Tabs, Whitespaces, and Highlighting in Emacs – for the Python Programmer

If you’re a python programmer, you probably know all about the troubles mixing tabs and spaces can cause. I have searched far and wide, and have collected some really useful configurations for setting up the perfect Emacs configuration for Python.

What it does:

Insert spaces instead of tabs when indenting

Sets indent to 4 spaces when in python mode & SGML (superset of HTML) mode. This is useful for the web developers out there.

Highlight tabs and trailing whitespace (thanks to http://www.emacswiki.org/emacs/highlight-chars.el)

via Tabs, Whitespaces, and Highlighting in Emacs – for the Python Programmer.

Use browser forward / back keys to switch emacs buffers and frames

Put the below in your ~/.emacs:

;; make thinkpad browser keys navigate buffers
(setq w32-pass-multimedia-buttons-to-system nil)
(global-set-key (kbd "<browser-forward>") 'next-buffer)
(global-set-key (kbd "<browser-back>") 'previous-buffer)
(global-set-key [C-XF86Forward] 'next-multiframe-window)
(global-set-key [C-XF86Back] 'previous-multiframe-window)

On my x220 this allows the browser forward & back keys (above right & left cursor keys) to be used to switch buffer and combined with ctrl to switch frame / window.

Rex – a systems orchestration tool written in Perl

Now, in 2014 Perl is considered rather embarrassing – but it is still widely used. I’ve wandered off the Perl path towards the seductive embrace of Python myself.

However, in some environments you cannot choose your toolset. I’m a big fan of Ansible and it has gone on from strength to strength with VC and a commercial operation behind it, but there are alternatives.

Rex is a similar tool to Ansible, but written in Perl. I’ve used it for a few basic tasks and here are some of its features:

Low Entry Requirements

On the “master” server side you need Perl 5.8.8 or greater (ie – the version that comes with Red Hat / Centos 5) and a small number of additional modules. On the client “target” side all you need is Perl.

For communication from master to target, it just uses ssh, like Ansible. No installing new daemons or opening up new firewall rules.

Works well with existing environments

As well as using existing ssh infrastructure, Rex can use ssh certificates (with or without ssh-agent) or username/password. It can enter your ssh private key passphrase or password for you. It can also use sudo on the remote box and enter the password for that too.

Open Source

On CPAN and Github.

Powerful

As Rex recipes are written in enhanced Perl, you can easily use other features of the language or other modules in your scripting.

Fast

Rex supports running tasks in parallel – you select how many threads you want running simultaneously.

Update: I asked in IRC whether it was possible to split groups for staging pushes – the author of Rex answered.

change email address in mysql

A tiny piece of SQL to update email addresses in a table where the domain is changing:

Very simple, but this has been hanging around in draft for ages and it may help someone.