Monday, November 12, 2012

Dirty Letterpress

My friend Andy introduced me to an iphone game called letterpress. The concept is pretty simple and the game is easy to learn - you have a board full of letters and you can create words out of any number of them. You get points for ever letter used, subject to some nuances about how they are defended and such.
iPhone Screenshot 1
(The picture is from the appstore link above)

Andy beat me a couple of times quite handily. Which got me thinking about how this was a rather simple string search problem that I was failing at. Enter python.

#!/usr/bin/python
import sys

board = sorted(sys.argv[1].lower())

d = open('/usr/share/dict/words')
for w in d:
s = sorted(w.strip().lower())
if len(s) < 9: continue
i = 0; j = 0
while i < len(s) and j < len(board):
if s[i] == board[j]:
i = i+1
j = j+1
elif s[i] > board[j]:
j = j+1
else:
j = len(board)
if i == len(s):
print len(s), " ", w.strip()


And the expected results:

letterpress > ./letterpress.py evkrvtzahfcyxvgatiwigoezy | sort -nr
12   vociferative
12   overactivity
12   excogitative
11   viaggiatory
11   theatricize
11   rhyotaxitic
11   overagitate
11   heterotaxic
11   heterotaxia
11   gravitative
11   fevertwitch
11   exhortative
10   whitterick
10   vociferize
10   vociferate
10   victoriate
10   verificate
10   twitchfire
10   thieftaker

Needless to say Andy caught on quite quick that something was amiss :) I resigned.





Wednesday, October 31, 2012

[books] Hydrogen Sonata

