FFAP and Ruby in Emacs

If you want to use FFAP (find-file-at-point) in ruby-mode you can add this to your .emacs (defvar ruby-program-name "ruby") (defun ruby-module-path(module) (shell-command-to-string (concat ruby-program-name " -e " "\"ret='()';$LOAD_PATH.each{|p| " "x=p+'/'+ARGV[0].gsub('.rb', '')+'.rb';" "ret=File.expand_path(x)" "if(File.exist?(x))};printf ret\" " module))) (eval-after-load "ffap" '(push '(ruby-mode . ruby-module-path) ffap-alist)) When you do ffap (i bind it to C-x f) near a require ‘PP’ for example it will find it in your ruby path.

May 4, 2008

Ruby XMLRPC over a Self Certified SSL with a warning

If you use the XMLRPC client in ruby over a self certified SSL you have this warning : warning: peer certificate won’t be verified in this SSL session You can get override that warning cleanly (i have seen some people who just comment the message in the standard library) like that : require 'xmlrpc/client' require 'net/https' require 'openssl' require 'pp' module SELF_SSL class Net_HTTP < Net::HTTP def initialize(*args) super @ssl_context = OpenSSL::SSL::SSLContext....

March 21, 2008

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

Emacs config

To anyone interested my extensive Emacs configuration is available here : http://code.google.com/p/chmouel/source And here is the usual screen shot :

September 7, 2007

Netapp sue Sun

This is fun, theses two CEO of theses big companies are dog fighting each others : Dave post: http://blogs.netapp.com/dave/2007/09/netapp-sues-sun.html Johanthan answer: http://blogs.sun.com/jonathan/entry/on_patent_trolling but the real (fake) truth about that post is here : http://fakeschwartz.blogspot.com/2007/09/bring-it-cowboy.html I tend to believe more NetAPP in this case, just because i don’t know how many time i have sweared on that bloody ps -aux that does not work on solaris.

September 7, 2007

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

Automatic best resolution with xrandr

If you like me you have a big screen with your laptop and wants to automate when your X session start to get the best resolution, you can use that script : [code lang=“bash”] #!/bin/bash function get_resolutions() { xrandr|while read -a line;do RES="${line[1]}x${line[3]} " [[ ${RES} != [0-9]* ]] && continue echo ${RES} done } _BEST_RES=0 BEST_RES= for res in $(get_resolutions);do _res=${res/x/} [[ $_res -ge ${_BEST_RES} ]] && { BEST_RES=${res}...

July 31, 2007

Automate SSH known_hosts cleanup

If you like me, you have to do a lot of installs1 of the same test machine with the same IP and have to ssh it you will notice this annoying message : IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is 54:9d:c0:37:3a:80:48:6c:82:ec:d1:84:93:61:24....

May 30, 2007

Linus Torvalds on GIT

Pretty good video to look if you like to know more about git and its creation : http://www.youtube.com/watch?v=4XpnKHJAok8

May 29, 2007

Always search before coding

This is a annoying, even if it take 5mn to code thing like that : (defun my-dired-rm-rf() "Rm -rf directories" (interactive) (let ((sel (selected-window))) (dolist (curFile (dired-get-marked-files)) (if (yes-or-no-p (concat "Do you want to remove \"" (file-name-nondirectory curFile) "\" ? ")) (progn (shell-command (concat "rm -rvf " curFile) "*Removing Directories*") (kill-buffer "*Removing Directories*") (select-window sel) (revert-buffer) ) )) )) you discover after a litlle while that if you have did a lilt bit of searching before, you will have discovered a variable call `dired-recursive-deletes` that would do the thing in a much better way....

February 11, 2007