Message to guy sitting next to me on the train: Stop picking your nose. It’s gross. It’s unsightly. Your attempts to disguise it are failing.
This weekend Jerry came over and we picked up an Xbox 360 Elite to replace our old and dead one. I guess I’ll be putting in those exhaust fans a little sooner than I expected. This is a good thing because it gets pretty warm beneath our television set. What was meant to keep the most destructive force in nature (our children) out of our electronics is actually destroying them as well.
It came with a couple free games one of them being Lego Batman. It’s actually pretty fun to play and allows a game better suited for kids to watch then say… Wolfenstein. I’m not so sure watching zombies and people explode into chunky bits and pieces spewing unbelievable amounts of blood and fluid is healthy for their little minds.
We visited with my parents a little. It had snowed a little; maybe half an inch. Henry loves the snow and was playing outside in it while I dropped off a couple things.
I need to finish up my Christmas shopping this week. I am excited about all the good food to look forward to. Visiting will be nice especially with friends. Family tends to be more stressful than anything. Is that normal?
I’ve lightened my backpack by 5 or so pounds and it’s because I’ve just finished The Hitchhiker’s Guide to the Galaxy by Douglas Adams. I’ll miss my daily commuting companion but I won’t miss the weight.
First off, I thoroughly enjoyed this book which isn’t a surprise given that the book has a decent level of popularity. My mistake in reading the book is also what kept me going: the author’s forward which explained some of the the reasons the book’s five member books seemed disjointed. The characters were somewhat unique and interesting.
I guess one of my few gripes is the ending. It makes sense and it was fairly predictable… but it doesn’t give you any closure.
I am looking to reread William Manchester’s The Arms of Krupp or some other wholesome historic goodness. After having put my head through an egg beater with Hitchhiker’s Guide I need to ground myself.
Recently I tried to get my Android Virtual Device (AVD) to run on my recently updated Ubuntu install and ran into the usual disheartening array of messages, errors, and other strange cruft that comes with that. Start and finish buttons in the Eclipse IDE weren’t responding. I tried running an AVD and got messages like “could not find virtual device”.
There is a decent page on fixing the AVD problem in Windows and although anyone with half a wit can extrapolate and figure out that the similar can be done to fix the issue in Linux, I’ve done that and share:
ln -s /root/.android/avd ~/.android/avd
To summarize (for both cases), we’re creating symbolic links from where the Android SDK thinks the AVDs should be to where they actually are. You will probably need to delete the directory ‘avd’ within your ~/.android directory before running that command.
While I’m at it, there is some general wonkiness getting Eclipse 3.5 to run properly on Ubuntu 9.10. I was having trouble with groups and owners (Android SDK installation has them set to root when you install so you’ll have to chown and chgrp recursively through the tree) and sometimes certain features simply don’t respond. The following code seems to alleviate the IDE issues.
#/usr/bin/bash
export GDK_NATIVE_WINDOWS=1
`~/bin/eclipsePackage/eclipse3.5/eclipse -vmargs -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=512M /dev/null`
This assumes that you are running Eclipse on Linux via a Bash script. Most of the command is from the usual Ubuntu/Eclipse forums on how to start eclipse. The important line is the one about the GDK stuff.
I hope that helps. We’ve been running Android 1.5, 1.6, and 2.0. Each time a new version gets released we all need to tweak things here and there. With how young the SDK is and how little there is about it out there the more stuff we can all share the better.
Recently I was having a discussion about putting together an API and some ideas about caching, rate limiting or flood protection, design patterns for rendering the output, scalability, and security came up.
A while ago I came up with a rate limiting class. It wasn’t as thoroughly tested as I would hope as I left a little over a week after putting this together there, but basically we use time as a cross thread limiter for all connections. If we wanted to limit a particular user, then we’d simply have to create a unique key for the memcache entry for each user.
This logic uses time (as Unix timestamps with microseconds) as a method to “charge” each request against the server a “fee” which accrues against the max or limit. As time moves forward, it removes accrued cost from the memcache saved value.
The beauty of doing rate limiting in code is it allows the developer to manage flow and how limits are handled to protect our databases and CPU load; dishing out less expensive and properly (and expected) formed API responses.
Here’s the code:
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// RATE LIMITER CLASS - rateLimiter.class.php
//
// @date: 2009.05.21
// @author Michael Hradek
// @version 1.0.0
// @license Apache License, Version 2.0
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// INCLUDES
////////////////////////////////////////////////////////////////////////////
require_once("initializeMemcache.class.php");
////////////////////////////////////////////////////////////////////////////
// PRIMARY CLASS
////////////////////////////////////////////////////////////////////////////
class rateLimiter
{
private $rateLimitKey;
private $rateLimitMax;
private $rateLimitCost;
private $memcache;
function __construct($rateLimitMax, $rateLimitCost,
$rateLimitKey = "rate_limiter_key")
{
$this->rateLimitMax = (float)$rateLimitMax;
$this->rateLimitCost = (float)$rateLimitCost;
$this->rateLimitKey = $rateLimitKey;
// Initialize your memcache. This is just one way of initializing it.
$this->memcache = InitializeMemcache::initMemcache();
}
public function enforceRateLimit()
{
$rateLimitDataMs = $this->memcache->get($this->rateLimitKey);
list($partMsec, $partSec) = explode(" ", microtime());
$currentTimeMs = $partSec.$partMsec;
if($rateLimitDataMs === false)
{
$this->memcache->set($this->rateLimitKey, $currentTimeMs,
MEMCACHE_COMPRESSED);
return true;
}
$timeDiffMs = $rateLimitDataMs - $currentTimeMs;
if($timeDiffMs < 0) {
$rateLimitDataMs = $currentTimeMs;
}
$rateLimitDataMs += $this->rateLimitCost;
if($timeDiffMs < $this->rateLimitMax)
{
if(!$this->memcache->replace($this->rateLimitKey,
$rateLimitDataMs, MEMCACHE_COMPRESSED)) {
$this->memcache->set($this->rateLimitKey, $rateLimitDataMs,
MEMCACHE_COMPRESSED);
}
return true;
}
$rateLimitDataMs += ($this->rateLimitCost*2);
if(!$this->memcache->replace($this->rateLimitKey, $rateLimitDataMs,
MEMCACHE_COMPRESSED)) {
$this->memcache->set($this->rateLimitKey, $rateLimitDataMs,
MEMCACHE_COMPRESSED);
}
error_log(get_class().": Rate limit enforced.");
return false;
}
}
The memcache class is simply something that reads memcache server configuration arrays and loads them into a memcache handle and returns it. I think with some larger volumes we can excuse things like misses in key lookups. We’re already using a hashed configuration. Why add the trouble of retrying?
During my travels across the wild and uncharted Internet I came across this interesting jewel. It’s a 10 year anniversary video from latex clothing designer Polymorphe out of Toronto. Titled Embryo, it’s put together by Dominic Vincent who does similar artsy and fetishy type things.
They’ve got some other mind bending stuff if you care to check it out. NSFW and all but really interesting. This isn’t anything terribly new but since I like it I thought I’d share it.
I’ve been switching off game mode and back into creative music recording mode with the completion of my most recent game Borderlands. I agree with Play magazine’s assessment. It’s a cross between Half-Life 2 and Fallout 3 taking on the cartoon approach and injecting a good amount of humor. I liked the game all the way through except the ending which I felt was massively under explained and felt rushed through. “You won. You may quit when ready.” comes to mind.
I also bought an additional Wii-mote and the New Super Mario Brothers game. It is a fantastic ride into memory lane. Again, the Play magazine review nailed it. It doesn’t add anything leaps and bounds new and multi-player gets to be crazy at higher levels… but… I question the writers of that mag’s game n00bness. Part of the fun in multi-player is how ridiculous and fun it is to try and get 4 people to go in the same direction without killing one another. It’s been fun to play with the kids and it’s brought the whole family together and for that the $50 or so was worth it.
Finally, I got my hands on Left 4 Dead 2 and to put it simply: awesome. They successfully taken what made the first game a hit and expanded it. More weapons to choose from, more interesting scenarios, and great sound. They bring back all the original monsters (although the “tank” still reigns supreme) and add some new twists. The difficulty in some areas seems a little off but I am happy to get a challenge. It seems the trend lately has been to make games enjoyable over challenging.
I am looking forward to getting my hands on Dragon Age: Origins, Call of Duty: Modern Warfare 2, Bayonetta, The Saboteur, Uncharted 2: Among Thieves, Final Fantasy XIII, Forza 3, Valkyria Chronicles, Gran Tourismo 5, Dante’s Inferno, DiRT 2, Wet, Diablo III, MagnaCarta 2, Resident Evil 5; just to name a few. Doesn’t help that my Xbox 360 has officially died. I guess I’m not too sad. I needed an excuse to get an Elite. But still, $300. Sad panda.
I’d like to play this a bit but as I poise to post about Crystal and my collaboration, I know I am running low on time.
It was nice 4 day weekend. We were really busy most of of the days. Thursday we made dinner and had guests. Crystal’s dad, step mom, and half brother came over and stayed a while. It was a fairly benign evening. My mom and sister showed up later. I’ve been making picture and movie discs of their trip to Bhutan and India. I finished that this weekend too.
I learned how to attach things to concrete this weekend with my dad. That was interesting. We rented a hammer drill and the things necessary to do it. Drilling holes into concrete was pretty easy which surprised me but it shouldn’t have since I suppose that’s what that type of tool is for.
We decorated the house and church this weekend in preparation for Christmas. It’s been tough hanging around the house with the kids especially Helen who is really eager to climb and destroy everything.
I finally updated michaelhradek.com and it’s got some basic info on it. Nothing amazing but hopefully I’ve have some time soon to give it a further update. Hopefully my “straight to the point”, “keep it simple”, and “don’t repeat yourself” look doesn’t end up discouraging potential employers!
No, not burghers. I wish there was an uninvited crowd of those showing up at my parents house while they were gone only to remain when they’ve returned. My parents house was burglarized last week. Fortunately, they only ran off with some material possessions money can replace and my parents weren’t hurt or anything. I spent this Saturday mostly helping my folks deal with that.