Older blog entries for avassalotti (starting at number 21)

3 May 2007 (updated 19 Jun 2007 at 21:07 UTC) »

Almost Summer

Bird are singing; the Sun is rising; and rivers are flowing again. In short, another beautiful summer is coming. To me that means the end of classes, and a wave of exams which will crush me for a week. But after, I will be free to do what I love — i.e. coding on open-source software, writing, and enjoying the weather while playing sports with my friends. Anyway, enough dreaming for today, I got some news.

I just finished the facelift to my blog’s layout. The new layout still keeps its original simplicity, while being more colorful and appealing. Personally, I am quite satisfied with the result. And thanks to two Firefox add-ons, called Firebug and Web Developer, the whole process was a breeze (and fun too). While I am at it, I would like to also thanks Becca Wei for the initial theme, Almost Spring, on which I built my theme upon. Feel free to comment about what you like or dislike. Since it’s you after all, who will use it (unless, of course, you’re using a feed reader).

A few longer posts will be coming up after I passed through my exams sessions. Plus, there will a weekly post about the status of my Google Summer of Code project. Thanks for reading!

Syndicated 2007-05-03 22:24:47 (Updated 2007-05-03 22:29:35) from Alexandre Vassalotti

21 Apr 2007 (updated 19 Jun 2007 at 21:07 UTC) »

Smoked brains for dinner

Today, there will be a special quiz on Python hosted by me, in #ubuntu-trivia on FreeNode, at 20:00 UTC. Most of the quiz will be to write some simple procedures, faster than your opponents. The winner will, of course, get a superb prize — 5 Ubuntu stickers! Obviously, the real prize is the fun that will get during the quiz. And who knows, maybe you will learn a few neat tricks. So, see you there!

Syndicated 2007-04-21 16:33:30 (Updated 2007-04-27 03:09:56) from Alexandre Vassalotti

16 Apr 2007 (updated 19 Jun 2007 at 21:07 UTC) »

Boosted Python Startup

Yesterday, I was reading Peter Norvig’s excellent article about spell checking. Then, I started to look to some of his older stuff. So, I found his Python IAQ (Infrequently Answered Questions), and discovered a pretty neat trick:

h = [None]  # history

