Last I heard they haven't done much with it. Would be fun to dick around with it. I think you're better off getting better results doing it yourself in C and then writing a C# parser of sorts and going from there. It'd probably get more done than any OS project.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
In my experience pointers confused the shit out of most people
It's surprising really, that someone that's in comp-sci can be confused by the concept of what pointers are. The concept isn't sufficiently difficult but there are just some people that can't make sense of it.
Then there's the difference between reference, pointer, and all that shit that just adds fuel to the fire.
pointers and references should be pretty par for the course for any decent compsci program.
where the real shit gets confusing is STL and Vectors.
In my experience pointers confused the shit out of most people
It's surprising really, that someone that's in comp-sci can be confused by the concept of what pointers are. The concept isn't sufficiently difficult but there are just some people that can't make sense of it.
Then there's the difference between reference, pointer, and all that shit that just adds fuel to the fire.
pointers and references should be pretty par for the course for any decent compsci program.
where the real shit gets confusing is STL and Vectors.
I don't know, that stuff was comparatively easy. I'm not saying pointers and references are hard, but, the concepts behind them can confuse the fuck out of people.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
I just came across the idea of using output buffering to increase PHP script speed. Aside from the implicit buffering that Apache does, am I wrong in thinking that manually invoking the ob_* functions would be pointless in a MVC environment? I mean, by the time output is supposed to be rendered, all of the heavy lifting is done, with only simple view logic remaining.
Nightslyr on
PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948 Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
Yeah, that won't really affect performance. What those functions are good for performance wise is capturing the output so that you can implement caching of it, so that the heavy lifting is not done on every request, up-front is fine but it doesn't persist.
This kind of stuff is fascinating to me. I think it would be so cool to have a whole new technology stack based on something other than UNIX.
You might want to read about Synthesis as well. (Massalin, 1992)
0
Apothe0sisHave you ever questioned the nature of your reality?Registered Userregular
edited September 2011
Familiarising myself with Python and loving it...
Is there a way to call a specific attribute (this is the wrong term, isn't it?) or method from a variable like so:
Like,
>>> b.foo
"bar"
Can you do something like
>>> a = "foo"
>>> b.$a
"bar"
or something so that a is interpreted as an attribute or method name?
I've been trying to google it or read through the language reference, but I'm not sure exactly what this would be called to check into it more efficiently.
How would you unit test the controls of a video game? Things like when A is pressed something happens? I was thinking of a class that you supply the key press and it alters an acceleration vector. Then I can test when a key is pressed the acceleration vector changes to what I expect it to be. However testing things like game logic might be more difficult. For collision detection I could setup a bunch of potential situations and determine if the objects collide. Anyone have any thoughts?
How would you unit test the controls of a video game? Things like when A is pressed something happens? I was thinking of a class that you supply the key press and it alters an acceleration vector. Then I can test when a key is pressed the acceleration vector changes to what I expect it to be. However testing things like game logic might be more difficult. For collision detection I could setup a bunch of potential situations and determine if the objects collide. Anyone have any thoughts?
Firstly, to unit test, make sure you're testing units. So if pressing A makes your character jump, then test that when your control class is given that input, that it invokes the jump() method on a mocked character. Then, separately, check that when the jump() method is invoked on your character, that the appropriate accelerations are applied.
For collision detection, yeah: firstly check your collision classes by setting up various situations and seeing if they collide, then test your broad-phase algorithms by setting up mocks
If you don't know how to unit test something because it's too big, or because there are too many steps between input and expected behaviour, that's a sign that you need smaller tests.
Is there a way to call a specific attribute (this is the wrong term, isn't it?) or method from a variable like so:
Like,
>>> b.foo
"bar"
Can you do something like
>>> a = "foo"
>>> b.$a
"bar"
or something so that a is interpreted as an attribute or method name?
I've been trying to google it or read through the language reference, but I'm not sure exactly what this would be called to check into it more efficiently.
This seems to be how to do it here. It's not quite as awesome of a solution as I'd expect from Python, but I guess it'll work.
Looks like you can use eval() as well, but the above solution is safer.
So yeah, diving into native node.js extensions and v8 engine is maybe a bit deep for a c++ novice. Lots of room to learn, but man, sometimes my eyes just glaze over looking over some of this source code.
jackfaces
"If you're going to play tiddly winks, play it with man hole covers."
- John McCallum
0
Apothe0sisHave you ever questioned the nature of your reality?Registered Userregular
Is there a way to call a specific attribute (this is the wrong term, isn't it?) or method from a variable like so:
Like,
>>> b.foo
"bar"
Can you do something like
>>> a = "foo"
>>> b.$a
"bar"
or something so that a is interpreted as an attribute or method name?
I've been trying to google it or read through the language reference, but I'm not sure exactly what this would be called to check into it more efficiently.
This seems to be how to do it here. It's not quite as awesome of a solution as I'd expect from Python, but I guess it'll work.
Looks like you can use eval() as well, but the above solution is safer.
Looks preeeeetty good - certainly solves my problem. Thanks Jimmy!
0
The AnonymousUh, uh, uhhhhhh...Uh, uh.Registered Userregular
So, my JSP/servlet class is on headers and stuff now. I understand all that, but our prof makes a note that since servlets are multithreaded, we need to be careful of how we use our counters.
Am I to assume I need to use a synchronize{} block to make my stuff thread-safe? Something like this:
int pageViews;
public void doGet(...){
synchronize(pageViews){
pageViews++;
if(pageViews % 2 == 0)
//output even number of pageviews
}
}
Hey guys, I have a java data structure question. I always find it hard to pick the most efficient one for what I'm doing. So I'm doing a flood_fill algorithm. http://en.wikipedia.org/wiki/Flood_fill The bottom one under Most Practical.
I got it working but it was slow as shit. I was using a LinkedList<Pixel> as the queue because I knew I would be removing alot and figured that would be efficient. I was wrong, mainly because I check a lot to see if a pixel is already in the queue. (Because I'm doing an 8-way fill, not 4).
So I implemented Comparable<Pixel> in my Pixel class and switched it to a TreeSet<Pixel> and it sped it up considerably but its still kind of slow. What is a good structure to house Pixels (double x, double y), where you will do many contains and removes and adds? Is TreeSet the best I'm going to do?
1) You can implement the list yourself and have each pixel object keep track of it's next/previous pointers. Testing for already being in the list becomes constant time.
2) If you can't do that, use an array of bools or something to keep track of the insertion status of your pixels to reduce the time checking if it's already in the list and a stack for your list
Also, you can try to use a further optimization of that algorithm: keep track of runs on the above/below pixels and only add one pixel per run to minimize list management overhead
1) You can implement the list yourself and have each pixel object keep track of it's next/previous pointers. Testing for already being in the list becomes constant time.
2) If you can't do that, use an array of bools or something to keep track of the insertion status of your pixels to reduce the time checking if it's already in the list and a stack for your list
Also, you can try to use a further optimization of that algorithm: keep track of runs on the above/below pixels and only add one pixel per run to minimize list management overhead
Really good ideas. With our special case, a co-worker actually thought of something that's similar to your #2. In my case, the images are a byte image, but we're only using 0 or 1. He had the idea of when adding to the queue, change that value to 2, and only go from 1 to 0 when you pop it off the queue. Then instead of structure.contains(pixel), I just have to see, pixels[x][y]!=2. Should be much much faster!
If we didn't have this special case of 0 or 1, I'd def. do #2.
Thanks!
Update:
In case anyone is interested, with using the image as an indicator as to whether a pixel was already on the queue, instead of doing a .contains() on the queue, the flood delete went from ~50% of the processing to 7% of the processing. And thats in the worst case sceneario. So, Woo! Interesting lesson learned!
Anyone care to take a swing at pointing me in the right direction for a Java assignment? I've tried fixing my issues for several hours now and I keep hitting new snags related to the problem.
Basically atm it's getting to the last element in the ArrayList and hanging with an ArrayList<E>RangeCheck error. The odd thing about it is that it correctly pulls the customer name from that row of the ArrayList then hangs on pulling the sales data when no new incrementing has occurred.
Also maybe thoughts on my approach atm: I'm parsing an invoice list and putting it into an ArrayList and sorting it. Then going back through it to process the report and generate a total sales report for each warehouse and grand totals. Customer names appear multiple times in the sample sales DAT from the professor, so when its sorted they are clumped together (hence checking to see if the next name is the same).
Dude you are accessing the next element of the arraylist even when you are on the last element with your while
while (arrayList.get(count).getCustName().equals(arrayList.get(count+1).getCustName())) {
Not to be mean but that whole thing needs to be reworked a bit. Why don't you use for each on your arraylist
and then reference the single Invoice object rather than looking it up from the arraylist for every method call?
edit: but...I can't see where moreCustomers is ever set to anything but true anyway
Thats a code fragment from trying to fix my problems. I'll clean it up later.... Since it doesn't harm anything atm and I wasn't sure if I would need to re-implement it later I left it for now.
Incindium: Thanks for pointing out the issue with the count+1. Should I make some kind of null check then? And I'll read up on foreach as well. This is the start of 2nd semester Java for me, so I don't know all of the ways to properly code yet. (Especially since most of my class is getting remedial review from the Professor while I work ahead and try to learn better ways of accomplishing the Projects. Pisses me off actually, because she's basically reteaching 1st semester to them while I pay for it...)
EDIT: Would I be better off scrapping the entire idea of parsing and sorting the invoice file first? And just going with something like a binary search for a matching customer name when each new line is read from the invoice file and add that data to it?
JediNight on
0
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
edited September 2011
Foreach is a beautiful thing. It nukes a lot of off-by-one bounds errors that otherwise pop up when you are learning a new language (or to code at all).
As a heads up, it looks like this in the languages I know and that have it:
Java
for(ThingType thing : box)
C#
foreach(var thing in box)
Javascript
for(var thing in box)
Go
for thing, index := range box
The only catch is that you lose the index number (except in Go). Most of the time you don't need it, but occasionally you do and have to go back to the traditional for(int i = 0; i < x; i++) format.
In Java you can do that with arrays and anything that implements Iterable
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
The only catch is that you lose the index number (except in Go). Most of the time you don't need it, but occasionally you do and have to go back to the traditional for(int i = 0; i < x; i++) format.
The only catch is that you lose the index number (except in Go). Most of the time you don't need it, but occasionally you do and have to go back to the traditional for(int i = 0; i < x; i++) format.
It's also easy to get the index number in Python:
for thing, index in enumerate(box):
Yeh I really need to sit down and learn python at some point.
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
The only catch is that you lose the index number (except in Go). Most of the time you don't need it, but occasionally you do and have to go back to the traditional for(int i = 0; i < x; i++) format.
It's also easy to get the index number in Python:
for thing, index in enumerate(box):
Umm...you have it backwards:
for idx, thing in enumerate(box):
stuff
It also supports a start parameter in case you want to start counting from something other than 0.
Rollers are red, chargers are blue....omae wa mou shindeiru
Ugh. Am I wrong in thinking there is no reason that dictionaries aren't serializable in C#?
I'm trying to save sprite sheet metadata to XML files with XNA. Does anyone have any suggestions for how to do this now that I can't just serializer.Serialize()? I'm not married to XML either, but I'd like to just implement a ready-made solution and get on with the interesting parts.
Ugh. Am I wrong in thinking there is no reason that dictionaries aren't serializable in C#?
I'm trying to save sprite sheet metadata to XML files with XNA. Does anyone have any suggestions for how to do this now that I can't just serializer.Serialize()? I'm not married to XML either, but I'd like to just implement a ready-made solution and get on with the interesting parts.
They aren't XML serializable out of the gate, but you can do a few things.
One would be to do a binary serialize of the dictionary object and then stuff that as binary data into a member that then is serialized by your overall XML process.
Another would be to implement your own SerializableDictionary from Dictionary and IXmlSerializable.
0
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
edited September 2011
Yeh I hit that little snag when trying to save dictionaries in Profiles in ASP.NET. (that and the fun that is specifying generic types in web.config) I ended up just specifying binary serialization and it worked out fine...
...except come to find out I didn't have anywhere to actually put the profile data since we use Oracle instead of MS SQL server at work and the backflips you have to perform to get that working ended up being incompatible with other weird things that we are doing with Oracle.
tl;dr Oracle is weird.
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
Ugh. Am I wrong in thinking there is no reason that dictionaries aren't serializable in C#?
I'm trying to save sprite sheet metadata to XML files with XNA. Does anyone have any suggestions for how to do this now that I can't just serializer.Serialize()? I'm not married to XML either, but I'd like to just implement a ready-made solution and get on with the interesting parts.
They aren't XML serializable out of the gate, but you can do a few things.
One would be to do a binary serialize of the dictionary object and then stuff that as binary data into a member that then is serialized by your overall XML process.
Another would be to implement your own SerializableDictionary from Dictionary and IXmlSerializable.
Or you can XML serialise a list of DictionaryEntry objects and then reconstruct the dictionary with them on deserialisation.
mmmm, foreach. I just had to go through a bunch of javascript at the new job written by an old C/C++ dev and turn for loops into foreach because there were off by one errors in all of them and they required manual fiddling any time new category thingies get added to the site. He's a smart guy, wrote multithreaded c++ stuff that works afaik, so just not up on this fancy newer stuff.
btw, be careful with the "for(var thing in box)" style of foreach in js. If you're iterating over an Array(), with "for(var thing in box)" you're actually getting the keys because it iterates over the object's dictionary (or something like that). That shit gets me every damned time. JavaScript also has a proper Array.forEach() which returns the values rather than the keys/indexes but IE didn't support it until IE9 so it's not terribly useful.
myArray = new Array();
myArray[0] = "zero";
myArray[1] = "one";
myArray[2] = 2;
myArray[3] = 3;
myArray[4] = 4;
myArray.forEach(function(x) { alert(x)});
/* or if you also want the index, similar to python you can do this. x and idx may be backwards*/
myArray.forEach(function(x, idx) {alert("Index is " + idx + " and value is " + x);
Posts
pointers and references should be pretty par for the course for any decent compsci program.
where the real shit gets confusing is STL and Vectors.
Joe's Stream.
I don't know, that stuff was comparatively easy. I'm not saying pointers and references are hard, but, the concepts behind them can confuse the fuck out of people.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
You might want to read about Synthesis as well. (Massalin, 1992)
Is there a way to call a specific attribute (this is the wrong term, isn't it?) or method from a variable like so:
Like,
Can you do something like
or something so that a is interpreted as an attribute or method name?
I've been trying to google it or read through the language reference, but I'm not sure exactly what this would be called to check into it more efficiently.
How would you unit test the controls of a video game? Things like when A is pressed something happens? I was thinking of a class that you supply the key press and it alters an acceleration vector. Then I can test when a key is pressed the acceleration vector changes to what I expect it to be. However testing things like game logic might be more difficult. For collision detection I could setup a bunch of potential situations and determine if the objects collide. Anyone have any thoughts?
For collision detection, yeah: firstly check your collision classes by setting up various situations and seeing if they collide, then test your broad-phase algorithms by setting up mocks
If you don't know how to unit test something because it's too big, or because there are too many steps between input and expected behaviour, that's a sign that you need smaller tests.
This seems to be how to do it here. It's not quite as awesome of a solution as I'd expect from Python, but I guess it'll work.
Looks like you can use eval() as well, but the above solution is safer.
"If you're going to play tiddly winks, play it with man hole covers."
- John McCallum
Looks preeeeetty good - certainly solves my problem. Thanks Jimmy!
Am I to assume I need to use a synchronize{} block to make my stuff thread-safe? Something like this:
It's not the cleanest looking thing, but:
If you inspect it you'll see something like:
An if you're stll looking for another way you can even do
I got it working but it was slow as shit. I was using a LinkedList<Pixel> as the queue because I knew I would be removing alot and figured that would be efficient. I was wrong, mainly because I check a lot to see if a pixel is already in the queue. (Because I'm doing an 8-way fill, not 4).
So I implemented Comparable<Pixel> in my Pixel class and switched it to a TreeSet<Pixel> and it sped it up considerably but its still kind of slow. What is a good structure to house Pixels (double x, double y), where you will do many contains and removes and adds? Is TreeSet the best I'm going to do?
Thanks!
Oh, and the images I'm working on are ~3kx3k.
2) If you can't do that, use an array of bools or something to keep track of the insertion status of your pixels to reduce the time checking if it's already in the list and a stack for your list
Also, you can try to use a further optimization of that algorithm: keep track of runs on the above/below pixels and only add one pixel per run to minimize list management overhead
Really good ideas. With our special case, a co-worker actually thought of something that's similar to your #2. In my case, the images are a byte image, but we're only using 0 or 1. He had the idea of when adding to the queue, change that value to 2, and only go from 1 to 0 when you pop it off the queue. Then instead of structure.contains(pixel), I just have to see, pixels[x][y]!=2. Should be much much faster!
If we didn't have this special case of 0 or 1, I'd def. do #2.
Thanks!
Update:
In case anyone is interested, with using the image as an indicator as to whether a pixel was already on the queue, instead of doing a .contains() on the queue, the flood delete went from ~50% of the processing to 7% of the processing. And thats in the worst case sceneario. So, Woo! Interesting lesson learned!
Basically atm it's getting to the last element in the ArrayList and hanging with an ArrayList<E>RangeCheck error. The odd thing about it is that it correctly pulls the customer name from that row of the ArrayList then hangs on pulling the sales data when no new incrementing has occurred.
Also maybe thoughts on my approach atm: I'm parsing an invoice list and putting it into an ArrayList and sorting it. Then going back through it to process the report and generate a total sales report for each warehouse and grand totals. Customer names appear multiple times in the sample sales DAT from the professor, so when its sorted they are clumped together (hence checking to see if the next name is the same).
http://www.privatepaste.com/2ac2c1ac0c
I can't stop looking at this:
edit: but...I can't see where moreCustomers is ever set to anything but true anyway
Not to be mean but that whole thing needs to be reworked a bit. Why don't you use for each on your arraylist
and then reference the single Invoice object rather than looking it up from the arraylist for every method call?
IE
etc.
Nintendo ID: Incindium
PSN: IncindiumX
Thats a code fragment from trying to fix my problems. I'll clean it up later.... Since it doesn't harm anything atm and I wasn't sure if I would need to re-implement it later I left it for now.
Incindium: Thanks for pointing out the issue with the count+1. Should I make some kind of null check then? And I'll read up on foreach as well. This is the start of 2nd semester Java for me, so I don't know all of the ways to properly code yet. (Especially since most of my class is getting remedial review from the Professor while I work ahead and try to learn better ways of accomplishing the Projects. Pisses me off actually, because she's basically reteaching 1st semester to them while I pay for it...)
EDIT: Would I be better off scrapping the entire idea of parsing and sorting the invoice file first? And just going with something like a binary search for a matching customer name when each new line is read from the invoice file and add that data to it?
As a heads up, it looks like this in the languages I know and that have it:
Java
C#
Javascript
Go
The only catch is that you lose the index number (except in Go). Most of the time you don't need it, but occasionally you do and have to go back to the traditional for(int i = 0; i < x; i++) format.
In Java you can do that with arrays and anything that implements Iterable
It's also easy to get the index number in Python:
Yeh I really need to sit down and learn python at some point.
It also supports a start parameter in case you want to start counting from something other than 0.
I'm trying to save sprite sheet metadata to XML files with XNA. Does anyone have any suggestions for how to do this now that I can't just serializer.Serialize()? I'm not married to XML either, but I'd like to just implement a ready-made solution and get on with the interesting parts.
They aren't XML serializable out of the gate, but you can do a few things.
One would be to do a binary serialize of the dictionary object and then stuff that as binary data into a member that then is serialized by your overall XML process.
Another would be to implement your own SerializableDictionary from Dictionary and IXmlSerializable.
...except come to find out I didn't have anywhere to actually put the profile data since we use Oracle instead of MS SQL server at work and the backflips you have to perform to get that working ended up being incompatible with other weird things that we are doing with Oracle.
tl;dr Oracle is weird.
Or you can XML serialise a list of DictionaryEntry objects and then reconstruct the dictionary with them on deserialisation.
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
btw, be careful with the "for(var thing in box)" style of foreach in js. If you're iterating over an Array(), with "for(var thing in box)" you're actually getting the keys because it iterates over the object's dictionary (or something like that). That shit gets me every damned time. JavaScript also has a proper Array.forEach() which returns the values rather than the keys/indexes but IE didn't support it until IE9 so it's not terribly useful.