Comment Maven System Path – Including local JAR files in a Maven project - 05/4/10

Sometimes it’s a real pain to add JAR’s to Maven, especially when the project doesn’t use Maven as the build system or provide scripts for this purpose. This is even more painful when we have to deal with the dependencies that a particular framework needs.

One solution to avoid this (at least temporarily) is to use Maven’s system scope and systemPath feature:

 XML |  copy |? 
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.3.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/zookeeper-3.3.0.jar</systemPath>
</dependency>

This will reference a dependency from the local filesystem, which means you do not have to install the JAR into the repository in order to use it. This is particularly useful when you’re doing some prototyping or research into a new technology.

By the way Zookeeper does provide support for Maven, see https://issues.apache.org/jira/browse/ZOOKEEPER-224

For more information see: http://maven.apache.org/general.html#tools-jar-dependency

2 Comments Installing And Running Fabric On Windows - 12/17/09

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)

 Python |  copy |? 
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:

 Bash |  copy |? 
easy_install fabric

will result in:

 PowerShell |  copy |? 
...
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:

 PowerShell |  copy |? 
Traceback (most recent call last):
  File "F:\Python26\Scripts\fab-script.py", line 8, in <module>
    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 <module>
  File "build\bdist.win32\egg\fabric\api.py", line 9, in <module>
  File "build\bdist.win32\egg\fabric\context_managers.py", line 12, in <module>
  File "build\bdist.win32\egg\fabric\state.py", line 125, in <module>
  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…

 PowerShell |  copy |? 
All Done...
Done.
Disconnecting from babar.net:40... done.

4 Comments MySQLdb – EnvironmentError: mysql_config not found - 07/21/09

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:

 Bash |  copy |? 
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

Comment Oogly – “A Brand of Interest” - 04/7/09

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/

Comment Pastebin – CakePHP + SyntaxHighlighter + Eclipse Plugin - 03/10/09

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.

Comment WordPress Contact Forms - 02/18/09

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:

 PHP |  copy |? 
[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.

Comment Terminator Terminal - 02/10/09

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:

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

Comment Postfix and Aliases - 02/3/09

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:

 Bash |  copy |? 
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:

 Bash |  copy |? 
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

 Bash |  copy |? 
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:

 Bash |  copy |? 
sudo newaliases; sudo postfix reload 


2. Aliases database out of sync

 Bash |  copy |? 
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.

Comment Twitter Tools – Woo Hoo! - 01/24/09

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 : )

Comment Lynx and Persistent Cookies - 01/21/09

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:

 Bash |  copy |? 
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:

 Bash |  copy |? 
alias lynx="lynx -cfg=$HOME/.lynxrc"

And that’s about it.