How to connect to Rackspace Cloud Files via ServiceNET

If you are a Rackspace customer and you are are planning to use Rackspace Cloud Files via it’s internal network (ServiceNet) so you don’t get billed for the bandwidth going over Cloud Files this is how you can do. The first thing is to make sure with your support team if your servers are connected to ServiceNet and if you have that connection then there is a small change to do in your code....

October 14, 2009

python syntax warning in emacs

One of the best feature to have with Emacs when doing python development is to have a real time syntax error/warning check highlighted in your code to avoid many errors or superfluous code. This code is taken from the brillant Emacswiki python page. You need to install pyflakes first which should be available on your linux distro by default in a package or for the other OS you may follow the procedure from the pyflakes webpage....

August 31, 2009

Yum Force Exclude List

While talking with my fellow colleague Darren Birkett about what seems a design limitation of yum to not be able to force listing the excludes from yum. I had a shoot to make a yum plugin to force listing the excludes. Here is how it works : root@centos5:~> grep exclude /etc/yum.conf exclude=rpm* root@centos5:~> yum install rpm-devel Loading “installonlyn” plugin Loading “changelog” plugin Loading “chmouel” plugin Loading “priorities” plugin Setting up Install Process...

March 20, 2008

Generating md5 encrypted password for chpasswd

If you want to generate properly encrypted password to feed to chpasswd, the most easier and proper way is to do that from command line : [code lang=“bash”] echo “encryptedpassword”|openssl passwd -1 -stdin [/code] If you want to generate in pure python you can do it like that : [code lang=“python”] def md5crypt(password, salt, magic=’$1$’): import md5 m = md5.new() m.update(password + magic + salt) # /* Then just as many characters of the MD5(pw,salt,pw) */...

August 17, 2007

Cheetah Mode for Emacs

Here is a simple html derived mode for Cheetah templates files. The font-locking regexp can be improved thought but that’s a start. (define-derived-mode cheetah-mode html-mode "Cheetah" (make-face 'cheetah-variable-face) (font-lock-add-keywords nil '( ("\\(#\\(from\\|else\\|include\\|set\\|import\\|for\\|if\\|end\\)+\\)\\>" 1 font-lock-type-face) ("\\(#\\(from\\|for\\|end\\)\\).*\\<\\(for\\|import\\|if\\|in\\)\\>" 3 font-lock-type-face) ("\\(\\$\\(?:\\sw\\|}\\|{\\|\\s_\\)+\\)" 1 font-lock-variable-name-face)) ) (font-lock-mode 1) ) (setq auto-mode-alist (cons '( "\\.tmpl\\'" . cheetah-mode ) auto-mode-alist ))

July 31, 2006

Assignement in Python with list.extend()

This is weird for me : d = ['foo', 'bar', 'ba', 'c'] print d f = d f.extend(d) print d give me the result python “/tmp/a.py” [‘foo’, ‘bar’, ‘ba’, ‘c’] [‘foo’, ‘bar’, ‘ba’, ‘c’, ‘foo’, ‘bar’, ‘ba’, ‘c’] Compilation finished at Mon Jul 31 16:49:4 It seems that extend assign as well the non extended part (d) which is confusing because to merge list i need to use temporary variable.

July 31, 2006

Jabber/Asterisk and Gajim notification

At work we are using Asterisk and Jabber and i am using Gajim as my client. I did a quick patch to have a notification on my desktop when someone call me and i get my big headphones (not that i like the phone very much but well), here is the patch for people who may wants it : http://trac.gajim.org/ticket/1998

May 25, 2006

Python 2.5 Beta

I have been looking at the What’s new __of Python 2.5. There is some cool features inside it : Conditional Expressions: This stuff basically allow to do standard C idiom (that we found in every kind of derivative language) like a = condition ? “true” : “false” the weird part is that Guido Van-Rossum implemented this syntax : x = true_value if condition else false_value which we will have to get use to....

April 9, 2006