Entries Tagged 'programming' ↓
August 16th, 2009 — programming
I don’t know what it is. Maybe it’s inherent to human nature to strive for and to create order. Maybe it’s just me.
But I love staring at branches and I love cleaning up my commit history until it shines. This is of course possible and encouraged with git and it’s only possible if you haven’t shared your code with anyone else publicly (pushed to a shared remote repository). So how does a shuffling cleaning frenzy look like? Here: (The screen-shot below is from GitX just for eye candy).

How do I work? Before I share my work with other developers I commit stuff to local branches furiously and in very small increments, I branch away like crazy. Then after a while I realize things are messy and commits are not elegantly divided per feature. So I stop coding and start cleaning the history of commits until they fit into a clean list of recognizable units of work. At that point I can merge the work back into the mainline, say the master branch or some shared topic branch.
Tools of the trade ? git branch, git reset, git cherry-pick and the very powerful git commit –interactive.
If you’re wondering why I like git and why I don’t use x (where x could be svn, hg, bzr or perforce) a good collection of reasons can be found at Why Git is Better Than X .
July 2nd, 2009 — programming, python
Lately I’ve been really impressed and experimented joyfully with
Compass and Sass. They make css/layout design fun again for me. Even if the whole tool chain is in Ruby you don’t have to touch any Ruby to use them – don’t misunderstand me: I like Ruby and I’ve been a Rails early adopter; my brain is very well tuned in with Python, that’s all -.
Compass makes the creation of a semantic layout using any of the
popular css frameworks (blueprint, 960, etc.) a breeze.
There’s ton of documentation around, for example this is what got me into it a while ago.
So today after a furious coding spree I achieved what I wanted. I integrated Compass into a default Pinax project.
To prove that I could quickly change the layout in an elegant way I tried to alter the default theme to have the menus vertically aligned instead than horizontally.
I know people love pretty pictures and screenshots so here is a taste of the end result:

And another one:

And if you find any of this interesting be my guest and peruse the newly created github project:
- The master just plugs in Compass without changing anything in the default theme. You can alter the layout by working in the media/sass folder and running compass -u in the media folder.
- The vertical branch includes the changes needed to come up with the vertical menu you see above. By looking into the media/sass/base.sass file you should see how to use Compass directives to include a 960 grid into Pinax.
Please note, this is nothing fancy nor hard, but I expect this integration to be a life/time saver in all my next projects.
July 1st, 2009 — editors, linux, programming
Here is what a coding session of mine looks like when I am in full swing. This is specifically the coding screen. That’s a 1920×1600 resolution screen-shot
. I obviously also have a browsing screen not shown.