The Hydrogen Sonata (Culture, #10)The Hydrogen Sonata by Iain M. Banks
My rating: 4 of 5 stars

Ian M. Bank's latest work is another Culture novel, with all the elements that make culture novels fun - androids, avatars, knife missles, Minds, GSVs. Includes the introduction of another pan-galactic species or two and contrasts between AI-life and bio-life. Its a fun read overall, though not the best Culture novel ever. If you're a Banks fan or a Culture fan, you should definitely read it. If you've never read Ian M Banks before, I would suggest Player of Games or Surface Detail before this one.

View all my reviews

Tuesday, August 21, 2012

[books] Blood Song


Blood Song (Raven's Shadow, #1)Blood Song by Anthony  Ryan
My rating: 5 of 5 stars

Every now and then, you stumble across an author through blind luck (or Amazon's recommendation algorithms) and discover a real gem. This book is one of those.

Blood Song is a great mix of politics, action, mystery, magic - all the elements of an epic fantasy novel. It tracks the life of a warrior from childhood through training into battle. Its ending is semi-conclusive, certainly paving the road for book 2, which I look forward to. Ryan's writing is really great, considering that the book is self published via amazon. Apparently it had a bunch of grammatical and other errors, but they have since been fixed.

At a $2.99 price point, I cannot recommend this book enough. I enjoyed it far more than Wizard's First Rule or A Game of Thrones - the story is very compelling and it has fewer downright nasty or gory bits. The only downside of the book is the lack of history about the world that he builds - the politicking is explained somewhat but nowhere close to the detail that Martin or Tolkien would go into.


View all my reviews

Sunday, July 15, 2012

[books] The Blacksmith's Son


The Blacksmith's Son (Mageborn #1)The Blacksmith's Son by Michael G. Manning
My rating: 4 of 5 stars

The Blacksmith's Son is Michael Manning's first book and it as a really great read. It has some of the traditional elements of fantasy (wizards, mages, runes, spells, hero who doesn't know his power, love interest etc), but the Manning manages to make the story interesting and does a great job with the writing.

The general idea probably feels familiar to anyone who has read sufficient number of fantasy books - hero whose parents were killed when he was a baby, raised in relative poverty, discovers his powers post puberty, love interest, chief antagonist etc. What makes the story and the book interesting is the relatively fresh writing style - Manning inserts enough quirky humor in there and makes the characters seem more 'normal' and less dour than say Tolkien's. Don't expect the deep lore of Tolkien, but its far, far better than say Wizard's First Rule which I hated.

Fun, quick read, I look forward to the next one in the series.


View all my reviews

Thursday, June 21, 2012

Mapping Caps Lock to Control on Windows 7

I find the Caps Lock key completely useless. On all my computers, I map it to the control key. This is rather straightforward to do on a Mac and in Linux, but slightly harder on a Windows 7 machine. Just slightly.

There are a few different tricks that exist on the web, but the easiest I found was the registry hack - all you need to do is create a new REG_BINARY key in HKLM/System/Control/Keyboard Layout (note the singular) called Scancode Map , put in the value below, and restart your machine.

Here is the MSDN article on the Scan Code Mapper. Basically, you can instruct it to remap keys to do whatever you wish. Two common configurations:


1. Map Caps Lock to Control (this is what I use) -  
00000000 00000000 02000000 1D003A00 00000000


2. Swap Caps and Control (I have no idea why someone would want to do this)
00000000 00000000 03000000 3A001D00 1D003A00 00000000

Obviously, use this at your own risk (though I think the risk of something going dramatically wrong is very minor). For the nerds, read the aforelinked MSDN article - the numbers actually make sense.

Saturday, May 12, 2012

[books] Reamde

ReamdeReamde by Neal Stephenson
My rating: 3 of 5 stars

Better than Anathem worse than Snow Crash. Fast read and a lot of fun. Much more like Snow Crash than any other recent Stephenson book - almost like his comeback novel. This is a fast paced adventure through a bunch of countries - mixing in computers, security, terrorisms, guns and what have you. I have always loved Stephenson's detail - his computer environments, his knowledge of how computer security actually works - all quite legitimate. This adds a sense of believability to his books that I really enjoy. If you like vintage Stephenson (ie not the Baroque Cycle stuff), you'll like this.

View all my reviews

[books] Ready Player One

Ready Player OneReady Player One by Ernest Cline
My rating: 4 of 5 stars

Fast, fun, awesome read. If you like Neal Stephenson, you'll like Cline. Immaculately researched, really readable, great combination of real and virtual worlds. Somewhat predictable, language is rather straightforward (unlike, say, Feersum Endjinn), but overall a wholly enjoyable read. Recommended.

View all my reviews

Sunday, June 12, 2011

Faster DNS Servers - namebench

Choosing the right DNS servers can make all the difference between a fast and snappy web browsing experience and a slow and untolerable one. I came across a utility called namebench, published by Google to test out DNS server speeds. It takes about 5 minutes and could result in a faster web experience - I would recommend giving it a shot. In my case, comcast is the fastest DNS server, so no changes needed to be made, but your environment may be different.





Full Disclosure: I work for Google. I do not work on Namebench. Please use it at your own risk.

Sunday, April 10, 2011

[books] Surface Detail


Surface DetailSurface Detail by Iain M. Banks
My rating: 5 of 5 stars

Ian M. Banks's latest Culture novel is, in my opinion, his best work to date. For the uninitiated, Culture novels usually revolve around the Culture, a perfect civilization of sorts, where people live as long as they want, benevolent (and sometimes malevolent) AIs control and provide for everything etc. Except there are tons of races in the galaxy (it is huge, after all) and the Culture deals with those both above and below it on the technological ladder. The most interesting sections of the Culture, Contact (the section dealing with other races) and Special Circumstances (the shady part of Contact) are usually at the center of most of I.M.B.'s Culture novels. No description of any of his works would be complete without mentioning the AIs or Minds as they are called. Generally AIs that control gigantic ships, AIs that are far, far outside the reach of any human, these have their own distinct personalities and play just as important a role in any Culture novel as any human character.

Surface Detail has it all - a new race, an interesting backward civilization, wierd connectons between virtual reality and the Real, crazy (literally insane) AIs with their own quirky personalities. The book is a fast read, I had a really hard time putting it down.

Couple of points of warning:
1. The book has foul language. Lots of it. It is not recommended for children; if it were a movie, it would be NC-17.
2. It is not as depressing as most of Banks's other books (Consider Phlebas for example).


View all my reviews

Tuesday, December 28, 2010

[books] Containment

ContainmentContainment by Christian Cantrell
My rating: 4 of 5 stars

Good pulp fiction - fast read, interesting idea, though not exactly the most original, and generally well written. There is a bit of a mystery element to it, so I won't go deep into the story, but suffice to say that the synopsis on the book misdirects: I was initially put off by it and left this book lie for a while on my kindle after I bought it. I would recommend ignoring it and just dive in. You'll know within the first quarter or so if this book is for you.


View all my reviews

[books] The Big Short

The Big Short: Inside the Doomsday MachineThe Big Short: Inside the Doomsday Machine by Michael Lewis
My rating: 5 of 5 stars

Extremely well written story of the financial crisis, from the insider's point of view. There is a bit of selection bias since all the "insiders" that Lewis interviews actually saw the crash coming and shorted the market. But don't let that detract from the book - its really well done and hard to put down. Lewis explains the various products and terms (CDOs, CDSs, tranches) quite well - most of which are different names for common sensical products anyway - and then goes on to explain how the mess was created, why it was very hard to value and where there was fraud versus bad judgement. He explains the greed factor - and the process of duping the rating agencies (S&P and Moody's).

The book reads like a fiction novel. Its fast, characters (all real people) are the kind you can relate to (like or hate). I loved this book and would strongly recommend it to anyone, regardless of your interest in finance.


View all my reviews

Tuesday, December 14, 2010

[books] Luka and the Fire of Life

Luka and the Fire of LifeLuka and the Fire of Life by Salman Rushdie
My rating: 4 of 5 stars

Not my favourite Rushdie book, but a pretty good one nonetheless. Think Rushdie crossed with Neil Gaiman and rather bright and written for children. Lots of mythological elements but explores dreams and families and has more fun stuff than usual Rushdie psychedelic strange stuff.

I cannot recommend an appropriate age for this book - certainly not too young since it could get a bit scary at times. All the usual Rushdie staples and extremely well written.



View all my reviews

Sunday, December 12, 2010

[books] The Player of Games

The Player of GamesThe Player of Games by Iain M. Banks
My rating: 4 of 5 stars

One of the best Ian M. Banks Culture novels I have read to date. Perhaps only Matter was possibly better.


Player of Games starts in the perfect Culture universe of parties and general good life - everything is provided for, there is no concept of money because its unnecessary and sentient robots are everywhere. It focuses on the protagonist, the best Culture player at any game ever designed. He has been studying and playing games all his life and is a natural recruit for Special Circumstances (Culture CIA equivalent) to go deal with a new civilization that centers completely around playing one game. This game decides who gets what post in their social and political hierarchies; all the way to the top: the game's ultimate winner is crowned emperor.


Interesting, fast paced, has many of the usual Culture elements of advanced civilizations meeting backward ones (but not willing to take them by force). Humorous sentient drones, interesting personality studies and a good story line make this book a very compelling read. Recommended if you like hard sci-fi, have enjoyed the works of Ian M. Banks, Vernor Vinge or Alastair Reynolds.


View all my reviews

Tuesday, December 7, 2010

[books] Pushing Ice

Pushing IcePushing Ice by Alastair Reynolds
My rating: 5 of 5 stars

Pushing Ice is my first Alastair Reynolds book. I bought it because it was recommended by the editors at Powell's in Portland (the best bookstore in the western united states, but thats a different story). I'm a big fan of other hard sci-fi authors like Vernor Vinge and Ian M. Banks and this book seemed to have all the right elements of a space opera.

It did not disappoint: it is fast moving, well written, excellent story and it has it all - politics, science, personal drama, aliens. Everytime I thought the book fell into a "usual" mold, the story twisted and accelerated to some other realm. For example: the book starts out with a ship that harvests comets for ice. Saturn's moon Janus, decides to leave orbit and take off on its own - an alien artifact that was masquerading as a moon and nobody realized this. The Rockhopper (aforementioned comet harvesting ship) is ordered to take off after the artifact and figure out what it is. Feels sort of like Rendezvous With Rama doesn't it? Except that it isn't. Its much, much more awesome. Conspiracy in the ship, on earth, who knows where, some bad luck, some bad decisions and the story just keeps accelerating. Starts to feel like Tau Zero. But its not; nor is it fair to give much away beyond this, part of the fun is discovering what happens next.

Its a very fast paced book, really hard to put down. It focuses on a few characters that are developed extremely well - most of the book has a background theme of an ongoing dispute between 2 former best friends. Few things that aren't amazing: while the book is well written, the language itself is not going to win the author awards. This is not to say that its incorrect, just very matter-of-fact. The ending is a bit anti-climactic - but not bad.

Overall: an outstanding work of hard sci-fi. Highly recommended if you like Vernor Vinge and/or Ian M. Banks.


View all my reviews

Tuesday, July 13, 2010

[books] Dragonflight

  Dragonflight (Pern: Dragonriders of Pern, #1)Dragonflight by Anne McCaffrey
My rating: 5 of 5 stars

Loved this book. I discovered this completely by accident while looking for fast reads in sci-fi off amazon. Since it was only 5 bucks, I took a chance and was very pleased at the result.

Dragonflight was first published in 1967. It is set on an earth-like planet that is part of a twin planet system. The basic idea is that when the second planet comes close to Pern, deadly Threads fall on Pern destroying any vegetation that they touch. Pern combats this using indigenous dragons that can teleport. Each dragon has a rider and the man-beast combination is used to destroy the Threads before they cause too much damage.

After reading the description, I will admit that I was not thrilled about the book. It seemed like a stretch; moreover, a story about a battle to save a planet from a recurring natural disaster? Sounds mildly depressing.

The book is anything but: it is very well written; McCaffrey's command over the language is commendable,  the story is extremely engaging, fast paced and mind bending. There is an interesting twist to the tale and I would recommend not reading up about the book on wikipedia a priori.

Strongly recommended if you're in the mood for some quick sci-fi.

View all my reviews >>

Friday, May 14, 2010

[books] Starbucked

Starbucked: A Double Tall Tale of Caffeine, Commerce, and Culture Starbucked: A Double Tall Tale of Caffeine, Commerce, and Culture by Taylor Clark

My rating: 3 of 5 stars
Fast, funny, reasonably balanced read into the workings of the coffee trade and Starbucs. Fascinating parts include the history of coffee consumption in the US - or large, milky, beverage consumption really. Insights into how Starbucks makes money, where the dollars in your $4 latte go, what Fair Trade coffee means and why it exists and finally, the cultural imperialism that Starbucks leads to. Clark tries to be neutral, but achieves that by stepping too far in one direction (anti- or pro- S'bucks) and then overcorrecting, giving the book a distinct "make up your mind" feel.

Not a book to buy, but a good pickup from the library and a fun read.

View all my reviews >>

Thursday, May 13, 2010

$4 latte breakdown

Sad how little of my coffee consumption goes back to the farmer. Breakdown of a $4 latte: http://bit.ly/cpkpJr

Wednesday, April 7, 2010

[books] Rework

Rework Rework by Jason Fried

My rating: 5 of 5 stars
I have great respect for 37signals: they seem to manage to build fantastic, usable product after product like clockwork. Moreover, I strongly agree with their focus on product design and how they generally run things.

Fried and DHH try to distill their philosophy down and put it into a form that is completely readable over a glass of wine and a sandwich. (2 hours, so maybe 2 glasses of wine?)

Key ideas that I love and completely agree with:
* Companies / products are trying to outdo each other in adding features, as if that was the only factor that sold things. Try to underdo the competition - have fewer features than your competition - but really nail the experience. Help people get stuff done.
* Workoholics are bad: they work so hard because they haven't figured out how to get stuff done quickly. Obsessing over minutae is not cool. Working all nights is not cool. Workoholics burn out (eventually). On a personal note: been there, seen that, this is so true, its not even funny.
* Don't plan: any more than you absolutely have to. ie plan for the next day/week but thats about it. Because planning is a joke - all you are doing is making a guess about what you / your team will have done by a certain time. The further out it is, the more variance you introduce and the worse your guess gets. So quit trying. Focus on the next important thing, keep yourself nimble and adjust.
* Be the *not* somebody. As in: UnderArmor is *not* Nike: they are not trying to be Nike. Virgin America is *not* like United and American (I made this one up). By focusing on who you hate and are trying really hard to *not* be, you clearly define who you are.
* Distributed teams work just fine. Make sure you have some time overlap, make sure you all meet up in real life every once in a while (1-2 times / quarter). +1 from personal experience.

This list goes on, this is stuff that I remember (ok I cheated and looked at the back cover and remembered some of the stories).

I think this book is great. It's such a fast read, it's a cheap book, you can get it on various i-devices, read it on your commute or while sitting in boring meetings - just make sure you read it.

View all my reviews >>

Monday, February 15, 2010

pound-o-meter

Full disclosure: I work for Google. I do not work on the AppEngine product in any capacity.

I wrote a webapp! It is designed to solve one problem: help you keep track of your weight. I had iphones and nexuses in mind, so it should work well on those.

Please check it out: http://poundometer.appspot.com/

Nerd Fanboy Talk:
I love AppEngine. I don't know of other technology that lets you go from something in your head to a production deployed app in a few minutes; where you don't have to worry about creating tables, dealing with databases, all that nasty stuff. And running your own servers too.

OK, I lied. I am aware it is possible to do these things running my own python/django instance or having someone host it or doing something similar with ruby/rails and a myriad of hosting services. Regardless, I stand by my adulation of AppEngine. The ability to write something and deploy it in minutes/hours is simply awesome.


Edit: 
Forgot the best bit: Throwing in an easter egg that triggers if user=.
Result (via twitter):
"oh and the bf made me a valentines day app (sort of)! Doesn't get any sweeter than that. ;)"

Nerd Stats:

find . | xargs wc -l
total: 236

python, appengine, Google Chart APIs.

Seashore to do simple image and favicon.

~3 hours, including an inordinately long time dealing with css and figuring out that stupid meta viewport tag to make it look right on a handheld.

Friday, February 12, 2010

[book] Matter

Matter Matter by Iain M. Banks

My rating: 4 of 5 stars
My third Ian M. Banks book and perhaps the best so far (Feersum Endjinn and Consider Phlebas being the other two). Matter does not have the distinct writing style of Feersum Endjinn, but is bigger and more interesting in scope. It is a Culture novel and the latest one in the series. Culture novels are distinguished by the fact that they are set in the post-materialistic, intergalactic society/empire called the Culture, but each book is a complete story and environment by itself, so one needn't go in order.

On genre:
Banks writes epic space dramas where the sci-fi and space elements just add that much more spice and deft story turns, but just like the other two books I've read, the space and sci-fi parts of the book are almost incidental. At the end of the day, it is really a political drama set on the edge of a culture clash between highly advanced and underdeveloped societies. The fact that it is set in space, allows Banks to use everything from extremely intelligent AIs to nanotech to really drive home the deification of a super advanced society from the perspective of the backwards. There is this constant, dark overhanging thought of how little the lives of billions of people matter when two highly advanced societies clash. This was present in Consider Phlebas as entire planets and star systems got destroyed in the Culture-Idiran war and is present in Matter as well.

On environment:
I enjoy reading about the environments he creates - Matter is set on a shellworld and it is difficult to explain what exactly that means and why it is interesting without revealing too much. Not only does he create one fantastic world, he throws in 5 distinct species competing for this world (in a way) and their own worlds and backgrounds and such. The Morthanveld water world, the Nariscene war-rock, Culture ships, the Oct and Aultridia and of course, the Sarl that form the center of the novel - each species with its own language, planet/star/cluster etc.

Complaints:
The only complaint about this book, really, is that like the others, it is slow to ramp up, sometimes drags along, and then speeds up and barrels like a speeding meteor to an end that is almost entirely unpredictable (until you get into the final few chapters). It also leaves a bit of a "whaaa???" feeling when its done. I had to go back and read the last chapter again - it made things better, but a bit more closure would have been better. Perhaps.

Overall:
Recommended.

View all my reviews >>