2009
12.17

I recently had to setup Fabric (http://docs.fabfile.org/0.9.0/) for doing deployment from my Windows machine at home.
Setting it up under Linux is very very easy but for some reasons there are a number of
issues you have to overcome when installing on Windows. I followed this page to start:

http://docs.fabfile.org/0.9.0/installation.html

First up a standard Python install (I used 2.6.2) and setup tools 0.6c11:

http://pypi.python.org/pypi/setuptools

and create a simple fabric script (fabfile.py)

from fabric.api import local, env, put
env.hosts = ["elephant@babar.net:40"]
env.show = ['debug']
def deploy():
print “Deploying…”;
put(”fabtest.txt”, “/tmp/fabtest.txt”);
print “All Done…”;

From there:

easy_install fabric

will result in:

...
Installed f:\python26\lib\site-packages\fabric-0.9.0-py2.6.egg
Processing dependencies for fabric
Searching for pycrypto>=1.9
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.amk.ca/python/code/crypto
Best match: pycrypto 2.0.1
Downloading http://www.amk.ca/files/python/crypto/pycrypto-2.0.1.tar.gz
Processing pycrypto-2.0.1.tar.gz
Running pycrypto-2.0.1\setup.py -q bdist_egg --dist-dir f:\docume~1\admini~1\loc
als~1\temp\easy_install-clrpu1\pycrypto-2.0.1\egg-dist-tmp-1wszmf
error: Setup script exited with error: Unable to find vcvarsall.bat

You can solve this in a number of ways, the easiest of which is to install the binary for pycrypto manually from here:

http://www.voidspace.org.uk/downloads/pycrypto-2.0.1.win32-py2.6.exe

Next, try running fabric using: fab -f fabfile.py deploy. This results in:

Traceback (most recent call last):
File "F:\Python26\Scripts\fab-script.py", line 8, in
load_entry_point(’fabric==0.9.0′, ‘console_scripts’, ‘fab’)()
File “f:\python26\lib\site-packages\setuptools-0.6c9-py2.6.egg\pkg_resources.p
y”, line 277, in load_entry_point
File “f:\python26\lib\site-packages\setuptools-0.6c9-py2.6.egg\pkg_resources.p
y”, line 2180, in load_entry_point
File “f:\python26\lib\site-packages\setuptools-0.6c9-py2.6.egg\pkg_resources.p
y”, line 1913, in load
File “build\bdist.win32\egg\fabric\main.py”, line 17, in
File “build\bdist.win32\egg\fabric\api.py”, line 9, in
File “build\bdist.win32\egg\fabric\context_managers.py”, line 12, in
File “build\bdist.win32\egg\fabric\state.py”, line 125, in
File “build\bdist.win32\egg\fabric\state.py”, line 74, in _get_system_username

ImportError: No module named win32api

Install the pywin32 extensions from here:

http://sourceforge.net/projects/pywin32/files/

and finally run fabric again (fab -f fabfile.py deploy), the script should run fine this time…

All Done...
Done.
Disconnecting from babar.net:40... done.

2009
07.21

Had a bit of a snag installing MySQLdb tonight, which is required when installing Django.  I ran into the following error when trying to install the MySQLdb egg under Debian Lenny.

EnvironmentError: mysql_config not found
When trying to install MySQL-python

It was fixed by installing the libmysqlclient15-dev package and the installing the egg again:


sudo apt-get install libmysqlclient15-dev
easy_install MySQL_python-1.2.3c1-py2.5-linux-i686.egg

Package details here:

http://packages.debian.org/search?searchon=contents&keywords=mysql_config&mode=path&suite=stable&arch=any

2009
04.07

It is always exciting to have your work noticed, and respected, by other designers…so today Oogly are happy to say we are featured on David Pache’s article “100 Brands of Interest“.

As David comments, “It can be the easiest thing to create a logo for a client but when it comes to assessing what style of identity can best represent yourself or your business, this is a different matter altogether. It is tempting to use your own brand as a showcase of all your best techniques and ideas but this must be balanced with modesty and professionalism to gain the correct tone for your business image.”

Check out the full article (including our logo) here: http://www.dache.ch/dache/comments/100_Brands_of_Interest_II/

2009
03.10

I’ve revamped the pastebin website (http://pbin.oogly.co.uk) - which is based on CakePHP (a model view controller PHP framework) and SyntaxHighlighter (http://alexgorbatchev.com/wiki/SyntaxHighlighter).  I also created an Eclipse plugin to interface with the website.

pbin-sel5

A pastebin allows you to share a patch/code selection/text selection with other people without having to resort to email/instant messenger.  You can either interact with pastebin via the URL or above or install the Eclipse plugin.  If you’ve installed the Eclispe plugin you then right click on the code/text you want to share and select Pastebin->Create Pastebin from the menu.  More instructions and screenshots are available on the website.

The Eclipse architecture is a little strange to start with, the support it provides via the extensions framework is easy enough to understand, although I’m a little confused now that they’ve announced declarative services and their bizarre use of OSGi. The plugin uses the org.eclipse.ui.popupmenus extension.  Dependency wise, I used the Eclipse UI and runtime along with the JFace Textfield components to provide the URL for the created pastebin.  The main plugin itself is made up of an Activator class along with a NewPastebinAction class which implements IObjectActionDelegate which provides a run(IAction action) method.  This obtains the current selection and checks to see whether it is a TextSelection (editor content selection) or a StructuredSelection (a package explorer/navigator file selection).

The selection is then wrapped in a simple domain object and passed to a web client facade that uses the Apache HttpClient (http://hc.apache.org/httpclient-3.x/) framework to provide connectivity with the pastebin website.

Finally, it uses a custom OkInputDialog to present the pastebin URL back to the user.

It’s not perfect at present (I need to unpick the dependency on the JDT plugin for the StructuredSelection), but it serves as a first attempt at creating a Eclipse plugin and understanding the internals of the Eclipse API.  Also, it unfortunately does not autodetect the file type and convert it into the internal pastebin format.

Packaging the plugin was very straightforward.  It involved using the File->Export function provided by Eclipse to package it into an appropriate JAR file.  Alternatively, you can publish an update site, I did this by creating a new feature project (and adding the plugin to it) then exporting the the update site using Eclipse.

I’m going to take the pastebin as a starting point for more collaborative features.

2009
02.18

Generating a contact form for a website can be a rather tedious job. To make things easier there are a number of Wordpress plugins available, one in particular which is rather good is Contact Form 7. This allows you to create a form and generate a number of tags for display on that form, e.g. email address, name, comments…

contactform71

You can then include this on your Wordpress site via a new post or page using the following syntax:

[contact-form 1 "ContactForm"]

It supports CAPTCHA, simple quizzes, various different components for generating surveys, contact forms etc… It also supports localization of messages so that you can customize the error messages and text displayed.

One issue I did find with it however was that I wanted to embed the contact form in a template. At first this doesn’t seem to be possible unless you use another plugin. I used Improved include page which allows you to include a wordpress page in a template. By creating a new page with a contact form embedded it’s very easy to include this page in your template:

And you have a contact form which can be embedded in the footer of your page or wherever you choose to put it.

2009
02.10

I’ve been using a terminal called Terminator for the last few months instead of the terminal that’s bundled with Ubuntu.  The main reason for this was to take advantage of easy split window creation to enable multiple terminals on the same screen.  This is provided along with tabbed windows, but there also a number of other notable features.  I struggled to find a set of shortcut keys for Terminator initially, so there are a few below along with some explanation of the feature:

CTRL+SHIFT+e - Split terminal horizontally
CTRL+SHIFT+o - Split terminal vertically
CTRL+SHIFT+T - Open a new tab
CTRL+Tab - Switch terminals
CTRL+SHIFT+w - Close currently selected terminal window
CTRL+SHIFT+q - Close all terminals
CTRL+SHIFT+z - Maximize currently selected terminal window
CTRL+SHIFT+Left Arrow - Move split (dragbar) to the left
CTRL+SHIFT+Right Arrow - Move split (dragbar) to the right
CTRL+SHIFT+Up Arrow - Move split (dragbar) up
CTRL+SHIFT+Down Arrow - Move split (dragbar) down
CTRL+SHIFT++ - Increase text size in the terminal
CTRL+SHIFT+- - Decrease text size in the terminal
CTRL+SHIFT+0 - Restore text size in the terminal
CTRL+Right Click - moves a window, release the CTRL key to finalise the window position.
F11 - Fullscreen view

You can also get these using to look at all possible options for terminator. Overall it’s a good replacement for the bog standard terminal with some added features.

2009
02.03

Just a quite post on a simple Postfix installation and some steps that tripped me up a little recently.

I installed a basic version of Postfix on Debian and didn’t want to go through the hassles of configuring a MySQL database for managing users etc… I decided to just use the simple aliases file to manage users. To do this I needed to specify the following in my main.cf file:


myhostname = example.co.uk
mydomain = example.co.uk
myorigin = example.co.uk
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, $mydomain, localhost.$mydomain, mail.example.co.uk

and this in my /etc/aliases file:


postmaster: root
root: example@gmail.com
example: example@gmail.com

I also ran into two more issues with the aliases file:

1. Dictionary issue with /etc/aliases
postfix/smtpd[19065]: fatal: open dictionary: expecting “type:name” form instead of…

The issue here was that Postfix couldn’t read the aliases file. It just needed to convert the /etc/aliases file into the /etc/aliases.db file. The question was how, the answer, like this:

sudo newaliases; sudo postfix reload

2. Aliases database out of sync

database /etc/aliases.db is older than source file /etc/aliases
The aliases database was not up to date with the aliases file. To fix this I ran the commands above.

2009
01.24

So this is an initial post from Wordpress using the twitter-tools plugin which allows you to integrate Wordpress and Twitter (and vice versa)…

http://wordpress.org/extend/plugins/twitter-tools/

so this new post should result in a new tweet being created in Twitter : )

2009
01.21

Just a quick write up here on persistent cookies and lynx. I was having an issue where lynx was prompting me to accept cookies from Google, Gmail etc… all of the time. I solved this by enabling persistent cookies for lynx 1.8.5.

To do this, you can put the following in lynx.cfg file which resides in your user home directory:


SET_COOKIES:TRUE
ACCEPT_ALL_COOKIES:TRUE
PERSISTENT_COOKIES:TRUE
COOKIE_FILE:~/.lynx_cookies
COOKIE_SAVE_FILE:~/.lynx_cookies

This will store cookies in the .lynx_cookies file. It will also accept all cookies (you may want to omit this and enable cookies for specific domains which is also possible). For more information on the lynx configuration file and the various options see the link below:

One more note, this doesn’t have to go in the lynx.cfg file, you can also put it in a .lynxrc file, but you then may have to alias lynx to read from that file, possibly in .bashrc or .bash_profile, up to you:


alias lynx="lynx -cfg=$HOME/.lynxrc"

And that’s about it.

2009
01.06

I’ve found a few Eclipse shortcut tutorials around that explain how to access features through shortcuts in Eclipse. One of the most useful I’ve found, and use all the time is the old CTRL+SHIFT+R shortcut for opening a resource.  I’ve noticed that there are a number of these documented within the Eclipse help menu here:

Help Contents > Java Development User Guide > Reference > Menus and Actions

You can also view a list of common shortcut keys using the shortcut:

CTRL+SHIFT+L

From here you can also access the key bindings menu by hitting CTRL+SHIFT+L again (as indicated in the diagram).  This allows you to remap the key bindings or setup new key bindings.  Eclipse also supports Emacs type bindings.

There are also a number of cheat sheets on the internet that you can print out and stick on the wall (or cubicle or whatever) to help you out. I’ve not found an editable template for these so I created my own in Microsoft Word format which can be found below.  This includes a list of the shortcuts I commonly use on a day to day basis.

http://blog.oogly.co.uk/downloads/eclipsesk.doc

The one annoying thing about shortcuts is that you can’t create them for new actions (I found this annoying because I wanted a shortcut for Checkstyle->Check Code With Checkstyle).  However, this functionality is available in the form of Eclipse Monkey (formally Groovy Monkey) which allows you to automate repetitive tasks.

Finally there is another option for memorising shortcuts in the form of Mousefeed - this displays the shortcut for the action you have recently carried out allowing you to memorise it for next time.

Hope that helps with your magical shortcut trickery.