In the image above I am immersed into integrating Compass into Pinax (full post on that will follow).
When developing under Linux (Ubuntu 9.04 at the moment) I have settled for a long time now on the ultra-productive tiling window manager Xmonad. Nothing I tried beats it. My fingers and my brain now are one with the keyboard short-cuts and the concept of mouse-less zen.
Yes I use vim extensively and yes I use screen with the new ubuntu screen-profiles. It rocks.
November 26th, 2008 — editors, programming, tip
Am I the only one to notice that there is a lot of vim love in the airwaves recently?
I saw the trend very clearly, spanning from reddit to news.yc and let me say that the material that came up recently is very good; those neat posts prompted me to improve my vimrc dramatically and I really like what I learned.
In this installment, instead than annotating my vimrc (another one? not that interesting, I’ll refrain) , I want to compile a roundup of the best vim articles I saw recently.
I’ll also add a few classics that changed me from a hater to a vim lover and will conclude with some minor tips out of my bag.
So here we go with the roundup.
Recent Vim Articles Roundup
Jamis Buck
Vim Follow Up
Coming Home To Vim
Jamis Buck switches back to vim from a period using TextMate and talks about his experience and his configuration. Many useful tips in there.
Stephen Bach
Configuring Vim Right
Sensible defaults for your vimrc, recommended.
Learnr dev blog
Configuring Vim Some More
Some additional configuration options that totally make sense and I incorporated in my config too.
Swaroop C H
A byte of vim
A new free e-book on vim, worth reading. Covers also advanced topics like writing your own plug-ins.
Effective Vim
This ends the recent vim trend spotting. But there are some older links that are worth sharing in my opinion.
Older Vim Gems
Jonathan McPherson
Efficient Editing With Vim
This is a true gem, an intermediate level tutorial that will convert you from a beginner vim user to a way more proficient one.
Jerry Wang
vi for smarties
Very good beginners guide to vim.
David Rayner
best of vim tips
Raw tips from a very long time vi/vim user
Vim is also great for Python development, 3 ideas…
vim omnicomplete awesomeness
How to make vim a modular Python IDE
How to replicate SLIME in vim
Finally a few tips from myself
vimperator: If you’re a heavy vim user you might want to checkout the great Firefox extension vimperator. You’ll find yourself browsing mouse-less with familiar vim keystrokes in a matter of minutes. I love it.
viPlugin for Eclipse: If you’re a Java developer (been there, done that) and you’re stuck with Eclipse, you definitely want to have viPlugin. It makes the Eclipse experience something much more pleasurable for one who has vi keystrokes embedded in the fingers.
cool color scheme: If you’ve seen “some” screen-casts and you have just a subterranean TextMate envy and you can’t stop thinking at that cool color-scheme, well think no more, you can use this one or my humbly tweaked version.
For delicious users here is the page of my bookmarks that made me notice the trend.
Ending note
For full disclosure I have to say that I have been – and still am sometimes – an Emacs user. One of the rebel ones daring enough to use Viper mode. So now you know.
November 21st, 2008 — linux, programming
This is the scenario I was thinking about: I want to interact with a graphic designer remotely, who is very very good with Photoshop and HTML/CSS but who might have trouble setting up the Linux environment needed to run my web app.
What I would like to build (or find if it already exists) is a custom CD that when inserted into a Windows or Mac OSX box does the following:
- Start a virtualbox/vmware instance with my Linux distribution of choice.
- Inside the virtual machine the web app is started automatically in debug mode.
- Proper networking is in place so that the web app is accessible to the host operating system on a specified port.
- The template/media folder of my web app is shared via SMB with the host OS.
This way the graphic designer could work on the templates/design of the application having (almost) zero knowledge of the technology behind and no access to the code.
I have already developed a solution like this for myself using colinux. But the process required quite some fiddling and was all but automatic.
Automated is the keyword.
That’s it.
November 19th, 2008 — programming, startup
One of the first things I implemented for tuttivisti – to add just a hint of viral marketing to the project – was a widget that you can import on your own blog, maybe on the sidebar, to show the latest movies you either want to see or just watched. Let me test it here for you (and for me
):
How does it work? Just go to the goodies page (well login first) select how many columns and how many movies you want to show, click preview, copy the short Javascript snippet into your blog, website, myspace,etc. and you’re done.
I don’t think anybody is using this yet, but it’s understandable, tuttivisti has only a little above 100 users at the moment, most of whom never came back.
We’ll see if adding the next level of viral-ity will improve things: think posting your movies to twitter, pwnce, plurk, friendfeed, facebook, etc…
. I’ll try. I think I’ll start from twitter this week. Pinax supports it out of the box (together with openmicroblogging which is way cool).
November 18th, 2008 — programming, python, tip
In the first installment of this series I’ve spoken about a set of technologies that can speed up the time to market quite a bit. Read about it here if you missed it.
This time I want to talk about where to get the content for your niche web app – if you need a source of content, that is.
Leverage the Semantic Web
I apologize if you all know it and I am late to the news. But really, the semantic web is alive and here and I think one of its most promising incarnations is Freebase.
What is Freebase?
Take the whole of Wikipedia, in it’s unstructured – well I should say semi-structured – mass of data, structure it properly creating schemas on schemas of semantic relations amongst articles, and expose a clean API on top of it. Keep the openness part, allow anyone to create new domains (called bases) and to contribute structured content by hand or programmatically. That is freebase as I understand it. Beautiful.
How did I use it
So the secret is out, that’s exactly what I used to present cool thumbnails and basic movie data for my tiny tuttivisti – now at the second week of life (check it out by the way, the new release is out).
Let me go into deeper depth here because I realize the audience requires it.
The Freebase folks have extensive documentation on how to interact with their service. In addition to that they publish two very nice Python libraries, freebase-suggest and freebase-python. The first to add a cool, jquery based autocompletion dropdown to your forms, the second to query Freebase programmatically from a Python program.
freebase-suggest example
Using the freebase-suggest library is very easy. To achieve this:

