normally, I would just use
lua_pushstring(lua_State* L, const char* s);
however, the string I want to push might have a null character in it. How do I make that work?
The Navigation framework in Windows Mobile 7 is a cut down version of what is in Silverlight. You can only navigate to a Uri and not pass in a view. Since the NavigationService is tied to the View, how do people get this to fit into MVVM. For example:
public class ViewModel : IViewModel
{
private IUnityContainer container;
private IView view;
public ViewModel(IUnityContainer container, IView view)
{
this.container = container;
this.view = view;
}
public ICommand GoToNextPageCommand { get { ... } }
public IView { get { return this.view; } }
public void GoToNextPage()
{
// What do I put here.
}
}
public class View : PhoneApplicationPage, IView
{
...
public void SetModel(IViewModel model) { ... }
}
I am using the Unity IOC container. I have to resolve my view model first and then use the View property to get hold of the view and then show it. However using the NavigationService, I have to pass in a view Uri. There is no way for me to create the view model first. Is there a way to get around this.
Background:
I have two 2d arrays. Each index within each 2d array represents a tile which is drawn on a square canvas suitable for 8 x 8 tiles.
The first 2d array represents the ground tiles and is looped and drawn on the canvas using the following code:
//Draw the map from the land 2d array
map = new Canvas(mainFrame, 20, 260, 281, 281);
for(int i=0; i < world.length; i++){
for(int j=0; j < world[i].length; j++){
for(int x=0; x < 280; x=x+35){
for(int y=0; y < 280; y=y+35){
Point p = new Point(x,y);
map.add(new RectangleObject(p,35,35,Colour.green));
}
}
}
}
This creates a grid of green tiles 8 x 8 across as intended.
The second 2d array represents the position on the ground. This 2d array has everyone of its indexes as null apart from one which is comprised of a Person class.
Problem
I am unsure of how I can draw the position on the grid. I was thinking of a similar loop, so it draws over the previous 2d array another set of 64 tiles. Only this time they are all transparent but the one tile which isn't null. In other words, the tile where Person is located.
I wanted to use a search throughout the loop using a comparative if statement along the lines of
if(!(world[] == null)){
map.add(new RectangleObject(p,35,35,Colour.red));}
However my knowledge is limited and I am confused on how to implement it.
Is it possible to use llvm to run x86 programs? I.e. I want to use llvm as an x86 simulator to run x86 programs and then instrument the x86 program.
Thanks!
I'm attempted to extend code, and have come across an issue, I don't understand a line of code. I know the outcome of it - but I don't understand how it happens and am naturally enough scared to change it.
The line of code I've come across is this:
MyGenericRelation().contribute_to_class(model, 'field_name')
The result of this code is a field with 'field_name' is added to the 'model' and from what I gather the objects inside the field are a list of type X (part of MyGenericRelation).
I'm wondering if anyone can explain how this works.
As in, why do I get a list of X objects attached to 'field_name' and if does it have to be generic relations prior to contribute_to_class or would using an actual model type, say 'Y' just give me a list of Y's.
To be honest, I am more interested in the affect and functionality of the contribute_to_class method.
It's well know that
1) the way computers actually work
2) the way computers are protrayed in movies
are not the same. In particular (2) looks much much cooler than (1). Where can I learn more about making flashy, superficially useful but deepdown useless fancy graphics UIs like that?
It's almost in the realm of "hollywood special effects" -- like fire/smoke/fire, but I don't want natural phenomenon; I want user interfaces.
Concrete question: where can I learn about creating flashy, cool looking (though not necessairly useful) user interfaces? [Perferably in OpenGL]
In many scheme/lisp dialects, when an error occurs, a "recursive repl" is popped up ... one can execute scheme/lisp code at the frame where the error occured, and go up/down the stack.
Is it possible to do something similar to this in lua?
Thanks!
Procedural techniques is common for texture synthesis, modeling plants, and modeling terrains. However, I've seen very little work on algorithmic construction of robots, which is a bit surprising given how mechanical these systems are.
Anyone have a good resource on the algorithmic construction of robots / robotic humanoids?
Thanks!
I have a class A with a public method in C#. I want to allow access to this method to only class B. Is this possible?
UPDATE:
This is what i'd like to do:
public class Category
{
public int NumberOfInactiveProducts {get;}
public IList<Product> Products {get;set;}
public void ProcessInactiveProduct()
{
// do things...
NumberOfInactiveProducts++;
}
}
public class Product
{
public bool Inactive {get;}
public Category Category {get;set;}
public void SetInactive()
{
this.Inactive= true;
Category.ProcessInactiveProduct();
}
}
I'd like other programmers to do:
var prod = Repository.Get<Product>(id);
prod.SetInactive();
I'd like to make sure they don't call ProcessInactiveProduct manually:
var prod = Repository.Get<Product>(id);
prod.SetInactive();
prod.Category.ProcessInactiveProduct();
I want to allow access of Category.ProcessInactiveProduct to only class Product. Other classes shouldn't be able to call Category.ProcessInactiveProduct.
I have a string in lua.
It's a bunch of [a-zA-Z0-9]+ separated by a number (1 or more) spaces.
How do I take the string and split it into a table of strings?
Thanks!
:bn , :bp just switches buffers
I want something like ctrl-o, which has a 'stack' of marks it jumps through.
However, I want it to ignore marks in the same file ... i.e
i want ctrl-my-o to be ctrl-o until you hit a different file
and ctrl-my-i to be ctrl-i until you hit a different file
Is there somethig like this in vim?
I'm using LLVM-clang on Linux.
Suppose in foo.cpp I have:
struct Foo {
int x, y;
};
How can I create a function "magic" such that:
typedef (Foo) SomeFunc(Foo a, Foo b);
SomeFunc func = magic("struct Foo { int x, y; };");
so that:
func(SomeFunc a, SomeFunc b); // returns a.x + b.y;
?
Note:
So basically, "magic" needs to take a char*, have LLVM parse it to get how C++ lays out the struct, then create a function on the fly that returns a.x + b.y;
Thanks!
I'm looking for something similar to List<T>, that would allow me to have multiple T. For example: List<TabItem, DataGrid, int, string, ...> = new List<TabItem, DataGrid, int, string, ...>().
void main(void)
{
vec4 clipCoord = glModelViewProjectionmatrix * gl_Vertex;
gl_Position = clipCoord;
gl_FrontColor = gl_Color;
vec3 ndc = clipCoord.xyz / clipCoord.w;
So the clipCoord is just doing standard fixed pipeline ransforms.
Now, the ndc ... why do I divide by w, and what do I get from this?
I have a string like this:
<span style="font-weight: bold;">Foo</span>
I want to use PHP to make it
<strong>Foo</strong>
…without affecting other spans.
How can I do this?
In C, I have format strings, something like:
char *msg = "wlll you marry me"
fprintf(stderr, "%s, %s?", name, msg);
Now, can I do something similar in lua with format strings? I.e. I want something functionally equivalent to:
name .. ", " .. msg .. "?"
but not so ugly, in lua.
Okay, so I can do string.format("%s, %s?", name, msg), but can I go even a step further, something like perl style, where I can go:
"%name, %msg?"
Thanks!
I am aware of J & K; but neither are open source.
I'm also aware of A+, but that seems outdated.
Is there any decent open source implementation of APL?
If so, where; is not, why?
Thanks!
The classical C program is something like:
int main() { fprintf(stderr, "hello world\n"); }
a classical OpenGL program is:
open up a window
setup ortho view
draw a colored triangle
Now, I want to do the most basic thing for sound in Linux.
I want to:
1) open up speakers
2) send a bunch of data, meant to be interpreted at 40Khz,
3) have pseakers play said data
no midi, no instruments, ... just playing back raw data
What is the easiest way to do this in a C program? [and what libraries; what's the equiv to OpenGL for sound?]
Thanks!
__thread Foo foo;
How is "foo" actually resolved? Does the compiler silently replace every instance of "foo" with a function call? Is "foo" stored somewhere relative to the bottom of the stack, and the compiler stores this as "hey, for each thread, have this space near the bottom of the stack, and foo is stored as "offset x from bottom of stack"" ?
Insights please.
so
1GvG:s/..../g
can replace over an entire buffer
However, suppose I have multiple vim buffers loaded, and I want to do a :s over all the buffers that are writable; is there a way to do this in vim?
Does anyone know a collection of articles or books that describes the implementation of the GNU Scientific Library?
This question is not about using the GSL; it's about how the GSL is implemented, their design decisions / tradeoffs.
Thanks!
I am trying to pass a variable from one page, load another and enter that information.
something Like this:
When 127.0.0.1/test.html&ID=1234
location.href = "127.0.0.1/newpage.html"
if (location.href == newpage.html){
var e = document.GetElementById("Loginbx");
e.Value = ID
}
I don't have access to modify 127.0.0.1/test.html nor newpage.html but would like to pass variables to them from another. Is this possible?
I've been programming off and on since 4th grade (for about 20 years). Technology is one of my passions but after working in the field for a couple years out of High School, I spent nine months and $15,000 getting an accredited certificate in music performance instead of CS.
I've been doing lots of self study but I think a CS degree is overkill for most line of business applications. Even so, HR departments can't be expected to know that...
How does one get their foot in the proverbial door without a degree, especially in a smaller "fly-over country" market?
...or...
Where can I get the cheapest/easiest degree that will pass muster (including testing out of as much as possible)?
Don't get me wrong, I'm down with learning new things but I don't necessarily need the expense or coaching to motivate me.
EDIT
Consolidating good answers:
Networking/User Groups
Portfolio/Open Source Contributions
Look for hybrid jobs (How I got my start :) )
Seek un-elitist companies/hiring managers. (Play the numbers game)
Start my own business. (This is a bit challenging for a family man but a very good answer. My reason for searching is to reduce my commute thereby allowing more time to cultivate income on the side)
Avail myself of political subsidies to constituents in the teachers' unions ;) .
Note, my question is not: how do I tell my compiler to compile with profiling on.
I want to profile my compiles process. For each file, I'd like to know how much time is spent on each line of the program.
I'm working on a project, some files have huge compile times, I'm trying to figure out why.
Is there anyway to do this with g++ or llvm-clang?
Thanks!
cat test.cpp
#include <iostream>
int main() {
int à;
}
results in:
clang++ test.cpp
test.cpp:4:7: error: expected unqualified-id
int à;
^
1 error generated.
Now, is there a way to get clang to allow unicode variable names?
Thanks!