class Prompt:
    """A prompt a history mechanism.
    From http://www.norvig.com/python-iaq.html
    def __init__(self, prompt='h[%d] >>> '):
        self.prompt = prompt

    def __str__(self):
            if _ not in h: h.append(_)
        except NameError:
        return self.prompt % len(h)

    def __radd__(self, other):
        return str(other) + str(self)

sys.ps1 = Prompt()
sys.ps2 = '     ... '

This improve the interactive prompt of Python with a shell-like history mechanism. With this prompt, you can reuse any previous value returned by Python. For example:

h[1] >>> lambda x: x * 2
<function <lambda> at 0xb7dab41c>
h[2] >>> [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
h[3] >>> map(h[1], h[2])
[2, 4, 6, 8, 10]

You can make it your default prompt, by adding the above in your .pythonrc.py. You will need to specify its location to Python with the environment variable PYTHONSTARTUP. Just add something like the following to your shell configuration (e.g., .bashrc or .zshrc).

export PTHONSTARTUP="$HOME/.pythonrc.py"

I am sure there is a ton of other useful modifications, which can be done with the startup file of Python. If you’re interested, here my brand new startup file. And if you know any other cool tricks for Python, please tell me!

Syndicated 2007-04-16 02:36:05 (Updated 2007-05-07 19:28:34) from Alexandre Vassalotti

Pretty Emacs: Compile guide for unsupported platforms

If you are using a platform other than a i386, you will need to compile my Emacs packages yourself. So, here a simple guide how to do this.

  1. Download the source package with:
    apt-get source emacs-snapshot
  2. Install the build-dependencies and some packaging tools:
    sudo apt-get build-dep emacs-snapshot
    sudo apt-get install devscripts fakeroot
  3. Go in the package’s source directory:
    cd emacs-snapshot*
  4. Build it (take about 30 minutes):
    debuild -rfakeroot
  5. Finally, install the newly built packages:
    cd ..
    sudo dpkg -i emacs-snapshot-common*.deb
    sudo dpkg -i emacs-snapshot-el*.deb
    sudo dpkg -i emacs-snapshot-bin-common*.deb
    sudo dpkg -i emacs-snapshot-gtk*.deb

Syndicated 2007-04-14 02:23:03 from Alexandre Vassalotti

Flipping bits this summer

Dear Applicant, Congratulations! This email is being sent to inform you that your application was accepted to take part in the Summer of Code.

Today, I am truly happy. I wasn’t expecting to be accepted, really, and perhaps no other candidate did. My accepted project is to merge C and Python implementation of the same interfaces (i.e., StringIO/cStringIO, Pickle/cPickle, etc), and my mentor is the Python star, Brett Cannon. This is a challenging project; I will have to work hard and efficiently to be successful. But one thing is sure, I will have some great fun.

I would like to congrats everyone who have been accepted. A special thanks to students who will be working on Ubuntu, this summer. There is surely some great projects for Ubuntu. And also, another special thanks to the mentors, who will be helping us this summer.

Syndicated 2007-04-12 14:36:03 from Alexandre Vassalotti

Welcome to Mr. Crystal Ball

As some of you may already know, I am a die-hard fan of productive editing. That is probably because I don’t find myself very fast, on a keyboard. So, I am always trying to find ways to improve my editing speed. When I ain’t surfing on the web, I am either typing stuff in my shell or my editor. Today, I would like to share a few tricks I uses in my default shell, Zsh.

The shell history can be a powerful tool. If you find yourself typing commands again, and again, and again, you probably can use it at your advantage. You probably already know about Ctrl+R, which is bound to history-incremental-search-backward command in most shells. Personally, I don’t find it very useful since it tries to find a match everywhere, but it’s better than cycling through the history with the Up/Down keys. In fact, anything is better than the Up/Down keys. So, why not rebind them to something more useful, like history-search-backward? Well, that is easy. With Zsh, you need to add these two line to your .zshrc:

  bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward

In fact, if you’re using Emacs key-bindings, you don’t even need to do anything, because Meta+P and Meta+N are already bound to these two functions. Incidentally, Steven Harms is advocating to enable this feature by default in Ubuntu, for Bash’s users. Personally, I am not sure if it’s really necessary to make it a default. I am not a fan of modification in .inputrc, either. But, I will leave that discussion for another blog post.

Now, that we have functional Up/Down arrow keys, can we do more? Yes, we can! Let me introduce one of my favorite features of Zsh, preemptive auto-completion. If you’re tired typing TAB a zillion times a day, you will love this one. This feature implements predictive typing using history search and auto-completion. Again, to enable it, just copy these lines to your configuration file:

  autoload predict-on
zle -N predict-on
zle -N predict-off
bindkey '^Z'   predict-on
bindkey '^X^Z' predict-off
zstyle ':predict' toggle true
zstyle ':predict' verbose true

Here, note that predict-on and predict-off, are bounded to Ctrl+Z and Ctrl+X Z respectively. That means you can turn it on/off, whenever you need to. You will find useful to turn it off when you edit the middle of a command, since it can confuse the prediction. But other than that, it’s great.

Sometime, the shell editor is not enough for me — I need something more powerful when I edit long commands. So, I use another cool built in function of Zsh, called edit-command-line. With this feature, I can edit the current command with an external editor, defined by the environment variable $EDITOR. To enable it, just copy-and-paste this:

  autoload edit-command-line
zle -N edit-command-line
bindkey '^Xe'edit-command-line

So, when I think the command will be long, like a for-loop. I just press Ctrl+X e, which launches, on my system, emacsclient. I am always running Emacs with its server, therefore the shell command is instantaneously loaded into a Emacs buffer. Then when I am done, I close the Emacs session with Ctrl+x # and the command appears in my shell. It is just sweet.

Even if you’re a master with your editor, nothing beats a short alias, or a shell script. I keep a full directory of useful scripts, to automate my daily tasks. At first, writing scripts feels a bit awkward. If you’re like me, you will always worry that your scripts might go terribly wrong, and eat your data. That’s totally normal, but don’t be a fool. Automating your tasks, even the most trivial ones, will saves your precious time. Unlike scripts, which can really do some heavy automation, aliases are just a shell convenience, like auto-completion. Personally, I am not a big fan of fancy aliases. (I tend to use functions for the more fancy things.) Anyway, here some of my favourite aliases:

  # Set up aliases
alias c=clear
alias d='dirs -v'
alias e=$EDITOR
alias grep=egrep
alias h=history
alias j=jobs
alias po=popd
alias pu=pushd
alias ss='screen -Rx'

# Global aliases -- These do not have to be
# at the beginning of the command line.
alias -g M='|more'
alias -g L='|less'
alias -g H='|head'
alias -g T='|tail'

# Go to parent directories without `cd'
setopt autocd
alias ...='../..'
alias ....='../../..'
alias .....='../../../..'

I certainly have a ton of shell tricks, but I will keep them for my other blog posts. So, that’s all folks!

Syndicated 2007-04-07 20:54:45 from Alexandre Vassalotti

Back in Business

A burned video, a zapped hard drive and a corrupt RAM module later , I have now, finally, got my system running again (and no, my computer was not struck by a lightning).

For the fans my Emacs package, I just uploaded a new release, and I will continue to provide weekly releases. Unfortunately, it seems, due to a licensing issue, Romain Francoise orphaned emacs-snapshot and its related packages. Therefore, this means I will have to work harder and fix packaging bugs myself, instead of relying on his bug fixes.

A week before I lost my system, I had promised a special Python quiz, in the issue #31 of Ubuntu Weekly News. I have not forgotten my promise. So if you’re one of the lovers my twisted Ubuntu quizzes, get ready for an awesome quiz. Date and time, when the quiz will be held, will be announced, as usual, in the #ubuntu-trivia channel on FreeNode.

On the final note, I would like to mention that will start posting more frequently on my blog. My current roadmap includes some cool tips-and-tricks, fun script recipes, more stuff about Ubuntu. So, stay tuned!

Syndicated 2007-04-06 21:13:02 from Alexandre Vassalotti

Bad luck

This week I wasn’t really fun. I first lost my video card — I now have a beautiful snow display. Then, I burned a hard drive in an attempt to access some of my data (luckily, it was my younger brother’s Windows installation, not mine). However, it won’t whine about it in a blog post; this isn’t my style.

I just wanted to notice the users of my Emacs package that I won’t be able to update it, until I get my system back on.

Syndicated 2007-03-16 22:41:59 from Alexandre Vassalotti

Tips on Emacs

Here a few Emacs tips and some gospel for those who are still using a butter-knife editor.

First, the most important skill you must develop is touch typing. This is what make the most difference in your productivity. I found out that Emacs is really pleasant when you are able to type, at a rate above 50WPM. One thing is sure, being able to type fast, make any typing task more pleasant. From my own experience, when you get good with the keyboard, you start spending less time reading about other people achievements and start creating your own cool stuff. And learning to type fast is easy. Find some online typing material and spend 15 minutes per day, working on your typing skills. You will never regret it.

Most IDE do a lot of code generation, because some programmers are too lazy to learn touch typing. So, they need snippets, IntelliSense, automated refactoring, etc. They’re all nice features. But, do they really make you more productive? I don’t think point-and-click programming is really productive. That is where Emacs comes in. Emacs, and also Vim, are different in the way they attack the problem of rapid development. They both try to make editing easier, and this is a truly challenging task.

Emacs gives you the power to make your editor. Some people may argues that, this feature made Emacs an operating system. Yet, it is this flexibility that mades Emacs so powerful. Almost all the commands in Emacs are coded with Emacs-Lisp — a full programning language built in Emacs. Even the cursor behaviour is coded in Emacs-Lisp. How many of these point-and-click IDE have you seen, which allowed you to change how you move the cursor? I bet the number is near zero. An example of this power, is a mode called chop. This mode makes your cursor behaves like a binary tree. It allows you to reach any line on your screen in O(log n) steps, where ‘n’ is the screen height. In plain English, this means you can reach any line, on a 130 lines screen, in less than 7 keystrokes. However in reality, the number steps is much smaller, because Emacs has a full set of other tools for moving your cursor, where you want it.

Now the interesting part, how to get good with Emacs. Learning Emacs is the same thing as learning touch typing. You need to practice a lot and frequently. The first thing you need to master is the keyboard shortcuts. There is a lot of shortcuts, in Emacs. There’s probably more than your brain can hold. But with some training, we will see that Emacs’ keyboard shortcuts are easy to remember. They all follow the same structure. Like touch typing, there’s also tools for learning the keyboard shortcuts. I highly recommend keywiz, which run within Emacs. This tool analyzes all the keyboard shortcut in Emacs, even the one you changed, and generate quizzes about them. Again, same idea as touch typing, practice about 15 minutes per day on a daily basis.

As your journey progresses, you will find the need to change some of the default behaviours of Emacs. This is done by putting stuff in your .emacs — the most precious file of any Emacs user. Trust me, you don’t want to lose this file. So, make sure you do regular backups or use a version control system, like Subversion, to protect it. How to use this file is an art itself. Some people like to keep all their configuration in a single file, some don’t; some others don’t care if it’s messy, some don’t; and so on. Personally, I like to separate the different components into smaller files. And, I like to use customize for the on/off type of settings. But, that is just question of personal taste. There isn’t a better .emacs. The best one will always be yours. You will, although, want to see how the others configured their Emacs. That is normal. We are all curious creatures, after all. A final note about .emacs, don’t spend too much time playing on it. Configuring Emacs is fun and addictive, but it won’t help your productivity by much, if you can’t touch type or use the keyboard shortcuts.

The last, but not the least, thing you need to know, is Emacs-Lisp. This is probably… No, this is the greatest feature of Emacs. And, it’s also the hardest to master. Learning a programming language is not the same thing as learning touch typing. Dumb practice won’t help you. You will need to sit down and think. Lisp, and all its parenthesises, freakes most people, who gots some programming experience. Unlike some people says, Lisp is easy to learn. There’s nothing exceptional about learning Lisp. You learn it as any other programming language. Get a book, read it attentively, write some code, repeat. That’s my general algorithm for learning programming languages, and it works. I learned several programming languages, including Lisp, this way. One more thing, knowing Lisp do not make you a superior programmer. What makes you a superior programmer is your ability to learn new ideas. So, don’t get caught by this lie from Lisp evangelists.

Emacs is still a great tool, even if you don’t learn Emacs-Lisp. In fact, many Emacs users never learn it and are still more productive than the majority of the other editors users. You can always copy-and-paste some Emacs-Lisp code found on the web.

However, I haven’t said yet why you should learn Emacs-Lisp. The reason is that if you know it, you can add features to your editor, on-the-fly, without even restarting Emacs. Did ever wished your editor had a particular feature? Well with Emacs, when you know Emacs-Lisp, you just add it. Emacs evolves with you. So, if you do a lot of programming, you will end with a lot of programming helpers and macros. On the other hand, if you write a lot of web articles, you will probably end up with a lot of text manipulation utilities. It is just beautiful, how Emacs can adapt to your editing needs.

Finally, mastering a good editor is a lifetime investment. You better choose one that can evolve with you or you will end up using many different editors poorly. Remember, that being productive isn’t that important, but the fun of mastering something is. You will smile when you will transform a painful editing task into a trivial one. So, enjoy your journey in the world of Emacs.

Syndicated 2007-03-03 20:26:21 from Alexandre Vassalotti

Don’t use fake emails

I just got a comment, on my post Pretty Emacs, which was:

<p>this is the error I get when trying to get your repositories


<p>Please help</p>

Has you probably see, the error message was probably truncated by the HTML filter of Wordpress. Unfortunately, when I tried to send an email to the author of this comment, I received a delivery error which told me that the author’s email address didn’t exist. So, I am stuck with a help request from a ghost.

I really care about the errors you get with the packages in my repository. If you stumble on a bug in one of my packages, it is my fault. And it is my responsibility to fix it. So please, don’t fake your email address when you leave a comment.

Syndicated 2007-03-03 00:15:26 from Alexandre Vassalotti

12 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!