I just had to add this jquery snippet to the bottom of the page:
<script type="text/javascript">
var options = {
soft: false,
ac_param: {
type: '/film/film',
category: 'instance',
disamb: '1',
limit: '10'
}
};
$('#searchbox')
.freebaseSuggest(options)
.bind('fb-select', function(e, data) {
$('#searchbox').val(data.name);
$('#freebase_id').val(data.id);
$('#freebase_image_id').val(data.image.id);
$('#search_movie_form').submit();
return false;
});
</script>
And mark the text input of the search with id=”searchbox”.
The freebase-python library is also very easy to use and I encourage you to take a look at the documentation, here.
So in conclusion, before your app gains traction and your content is produced by your users, leverage the Semantic Web if you can, use freebase!
November 9th, 2008 — programming, tip
Quick one liner to list the ubuntu packages you recently installed on a machine. I needed this to copy the configuration of one of my production boxes onto a dev environment:
sudo cat /var/log/dpkg.log | grep \ installed | awk {'print $5'} | xargs
mysql-client-5.0 mysql-server-5.0 ... apache2
November 9th, 2008 — programming, python, startup, ycombinator
First things first. My new webapp tuttivisti is live!
This post is about how it came to be. In just one week. One person team. Crazy working hours.
So I was there immediately after receiving the news that YC did not select my team for this round. I thought I would feel depressed. I thought that the put down would ruin my mood.
Well it didn’t! I actually felt a jolt of energy. For some reason I felt a bit as if I had been freed. Can’t really explain why but my motivation and excitement bounced back up.
So what did I do with all this creative energy? Well my partner for diffract.me (the other project I am preparing to launch) had to go for a few days back home and we hadn’t planned our next iteration yet. So I decided to dive into something new, short and sweet.
Yep, I started coding. Again. From scratch.
I sat on the shoulders of giants. For this 1 week challenge I picked some of the most productive tools I know (and these will be topic for a future post):
I’d love to communicate properly the productivity boost that the set of frameworks above can give a developer.
No more spending endless hours trying to create a decent CSS/HTML layout. Bluetrip (and by saying Bluetrip I mean also the great Blueprint and Tripoli from which Bluetrip has been created) makes it trivial to put the stuff exactly where you want it on the screen. Cross-browser. No hassle.
Pinax. Ah, the joy. No more coding for the nth time a registration module. No messing with authentication emails. No rewriting another openid library. No more. It’s all there. Ready to use. Greatly structured. Amazing stuff. This is a game changer in my opinion.
Jquery. Well it needs no introduction. Jquery is a work of genius. For me it changed coding in Javascript from a painful experience into a pleasurable one. I love Javascript again.
Now will tuttivisti fly? I sure hope so, but the truth is that it does not matter. What I am saying to myself is: If I can build something like this in 1 week the question is not “will I ever manage to build a webapp that gains some traction?” but “How many attempts will it take? Is 5 going to be enough? 10?”. Maybe.
I have a lot more to say but will cut it short. I am at the end of a very very long and demanding coding spree.
Update: The past weekend a new version of tuttivisti has gone live, my 2nd week of work on the project, which incorporated much of the feedback I received, but a lot of work is still needed. So feedback is welcome, and – yes I know – I need a graphic designer.
October 1st, 2008 — apple, programming, tip
Beautiful tip to search and replace all occurrences of a string in a given folder.
I had to change it slightly to make it work under OSX so here it is for future reference:
find . -type f -exec sed -i -e ’s/Old/New/g’ {} \;