Friday, April 10, 2009
Making Advance Wars work With EZ-FLASH IV cart
Advance Wars does not work with the standard EZ-Flash loader. You need to use GBATA instead. The link below explains the steps requred. To summarize: use GBATA's SRAM patcher on the .GBA file first, and then use the EZ-Flash loader to copy the .gba file, taking care to un-check the patch save box.
http://ezflash.sosuke.com/viewtopic.php?f=12&t=13261&hilit=advance+wars
Download GBATA: http://gbatemp.net/index.php?download=224
The question this raises: is there ever a time where you should use GBATA first? I don't know yet.
Saturday, February 28, 2009
Turning off over commit in the Linux kernel
Linux Malloc's never fails (or at least not until you request more than 150% of the available RAM). This is because the Kernel is optimistic - even if you ask for a lot of memory, maybe you won't use it. Seems like a bad bet, but as long as it's true, everything will run fine. As soon as it's false, the kernel starts killing processes randomly. Yuck.
This is because the swap partition does not grow. If you ask for more RAM than your actual ram PLUS your swap partition, Linux will happily "give" it to you, but has no recourse in the situation that you actually touch all those pages.
In the case that you want Malloc to fail if there's not enough available RAM (such as in embedded code), what to do?
The solution is to modify the kernel, or use syscntrl at run-time. I prefer the permanent solution, so here's how to do it.
In mm/mmap.c, about one page down are two variables which control the "over commit" strategy. Starting around line 80:
int sysctl_overcommit_memory = OVERCOMMIT_NEVER;
/* default = OVERCOMMIT_GUESS; heuristic overcommit */
int sysctl_overcommit_ratio = 0;
/* default is 50% */
Postscript: doing this often results in mallocs failing even when there is clearly lots of RAM remaining. It seems that Linux makes the general assumption that over commit is on, and kind of breaks if it's turned off. A better strategy may be to allow the default (default = OVERCOMMIT_GUESS; heuristic overcommit), and modify the code to be slightly more conservative. I find that heuristic overcommit tends to guess that there is about 2% more RAM available than really is. This would probably vary between machines/kernels/apps running a bit, though I haven't tested it.
Tuesday, February 10, 2009
Growing Kumquat's in a pot
Kumquats are delicious mini-citrus fruit with a sweet outer rind and a sour flesh. When eaten whole they are a wonderfully sweet, sour, and pungent experience, all in one bite-sized morsel.
Even better, Kumquats can be grown in a (large) pot, something really not possible with most other types of sweet citrus.
You can buy the plant from Lowes in San Diego for about $30. I decided to try growing one from seeds. Typically Kumquats are grafted onto hardier rootstock, which is not so easy for a home grower. But you can also grow them from seed. These general tips on growing indoor fruit trees are also helpful. It's a slow process, but you can also try rooting a cutting.
Wednesday, January 21, 2009
Asparagus pasta
Prep time: 10 min with Cuisinart to chop asparagus, otherwise ~20 min. Total time: about 30 min. Serves 2 people, or more if you go heavy on the pasta.
| 1lb asparagus | Chop into thin circles, about 1/8th of an inch or thinner. A Cuisinart makes this a snap! |
| 3 T olive oil (or Butter) | Sauté in pan with oil until asparagus is tender. Butter tastes better than olive oil. Start the pasta |
| 2 cloves crushed garlic 2 T lemon juice 1 T Worcestershire sauce 0.5t pepper 1 t salt angle hair pasta (cooked volume of pasta should roughly equal the volume of the asparagus) | Once all ingredients are mixed in (including pasta) it's ready to serve. Worcestershire sauce is important to the taste, but soy sauce could be subbed if needed. |
You can make it more filling by adding in 1lb of ground turkey.
(T = table spoon, t = teaspoon)
(c) 2009
Beef stu with beans
This stew is heavy on the veggies, and has zero potatoes (beans fill the starch role). Yummy!
| 1.5c pinto beans 1.5c red kidney beans | Soak overnight & then simmer for ~ 1 hour |
| olive oil for pot 2lbs London broil steak 2 medium onions 2-3 garlic cloves | Cut beef into small pieces (< .5in on a side) Chop onions and mince garlic Brown beef in a large pot (cook until water boils off), then add onion and garlic and cook till onion is transparent. |
| 0.25c flour | Add flour and cook until light brown. |
| beef bouillon (~8000mg sodium) 1t Worcestershire sauce 0.5t ground pepper 0.5c water | Washington's rich brown seasoning and broth is the best, but Wyler's beef bullion is almost as good. I put in enough to get 8g of sodium, but that may be too salty for some tastes. Add all, and mix until bullion is fully dissolved. |
| 7 c water cooked beans | I like to use the water from the beans, which adds extra flavor. Cook until meat is tender, perhaps 1 hour. |
| 7c carrots 3c celery 1lb frozen peas | Remove peas from freezer to start defrosting them. 7c of carrots is roughly a 2lb bag of carrots. Chop veggies smaller if you want them to cook faster. If you like crisp veggies, add carrots an hour before you want to eat, celery ~30 minutes before, and peas ~15. |
I like to cook the beans a long time so that they split open a bit and thicken up the stew nicely. If you don't like beans, try it with 8c of potatoes. Finding the right bouillon is key to this recipe. Look for something with MSG and onion powder. Plain old beef flavoring is a bit too dull.
Sunday, October 26, 2008
Best OS for low-end laptops: take 3
Just a quick update: less than a month after my two posts on the topic of the best OS for low end machines, somebody posted an Ask Slashdot on the same question. A quick glance thru the comments suggests that Linux is the most popular option, which isn't surprising given the audience.
The real value of the Ask Slashdot article, however, is that people are suggesting actual Distros. So far xubuntu doesn't get a lot of hits, suggesting that perhaps I didn't select the very best option for my own head-to-head tests. If you do decide to install Linux on your low end laptop, you should check it out:
Friday, October 24, 2008
Converting Windows filenames to Unicode
Let's say you used FindFirstFile, etc to get a list of file names. What character set will those files be in? Evidence suggests Windows code page 1252. Now, let's say you want to convert those 8-byte chars into Unicode. One easy way that almost works is:
wchar_t tmp[256]; // potential buffer overflow exploit here
swprintf(tmp, L"%S", name); // %S (note caps) converts narrow (8 byte) to unicode
This will fail, sooner or later, because this conversion only seems to work for ASCII defined characters (ie char values less than 127). WinLatin (1252) has plenty of characters which are not ASCII. You might think you'll never encounter them, but one way that they can creep in is if you use MSWord's smartquotes, and then paste text from Word into your filename. Probably filenames written by people outside of the US also tend to have these characters.
I don't know what would happen with swprintf if you had some other code page, but I'm guessing it also would be bad.
Here's the proper way to do it.
Not only does this work for 'fancy' characters, but it also prevents the buffer overflow bug.
Subscribe to:
Posts (Atom)