Ever wish that Java had associative arrays (aka assoc arrays) like in PHP? As in, $x["name"] = "Bill" ? Well, I created a helper class for Java which comes close to approximating it. It can even loop through it similar to foreach().
I call the class PseudoAssocArray, because it actually uses a HashMap to do the behind the scenes work.
Simply include the file attached at the top of the page in your project, then use it like so:
PseudoAssocArray temp = new PseudoAssocArray(1);
temp.put("name", "April");
temp.put("age", "26");
// ...
String n = temp.get("name");
You can even make it be 2 dimensional by supplying a 2 in the constructor. For example:
PseudoAssocArray temp = new PseudoAssocArray(2);
temp.put(0, "name", "April");
temp.put(1, "name", "Samuel");
// ...
String n = temp.get("1", "name");
Loop through like so:
temp.resetCounter(); //always do this first
while (temp.hasMore()) {
Object obj = temp.getNext();
// or: String s = (String) temp.getNext();
}
To loop through and get both key and value, try this:
temp.resetCounter();
while (temp.hasMore()) {
Map<String, Object> entry = temp.getNextMap();
String key = (String) entry.get("key");
String value = (String) entry.get("value");
}
Enjoy!
Software License Fine Print
This code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.
You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.
For example, on a Help/Credits screen: Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc. These outside developers neither endorse nor support this software.
If you use this code, feel free to email me to let me know! I'll include a link to your project here.
What you need is a password scheme that lets you use a different password for every site you go to, so even if one gets stolen, it won't comproise all your other sites.
Apple iPhone cables-- at Target they're $20. At Amazon
Let's say you already know the lat/long of a particular point on the map, and now you want to draw a box around it, or maybe you just need to know the lat/long coordinates of another point, so many km or miles away? Well, this is the script for you!
Enter your new best friend: Preferences.
Well, since a year has passed, I thought it might be nice to check again, not just the top 10, but some other well-known sites.
Well, I'm glad I didn't, because I fixed it with one simple trick after some googling. All you need to do is break out your vacuum cleaner, and clear the dust from the laptop's cooling system.
Programming from multiple computers is always a bit of a pain. What I normally do is I keep all my files on a USB drive, and just have to remember to carry it with me every where I go. I'm always worried about breaking or losing it, so I have to back it up like crazy.
Recently at my day job, I used Synergy to connect my main work computer to a spare computer I set on my desk but did not want to make room for another keyboard and mouse. I also did not want to connect our company network to the spare computer, for security reasons. Now, I could have just used a cross-over ethernet cable, but did not have a spare ethernet port on my main computer.