Android Apps
Recently, I’ve started writing apps for Android devices. It started when I got my new android phone just after Christmas. Over the past couple of weeks, I developed a nonograms app and a tile puzzle app. Both are available via the android market for free. Use the barcode scanner app on the images to take you straight to the page in the market.

Nonograms Online Free contains 100 puzzles and is ad-supported. I chose this to be my first app because it is also my first website. NonogramsOnline.com has been around for almost 4 years and has a fairly good following, so I ran with it and in the first 24 hours, over 100 people had installed the app.

Tile Puzzle is just a simple 4×4 grid of numbered squares (1-15) with one missing. We all have quite a few fond memories from our youth of these fun games. If you don’t remember them, try it out. Be warned, it can be addictive!
![]() Nonograms Online Free |
Scan the barcode to take you directly to that app’s page in the Market! |
![]() Tile Puzzle |
More apps are on the way!
What you should know about memory leaks
Have you ever noticed that your browser slows down after running for a while? Heck, most times the whole computer slows down after running for a while. This is primarily because a program requested a chunk of memory and not releasing that chunk when said program is done. This is called a memory leak.
When I speak of memory, I’m speaking of RAM, not the hard drive. RAM forgets everything when the computer turns off. The hard drive stores the programs, music, e-mails, etc. while the computer is off. At least until the hard drive fails, and it will one day. Reason #1 to Make Backups!
Every program uses RAM. It’s impossible to run a program without copying it to RAM first. On top of that, when a program needs more RAM, it requests it from the operating system. Once the program exits, the OS should release that RAM so another program can use it. Sadly, this is not always the case.
Checking for Leaks
It’s quite easy to check for memory leaks for a specific program. If you’re running Windows:
- Right click on the task bar and select task manager
- Click on the Processes tab
- Select Options -> Select Columns…
- Check the VM Size and Mem Usage
- Click OK
- Run the program, if its not already running
- Keep a watch on it’s statistics
- If the VM Size and/or Mem Usage keeps going up and not going down, that program has a memory leak!
Note: Once you do steps 3-5, you won’t have to do them again on that computer.
Using Linux or MacOS:
- Open a command prompt
- Run: top
- The columns to watch at Virt(ual Memory) and Res(idual Memory)
- Run the program, if its not already running
- Keep a watch on it’s statistics
- If Virt and/or Res keeps going up and not going down, that program has a memory leak!
Note: Press h for help while running top.
Most Leaks Occur in the Browser
Sadly, tons websites have memory leaks. To check for this:
- Do steps 1-5 above or run top
- Load up your browser
- Go directly to Google.com(No Leaks There!)
- Check the VM Size and Mem Usage
- Go to a site that regularly slows your browser down
- Check the numbers, they should have gone up
- Go back to Google.com
- Check the numbers again
If they don’t go down at all, you can almost guarantee that that website has at least one memory leak. I’ve noticed this is especially true for Cafe World and Frontierville on Facebook, but almost all flash-based game will have memory leaks because flash has memory leaks. That is why the newer versions of Firefox runs flash as a separate program.
Luckily, all you have to do is restart your browser and those numbers will be reset. Setting your homepage to something simple that doesn’t leak, about:blank is good, can help too.
Memory Leaks Are NOT Dangerous
These leaks are not dangerous, just frustrating and annoying. Restarting the program or computer will speed things back up. That’s not a permanent solution, but it is usually the easiest fix.
Another option is to call tech support, but most of the time they can’t do anything for you except forward your complaint to the proper department and tell you to restart your computer or the program. If you choose this option, make sure to have all your number written down before you even call.
Sometimes, the best solution is to just stop using that program or website. Find an alternative that doesn’t have memory leaks. You might even find a gem in the rough.
GCC 4.5
Over the last week, I’ve been updating my eeePC’s Gentoo linux to run GCC 4.5 and recompiling every package. The main reason is that now almost all my software is fully optimized for the Intel Atom processor. With only 1 relatively small hack, the rebuild went fairly smooth and my CFLAGS now contain “-march=atom -mtune=atom” !
The one small hack was placing a sed command inside the gcc 4.5 ebuild. It will build the first time without the command, but all subsequent builds will fail with an error that stage 2 and stage 3 are different. Here’s the line added to the src_unpack part of the ebuild: (Note: wrapping added)
[[ ${CFLAGS} == *-march=atom* ]] && sed -i
-e 's/(INSN_P/(NONDEBUG_INSN_P/g'
-e 's/!INSN_P/!NONDEBUG_INSN_P/g'
gcc/config/i386/i386.c
To keep it safe, the line check if you $CFLAGS has -march=atom in it. If so, then it runs the following sed command. Originally issued as a patch for gcc for all of us running an Atom processor(s), I swapped it around to a sed command, as a few forum posts pointed out.
Beyond making the ‘overlay ebuild’, there was only 1 other snag, and that was binutils. Using the new gcc, binutils just wouldn’t compile. The error was about the movbe instruction. Upgrading from 2.18 to 2.19 using the old gcc compiler did the trick. After that it was just a matter of waiting for all the packages to recompile.
If anyone is thinking about upgrading to gcc 4.5 on gentoo, it’s not all that bad. Make sure to read the Gentoo GCC Upgrading Guide before you do anything. Also, run a “cat /proc/cpuinfo” to get the model of atom processor and make sure your CFLAGS are set properly.
Are Games Moving to Legal Torrents?
Thursday, 1/21/2010, someone uploaded Mass Effects 2 to a torrent site. Between then and today, it has bounded to the top of The Pirate Bay’s PC Games category and #4 in the overall top 100. Today, the official game release date, the 14.35GB download has 1,877 seeders and 28,448 leechers according to TPB.
The retail version of this game comes with access to downloadable content. While this additional content can be purchased for $15 if the game comes second hand, that doesn’t help those that download the game illegally. The retail PC version can be found for at little as $43.
My theory is simple: This game was leaked by BioWare. They want to see how many people buy the game vs how many download it, when buying the game comes with extra content. The leak is just like an old school demo; the ones where you got the whole game, but just one level.
The business model makes perfect sense. The more people that download via BitTorrent, the more money saved from manufacturing. On top of that, removing retailers from the financial pyramid makes products cheaper for the consumer and more revenue directly to the producer.
Could we be returning to these earlier days? Could this be the future? Game makers releasing a low content version via BitTorrent and charging for additional content?
Cafe World Cheat #2
UPDATE 3/18/2010: I have created some tools to help at http://www.cafeworldhelper.com. Included are a cooking suggestion tool, more cheats and tricks, a forum, even a spice tool.
I’ve got another cheat for all you cafe world fans.
If you turn your stove toward a wall or table or another stove, you will not have to walk to the stove. Ever. In fact, the only place your character will walk to is a serving table.
Bonus Tip
Max your buzz rating to 105.0 by making sure no customer leaves without food. Following my original Cafe World post, will almost ensure this.
Once your employees are boxed in, if anyone leaves without food, (re)move the table/chair where that person was sitting.
Cafe World Cheat
UPDATE 3/18/2010: I have created some tools to help at http://www.cafeworldhelper.com. Included are a cooking suggestion tool, more cheats and tricks, a forum, even a spice tool.
UPDATE 2/6/2010: Cafe World upgraded their game this past week. Instead of a plant, you must use a chair or table now to block your employees.
Recently, I’ve been playing Cafe World on Facebook. It’s one of those games that you play in spurts, cooking food. It’s quite addicting, and leveling goes fairly quick. I’ve figured out an easy cheat that anyone can do.
You can block your employees behind serving counters and they don’t have to walk to the tables. They pick up the food and it magically appears on the table. Also, the employee will “clean” the counter directly in front of them, leaving all servings there and a plate in the dining room disappears.
There is a trick to doing this. You have to block them in with a small object. I use a plant:
The plant was even a gift from a neighbor. This is super simple and can help raise your buzz rating.
MySQL Timezone
I have been using a to do list web application for the past couple of years. It’s not perfect, but it gets the job done. Well, from time to time, I stay up past midnight and am still working on my to do list. When that happens, I have to manually set the completed date, but not anymore.
I changed the timezone for the mysql session of the web app. It’s quite simple. The app uses good programming practices, so there’s only 1 place that I had to modify: immediately after the database connect & select db. These two lines now run as well:
mysql_query( 'SET time_zone = \'-8:00\'' ); date_default_timezone_set( 'America/Los_Angeles' );
My timezone is -5:00 (EST), so I set the timezone to -8:00 (PST). That gives me until 3AM local time to complete the tasks. If only there was a way to set the timezone of a particular database or user.
HDTV using MPlayer
In my desktop computer, I’ve got an nvidia GeForce 6150 PCI-E video card. It has a built-in mpeg2 decoding helper in it. Using Linux, this is called XvMC, or Xvideo Motion Compensation. I finally got it partially usable.
I’m currently watching the news on WJBF, the only channel I get b/c I haven’t fully setup my antenna. Using xvmc is fairly simple:
mplayer -vc ffmpegmc12 -vo xvmc -framedrop dvb://WJBF-DT
I add -framedrop to keep the video and audio sync’ed. Mplayer will rant about waiting for retrace. Using OpenGL is actually better, for me at least.
mplayer -vo gl2 -framedrop dvb://WJBF-DT
It dropped 14 frames at the beginning, but hasn’t dropped another in 10 minutes. XvMC would have crapped out by now. A/V sync is still perfect. I’ve even got it full screen and it’s resizing from 1280×720 (720 HD resolution) to 1440×900.
X11 Forwarding
A few days, I moved my desktop computer out into the living room. The computer has a tuner card that can receive digital broadcasts. I don’t own a TV, so this is the closest I’ve got to one. I still have to set up lircd before I can use a remote, but I wanted something a bit easier
Today, I discovered a new trick … SSH X11 Forwarding. Now, I can play video on my desktop right from my netbook. It’s wonderful and very simple!
In the following instructions, the “A” refers to the computer playing the video and “B” refers to any other computer.
- Make sure “X11Forwarding Yes” is in your sshd_config file on computer A. Restart sshd if you had to uncomment/add it.
- On B, run `ssh -XC A`
- In the ssh session, type `DISPLAY=:0.0`.
- Now run mplayer or any other video player in the ssh session and it will play on computer A.
If you want to have a program run on computer A and use the screen on computer B, the process is very similar:
- Make sure “X11Forwarding Yes” is in your sshd_config file on computer A. Restart sshd if you had to uncomment/add it.
- On B, run `xhost A`
- On B, run `ssh -XC A`
- Now run mplayer or any other video player in the ssh session and it will play on computer A.
Step 2 authorizes use of the current display by computer A and only needs to be run once. Also, note that the display variable doesn’t need to be set when using B’s screen.
Mplayer works wonderfully when playing on my desktop, plus I control it via the ssh session. It has tons of keyboard shortcuts. The ones I use the most are space for pause and the arrow keys for skipping around.
PVR Update
In anticipation of TV shows coming back on, I’ve been tweaking my PVR scripts. These record shows from the digital airwaves right onto my computer. I’ve separated the script into two parts: recording and encoding. Each is a simple one line shell script that can be called easily from the command line or from a cron. The record.sh script is:
/usr/bin/mencoder dvb://$1 -ovc copy -oac copy -o "$2.mpeg" -endpos $3
All this does is copy the video and audio streams directly to the disk. The three parameters are the station name, as stated in ~/.mplayer/channels.conf, the filename and the end position. This end position can be the number or seconds to record, or a time format of hh:mm:ss. This makes recording fairly simple within the cron.
The encode.sh script contains:
/usr/bin/mencoder -vf scale=640:-2 -ovc xvid -xvidencopts bitrate=1700:threads=2 \ -oac copy "$1" -o "$1.avi"
This, slightly more complex use of mencoder, will scale the video to 640 wide, the height calculated to keep the aspect ratio. The video is encoded into xvid at 1700kbps using 2 threads. To speed up the encoding process, the audio is not re-encoded, but copied as is.
You will need to play with the number of xvid threads to find the best fps. I have a dual-core and it encodes the fastest with 2 threads. It does need to be an integer, and most dual-cores will work best at 2.
Then, two lines are required in the cron to record and encode the program:
59 19 * * 1 /dvr/record.sh WAGTNBC /dvr/shows/heroes 01:03:00 05 20 * * 1 /dvr/encode.sh /dvr/shows/heroes.mpeg



