Thursday, June 28, 2012

Guess my number the functional way

Guess my number on python the functional way:
import random
def getnum() : return int(raw_input("your guess? "))
def match(guess, secret) : 
    r =  ( guess < secret and 'too low') or ( guess > secret and 'too high') or (guess == secret and 'You win!!')
    print r
    print
    return r

def loop(x,z):
    print "try #",z,
    return ('You win!!' != match(getnum(),x) and loop(x,z+1) ) or (z)

def guessnumber():
    secret = random.choice(range(101))
    times = loop(secret,1)
    print "Total # of try's = ",times
    print (times < 3 and "no way!!") or (times < 4 and "very good") or (times < 6 and 'slo-po') or (times > 5 and 'looser!!')
    return

Wednesday, June 27, 2012

Calculating the scrabble value of a word

def scrabble_value(word):
if len(word)==1:
       return 0
       val=dict(a=1,b=3,c=3,d=2,e=1,f=4,g=2,h=4,i=1,j=8,k=5,l=1,m=3,n=1,o=1,p  =3,q=10,r=1,s=1,t=1,u=1,v=4,w=4,x=8,y=4,z=10) 
return reduce(lambda x,y:x+y,map(lambda x:val[x],word)) 

Skydivers over Google IO

Watching skydivers jumping over SF for google I/O

Cool!

Flying trucks over Texas..

While chatting with a client I happened to mention a tornado that sent trucks flying not to far from where I live.. I had the feeling that he thought I was exaggerating..


Nope, we don't exaggerate here in Texas.. ;)

I loved that plane...


Paragliding over miraflores


Summer Soaring over North Texas


Java is good, just not fun.


Over a few beers, fellow Python developers like to pound on the failures of Java and their use by large corporations..

My personal take on this is that the success of  software development is more a function of the team, than of the language used. It is wrong to blame Java for the failures of poor developer teams.

Java is stable, has plenty of libraries, lots of tools, is friendly to refactoring, testing, and it is not such a bad language. Just take a look at the tools developed in java by good teams (eclipse, apache, joss, spring and so on..)

* It just not as fun as other languages ;)

About working remotely


I work on an home-office space, it is quiet,it holds all my work stuff, it is "the" office. The kids know if I am in there.. I am "at work".
I do plenty of one-to-one over chat/skype/phone with peers,vendors and customers. Nothing different then on a real office.
I regularly do 2/3 hour pair programming sessions with members of my team. We use x11vnc + skype, (we use the pilot-copilot technique ), we get lots done and by the end of a session, our thought-spaces are 100% in sync.
I don't miss the "social interaction" at the office, I got plenty of friends in the "real world" and they don't care to hear from my work (nor would understand it if I told them)
I also get plenty of "geek interaction" with other developers, over beers at the local pub.
The key for remote development is to realize that development is creative work. Hours of work are not important, tasks done are.


* From a post I did at Hacker News

Can you make it fly ?

Conversation between a sales guy and  a technical sales support engineer for an outrageously expensive product ( for whom I used to work on a previous life) :

Sales guy: We are biding for a multi-million $ project and the RFQ requires that our product does X, can our product do X ?
Tech guy: If our software was a car,  what you are asking is: "can our car fly?".
Sales guy <puzzled> : Can't you just make it fly?
Tech guy : it is not made to fly! if you must fly, drive off a cliff  and technically you will "fly" for a bit.

He made the sale, we got stuck supporting the "flying car"


Tuesday, June 26, 2012

Having fun again

I've been a coder for a long time, so long ago I used to store my code on cassette tapes.  it was a *lot* of fun.

Then I grew up, had kids, left my fun but low paying research project at the university and started coding Java for money.

I went deep into the dark side: Oracle stored procedures, waterfall, TPF reports, meeting to schedule meetings.. the whole nine yards!  I did this for 10+ years and it was not fun at all ( it did pay the bills and then some!)

Then one holiday break wanting to learn a bit about Python, I decided to re-write an old anagram puzzle maker I had coded time ago in Java to Python..

Hmm.. no static typing, less verbose, the code just flowed. one day after.. Wow! from 800 lines in Java down to less than 500 python lines on my first draft!  

Next I discovered map, filter, reduce! amazing! the LOC dropped to < 200! and it was still quite readable! Man, this is fun! lets go for some code golf !

By the time the holiday ended, I got down to 87 lines of code.. hard to read code (lots of list comprehensions) but 87 lines non the less!

Now please forget the 87 lines of unreadable code issue, the point of this story is I was having fun again and that day I decided life is too short for a one hour commute to a depressing job.

It has been 4 years since then, I code mostly in Python/Django, I take projects that allow me to work mostly from home, I get to pick up my kids from school, I do challenging stuff and I when I discount day care, gas, lunch outside, and such, I am making almost as much as I did before with a 100% improvement on my family's life.

I am having fun again and I am not having to fight with a cassette recorder to give me my code back!

nmmm brrriiip riiip rip riiiip rip (for the ones of you old enough to know what that noise means)



DNA = Source code = Mind boggling!

Just read DNA seen through the eyes of a coder which compares parallels between DNA and coding.. it is a great read and truly mind boggling!

Your baby is ugly

A customer asked us to use a really ugly color pattern for the site we were developing for them. My graphics artist partner on the project was having a coronary to think we had to implement "that" and resisted to commit such sacrilege.. So I said : "what right do we have to force our ideas on beauty and style onto him?  it is *his* baby, it is his choice,  nobody likes being told their baby is ugly."

My partner did not buy the argument, but implemented the site as requested..

The client is always right

Often clients ask us to do something that we think is *really* bad for the project. What they ask is not really important here, it could be using a particular technology or specific approach to a task that on the long run  will create (IMHO) issues on performance or maintainability of the code or something like that.

As professionals, it is our duty not just to "tell" it is a bad idea, but to educate the client on "why" it is a bad idea. Communicating complex ideas to non technical customers is not easy for us technical people, but like it or not, it is part of the job and helps us get the job done right... and *that* is the reason why clients are willing to paying the big bucks for.

A bit ago I was trying to explain a customer the why's of a bad idea. Still, he insisted on going for it.. Frustrated I said in a very nice tone: "The way I see it, you are asking me to hit your finger with hammer" to what I quickly followed with:  "then again.. it is *your* finger and *your* hammer so say the word and I will go ahead."


First Post

First Post is a common internet cliché where a commenting user on a forum or message board creates the first comment, and includes only the text "first post" or something to that same effect. It is considered bad manners to create such a comment, or post, as it does not add value to the discussion.