Latest Publications

Accessing to Rackspace Cloud Files via servicenet (update)

Last week I have posted an article explaining how to connect to Rackspace Cloud Files via Rackspace ServiceNET but I actually got it wrong as pointed by my great colleague exlt so I had to take it down until figured out how to fix it.

I have add that feature properly to the PHP and Python API in version 1.5.0 to add a ’servicenet’ argument to the connection and updated the blog post here :

http://blog.chmouel.com/2009/10/14/how-to-connect-to-rackspace-cloud-files-via-servicenet/

It should give you all the information for the howto use that feature.

I have released as well a minor update in 1.5.1 to allow you to define the environment variable RACKSPACE_SERVICENET to force the use of the Rackspace ServiceNET this allow you to don’t have to modify the tools and have a clean code between prod and testing.

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.

The second thing is to use the just released 1.5.0 version on GitHUB for PHP :

http://github.com/rackspace/php-cloudfiles/tree/1.5.0

and for python :

http://github.com/rackspace/python-cloudfiles/tree/1.5.0

(you need to click on the download link at the top to download the tarball of the release).

Afer this is just a matter to set the argument servicenet=True, for example in PHP :

$user='username';
$api_key='theapi_key';
 
$auth = new CF_Authentication($user, $api_key);
$auth->authenticate();
$conn = new CF_Connection($auth, $servicenet=true);

In Python you can do like this :

username='username'
api_key='api_key'
 
cnx = cloudfiles.get_connection(username, api_key, servicenet=True)

Rackspace Cloud Files helper scripts

Since working a lot with Rackspace Cloud Files I have put some quick
scripts using the python-cloudfiles API to do some ls rm and cp of containers or objects..

It’s really a collection of quickly written stuff put in the same file
but at least if not useful for you it would give you an idea how the
python-cloudfiles works. It is all available here :

http://github.com/chmouel/cloud-files-helper

Emacs transparency with mouse wheel

Emacs is playing fancy on the latest version (since emacs 23) it has now support for transparency at least on Linux when you have a composited Windows Manager.

As explained on the Emacs wiki here everything is controlled by this frame parameter like this :

 (set-frame-parameter (selected-frame) 'alpha '(85 50))

I have automated the thing to allow the transparency to increase or decrease when combined with the alt key just put this code somewhere in your $HOME/.emacs or $HOME/.emacs.d/init.el :

(defun my-increase-opacity()
  (interactive)
  (let ((increase (+ 10 (car (frame-parameter nil 'alpha)))))
    (if (> increase 99)(setq increase 99))
    (set-frame-parameter (selected-frame) 'alpha (values increase 75)))
)
 
(defun my-decrease-opacity()
  (interactive)
  (let ((decrease (- (car (frame-parameter nil 'alpha)) 10)))
    (if (< decrease 20)(setq decrease 20))
    (set-frame-parameter (selected-frame) 'alpha (values decrease 75)))
)
 
(global-set-key (kbd "M-<mouse-4>") 'my-increase-opacity)
(global-set-key (kbd "M-<mouse -5>") 'my-decrease-opacity)
</mouse>

rsync like backup to Rackspace Cloud File with duplicity

It seems that there is no much documentation about how to do rsync like backup with duplicty so here it is :

#!/bin/bash
UPLOAD_TO_CONTAINER="backup" #adjust it as you like
export CLOUDFILES_USERNAME=Your Username
export CLOUDFILES_APIKEY=API_KEY_YOU_GOT
export PASSPHRASE=The Passphrase for your encrypted backup
 
duplicity /full/path cf+http://${UPLOAD_TO_CONTAINER}

This should take care to upload the backup files to the backup container. It does that incrementally and detect the changes to your file system to upload. There is much more option for duplicity look at the manpage for more info.

Upload to Rackspace Cloud files from GNOME nautilus

After seeing this script http://overhrd.com/?p=106 which allow to upload files with the file manager (finder) of MacosX to Rackspace Cloud Files, I have made a nautilus script that doe the same for us Gnome/Unix users.

Available here :

http://github.com/chmouel/nautilus-rackspace-cloud-file/tree/master

Screensho uploading to Rackspace Cloud File form Nautilus

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.

and add this configuration to your .emacs :

(when (load "flymake" t)
(defun flymake-pyflakes-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
             '("\\.py\\'" flymake-pyflakes-init)))

make sure pyflakes is in your path and enable flymake-mode by default if you like for all python mode :


(add-hook 'python-mode-hook 'my-python-mode-hook)

go by M-x customize flymake as well if you like to customise some variables.

emacs daemon and Xdefaults

It does not seems that emacs started with –daemon read the .Xdefauls resource it seems that the only way setting it is by the default-frame-alist variable.

I have my setup like this :

(setq default-frame-alist '((font-backend . "xft")
                            (font . "Inconsolata-14")
                            (vertical-scroll-bars)
                            (left-fringe . -1)
                            (right-fringe . -1)
                            (fullscreen . fullboth)
                            (menu-bar-lines . 0)
                            (tool-bar-lines . 0)
                            ))

PS: inconsolata font can be installed from the package ttf-inconsolata

Network manager and iwl3945 not showing network

So if you have network-manager not detecting wireless networks it is probably because lately the driver need to be set as up to get the thing going.

On my Debian I have added this to make it works :

echo "/sbin/ip link set wlan0 up"|sudo tee /etc/default/NetworkManager

Better output from sqlite3 command line

That weird output from sqlite3 command line is annoying you as well ? Just set this up to get something better :

cat < <EOF>~/.sqliterc
.mode "column"
.headers on
.explain on
EOF