lorenzo bolla’s blog

September 13, 2009

the List and the Truth

Filed under: links, programming — lbolla @ 1:38 pm

Spoon Boy: Do not try and bend the list. That’s impossible. Instead . . . only try to realize the truth.
Neo: What truth?
Spoon Boy: There is no list.
Neo: There is no list?
Spoon Boy: Then you’ll see that it is not the list that bends; it is only yourself

from “Practical Common Lisp

August 25, 2009

surf browser hints /2

Filed under: programming — Tags: , , , — lbolla @ 12:45 pm

following yesterday’s post, here is another useful hint about surf’s usage.

the following script lists the available bookmarks (from ~/.bookmarks file) and let’s you pick one using dmenu. if a new link is inserted, it is added to the list of known bookmarks, so you won’t need to type it in full the next time:

#!/bin/sh
bookmarks=~/.bookmarks
link=`cat $bookmarks | dmenu ${1+"$@"}` || exit 0
present=`grep $link $bookmarks`
if [ "$?" -ne "0" ]; then
echo $link >> $bookmarks
fi
surf -u $link

if you don’t want to open a new window, just change the last line to set the _SURF_URL X Property of the surf window you want to use (by clicking on it):

xprop -f _SURF_URL 8t -set _SURF_URL $link

August 24, 2009

surf browser hints

Filed under: programming — Tags: , , , — lbolla @ 6:13 pm

surf is a simple webbrowser based on webkit/gtk+, the same web engine that powers Google Chrome.

used with dwm and dmenu, it’s a very powerfull, yet simple tool.

here is a patch to apply X geometry hints to surf, so that surf windows behave in dwm.


*** surf.c.orig 2009-08-24 16:41:31.000000000 +0100
--- surf.c 2009-08-24 16:35:02.000000000 +0100
***************
*** 372,377 ****
--- 372,381 ----
gtk_container_add(GTK_CONTAINER(c->vbox), c->searchbar);
gtk_container_add(GTK_CONTAINER(c->vbox), c->urlbar);

+ /* Hints */
+ GdkGeometry hints = { 1, 1 };
+ gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, GDK_HINT_MIN_SIZE);
+
/* Setup */
gtk_box_set_child_packing(GTK_BOX(c->vbox), c->urlbar, FALSE, FALSE, 0, GTK_PACK_START);
gtk_box_set_child_packing(GTK_BOX(c->vbox), c->searchbar, FALSE, FALSE, 0, GTK_PACK_START);

another hint is to create a script to feed surf with your favorite bookmarks. here it is:

#!/bin/sh
exe="surf -u `cat ~/.bookmarks | dmenu ${1+"$@"}`" && exec $exe

enjoy!

August 12, 2009

vim and python comments

Filed under: programming — Tags: , , — lbolla @ 5:56 pm

I’m currently undergoing a profound revision (read “cleanup”) of my .vimrc and I recently had to choose a decent plug-in to comment python code.

the best so far is EnhancedCommentify. it’s highly configurable, powerful and it supports a different number of languages (not only python).

the only one thing that wasn’t easy to setup if the behaviour described here: being able to comment a block, respecting the indent, in both visual and normal mode.

a clean solution, without the need to define any function is to stick these lines into your .vimrc:


let g:EnhCommentifyPretty='Yes'
let g:EnhCommentifyRespectIndent='Yes'
let g:EnhCommentifyUserBindings="Yes"
let g:EnhCommentifyUseBlockIndent='Yes'


vmap ,c (Plug)VisualComment
vmap ,d (Plug)VisualDeComment
vmap ,g (Plug)VisualTraditional
vmap ,f (Plug)VisualFirstLine
nmap ,c (Plug)Comment
nmap ,d (Plug)DeComment
nmap ,g (Plug)Traditional
nmap ,f (Plug)FirstLine

(but remember to change “(” to “<” and “)” to “>” — wordpress is strict about “<” and “>”…)

enjoy!

May 1, 2009

escape sequences for rxvt

Filed under: programming — Tags: , , , — lbolla @ 10:07 am

I’m posting this info because I had a hard time searching for it on the internet.

if you are using rxvt (or urxvt), and you want escape sequences to work as in xterm, you need to specify them in your .Xdefaults.

here are the codes I had to add to have vim working properly on rxvt (I use alt-left_arrow and alt-right_arrow to navigate through tabs):

*Rxvt*meta8: false
*Rxvt.keysym.C-Left: +033[1;5D
*Rxvt.keysym.C-Right: +033[1;5C
*Rxvt.keysym.M-Left: +033[1;3D
*Rxvt.keysym.M-Right: +033[1;3C
(substitute “+” with “\”)

enjoy!

April 7, 2009

blog post with charm

Filed under: programming — Tags: , , , — lbolla @ 5:52 pm

this is a test blog entry, posted with charm!

charm is a text-based client which uses the MetaWeblog API to post entries to WordPress powered blogs. it also implements other APIs.

I’m wondering if simple ASCII entries like this one will be properly formatted by the WordPress’ Intelligent Text Formatting feature. it would be nice to use vim to edit it…

enjoy!

January 31, 2009

command line html validator

Filed under: programming — Tags: , , — lbolla @ 11:00 pm

valid HTML is something we should strive to achieve.

W3C Validator is an invaluable tool to do just that.
unfortunately, validating a local file you are working on can be annoying after the 100th time you’ve uploaded it to the W3C website.

Here you can find a command line HTML validator that simply uploads anything passed to it from stdin to the W3C Validator.

The basic syntax is:
$> python validate.py < file_to_validate.html

enjoy!

Note: before using the file, rename it from validatepy.pdf to validate.py. unfortunately, I’m not allowed to post .py files on this website…

October 5, 2008

py2dot

Filed under: programming — Tags: — lbolla @ 2:17 pm
py2dot example

py2dot example

py2dot is a python script to generate graphs from a  python program.

it interprets a python program as a graphs of function calls. it can represent classes and imported modules.

py2dot is available from pypi.

more information are available here.

June 25, 2008

tab completion in python shell

Filed under: programming — Tags: , , — lbolla @ 11:52 am

recently I saw with this little piece of code to give the standard python shell tab completion capabilities:

# setup tab completion in python shell
import rlcompleter
import readline
readline.parse_and_bind("tab: complete")

obviously, you can use the environmental variable PYTHONSTART to execute this few lines anytime you start your python shell.

enjoy!

June 11, 2008

numerical recipies

Filed under: links, programming — Tags: , , , , — lbolla @ 1:48 pm

Numerical Recipies is a classic of Scientific Computing.
download here the whole book in ps or pdf.

a little story.

older versions are freely available here.

if you are lazy, like me, and you get bored of saving every single file by
hand, you can use this fantastic Firefox plugin.
or download them zipped here.

if you are lazy, like me, and you get bored of having to open a new file for
each chapter, you can merge them in one monolithic file.

if you are _really_ lazy, like I wish to be, you can use my job and
download the complete book in ps or pdf straight away.

enjoy!

Older Posts »

Blog at WordPress.com.