Aug
31
2008
The Haskell community has built up a great resource: the Hackage Haskell package database, where we recently hit the 500-package mark!
One of those 500 packages was mine, I added another to their number just an hour ago, and I've got two more in the oven. Given, then, that I'm starting to maintain a few packages, I went to the trouble of automating the Hackage release process, and in this post I'm going to briefly walk through setting up this automated environment.
- Install cabal-upload from Hackage. I'm afraid that at the time of writing this is not perfectly simple because it won't build with GHC 6.8 or above: this can be fixed with a new .cabal file, however, which I've made available here. (Edit: I've just noticed that this functionality seems to have been added to Cabal itself! You may just be able to use cabal upload. However, I'm not sure what the right config file location is for the next step).
- Add a file containing your Hackage username and password in the format ("username","password") called ~/.cabal-upload/auth.
- Copy the following shell script into a file called release in the root of your project (the same directory as the Setup.lhs file):
echo "Have you updated the version number? Type 'yes' if you have!"
read version_response
if [ "$version_response" != "yes" ]; then
echo "Go and update the version number"
exit 1
fi
sdist_output=`runghc Setup.lhs sdist`
if [ "$?" != "0" ]; then
echo "Cabal sdist failed, aborting"
exit 1
fi
filename=`echo $sdist_output | sed 's/.*Source tarball created: \([^ ]*\).*/\1/'`
echo "Filename: $filename"
if [ "$filename" = "$sdist_output" ]; then
echo "Could not find filename, aborting"
exit 1
fi
version=`echo $filename | sed 's/^[^0-9]*\([0-9\.]*\).tar.gz$/\1/'`
echo "Version: $version"
if [ "$version" = "$filename" ]; then
echo "Could not find version, aborting"
exit 1
fi
echo "This is your last chance to abort! I'm going to upload in 10 seconds"
sleep 10
git tag "v$version"
if [ "$?" != "0" ]; then
echo "Git tag failed, aborting"
exit 1
fi
cabal-upload -v5 $filename
if [ "$?" != "0" ]; then
echo "Hackage upload failed, aborting"
exit 1
fi
exit 0
- When you're ready to release something, simply run the shell script! Not only will this package up your project and upload it to Hackage, it will also add a version tag to your Git repository (obviously you should change this bit if you are using another VCS!).
If you would like to follow my continuing adventures in Haskell open source, please check out my GitHub profile! Patches gratefully accepted
Comments Off | posted in Haskell, Solutions, Unix
Feb
3
2008
So, I finally switched to Mac a month ago. I've had a Mac laptop since last summer and have been very pleased with the experience, so since Windows Vista has been giving me huge amounts of trouble (e.g. see my last post on getting Cygwin to work, though I won't go into the full gamut of issues I had here) I decided to go for an Apple desktop machine too.
Happily, Steve Jobs has heard my cries of Windows-inflicted pain and ordered his minions to release a new revision of this baby:

Beautiful, isn't it? With 8 cores of Xeon love, it's no slouch in the performance department either. Salivation-inducing hardware aside, it comes with OS X, which is so much better than Vista that its simply not even funny. Overall it's fair to say that I've been very pleased with my purchase
There have been some problems switching, of course. I have Parallels Desktop installed so that I can still develop using C# and I will probably end up installing Office 2007 on there at some point as well, but for pretty much everything else I've been able to find an acceptable or beyond-acceptable alternative for OS X. Here are some of my favourites:
 |
LaunchBar is a very neat application that you can use to quickly access many things on your Mac. For instance, if I want to play the album "Twin Cinema" in iTunes, I just press Option-Space, type "twin" into the box that comes up and press enter: fast and convenient. Similarly, if I wanted to open TextMate I simply press Option-Space and type "mate". Of course, there are loads more things you can do with it such as running any AppleScript you like or make a Google search.. the list goes on. LaunchBar learns over time what abbreviations you want to associate with an action, and hence it becomes so natural that so you soon find it hard to live without it!
Unfortunately it is payware, but it's certainly well worth the price tag.
|
 |
Plot is a really nice graphing application. On Windows I was using Gnuplot, which is doubtless powerful but insanely hard to use. Plot just works and supports pretty much every feature I need. The graphs it outputs look very professional: see for yourself.
|
 |
LyX is what I'm using instead of Office (NeoOffice, the OS X OpenOffice port, is too sluggish for words so I'm trying to avoid it). It's a nice friendly interface onto an OS X LaTeX distribution that makes the common case fast while still letting you access the full power of LaTeX when you need it. The application is actually nominally cross platform but I had numerous problems with crashes and weird behavior in the Windows version that have yet to occur on Mac.
|
 |
I bought 1Password (it actually came as part of the MacHeist deal) to replace my long-time Windows password manager Password Manager XP. I have no complaints: on the contrary, 1Passwords integration with Firefox and the OS is much more reliable and complete than Password Manager XP ever managed.
What's more, they are about to release a service called my1Password that will let me get web-enabled access to my passwords from any location and platform! I'm happy as a clam about this as it's proven impossible to find a decent cross platform desktop password manager application. I should give a shout out to Clipperz here as they have had a decent implementation of this for a while, but the lack of integration with my main password manager (so I have to maintain two lists) and minuscule password limit have put me off using it regularly. UPDATE: Marco Barulli from Clipperz has responded to what I said here: please read this post to get the full story.
|
 |
Time Machine, oh Time Machine, how did I ever get backups done before I had you? The answer is: with great difficulty. On Windows I set up a scheduled task to use SyncBack to clone my hard disk to another server. Unfortunately, this was pretty unreliable (partly because I was backing up onto a Linux file system that had an imperfect emulation of Windows security and didn't seem to support Unicode properly) and also meant that I only had a backup of the most recent version of my filesystem. With Time Machine everything is seamless and I can go back weeks or months in time to see my files at any point, all from within the Finder! Awesome!
|
 |
And finally, maybe you don't find the OS X Terminal very exciting, but for someone who has wasted many hours struggling with Cygwin and its numerous problems (e.g. the awkward attempt to reconcile the Windows and Unix permission models) it is a godsend to finally have a real Unix shell available
|
I haven't even mentioned some perennial favourites like Transmission, Perian or AppFresh, but my time is limited! If you really feel the need to peek into all the applications I have installed, take a peek at my iusethis profile.
Overall my switching experience has been almost entirely painless and has certainly made me more productive and satisfied with my machine. Here's to many more happy years with Apple computers!

3 comments | posted in Apple, Solutions, Unix
Oct
20
2007
I've just managed to fix a particularly annoying issue I was having with Cygwin under Vista with UAC enabled. Essentially, when I ran the Cygwin bash shell as an Administrator I was seeing the following:
- Bash started in /bin/
- The bash shell had no knowledge of Unix paths (i.e. the current working directory was /c/Cygwin/bin)
- The root file system was just my C: drive
- My .bashrc and .bash_profile were not being executed
All of this made it fairly hard to actually do anything. However, I was given a clue when I started up Poderosa (a nice GUI terminal emulator) and tried to open a Cygwin console: there was an error message about not being able to access "HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/". This key contains the mount information for the root directory of the Cygwin instance, so it looked like the root of the problem.
I then opened up Process Monitor to see what happened when, running under the Administrator user, Poderosa tried to access that key. It got "NAME NOT FOUND" as expected. I then tried the same thing as a normal user, and found that the response code as "REPARSE" instead! The log looked like this:

What, do you ask, is all that VirtualStore nonsense after the REPARSE has occurred? Well, that REPARSE is actually redirecting Poderosas read of the LOCAL_MACHINE registry key to some keys in the CURRENT_USER hive: this is a new "feature" of Windows Vista designed to ensure that old applications that assume they can write to LOCAL_MACHINE still work. Any such writes by a process without the appropriate permissions are redirected to the VirtualStore instead, and then read back later transparently by this REPARSE mechanism. However, in their wisdom Microsoft have decided that this redirection is disabled when applications are run as an Administrator from a UAC protected account.
What must have happened is that I accidentally installed or modified Cygwin using the Setup program as a normal user, and it's writes to HKLM were hence redirected to VirtualStore, which is then not consulted when you try and run Cygwin proper as an Administrator. My fix was simply to:
- Export the VirtualStore branch as a ".reg" file from the registry editor
- Open the resulting file in Notepad and replace the text "HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE" with "HKEY_LOCAL_MACHINE"
- Import the modified .reg file using the registry editor again
After that process the user-private data written by Cygwin setup was accessible machine-wide, solving my problem. I hope that this post will be able to help out someone else with similar problems!
Comments Off | posted in Solutions, Unix
Apr
21
2007
Inspired by Yariv's Blog, where he talks about a framework for building web applications in Erlang, and my so far abortive attempts to get into Erlang, I decided to give it another go with Erlyweb. Erlyweb depends on YAWS (Yet Another Web Server), however, and this proved to be a bit of a pain to install since I'm being difficult and using Windows on my development machine. So, in order to help any other lost souls who try to duplicate this feat in the future, I'm recording the process (tested against YAWS 1.68):
- Install Erlang (obviously), and make sure it is in your PATH
- Install Cygwin with the Perl and GNU Make packages at minimum
- Unpack the latest YAWS release into your home directory
- Now, the first trickiness: there is a small error in the YAWS makefile, so open up the yaws-X.XX\src\Makefile and for the mime_types.erl target change the first command to be not $(ERL) but "$(ERL)". The quotes mean that for those of us with Erlang installed in a path with spaces in the name (such as Windows users who put it in Program Files) the erl executable will actually be found. If you don't follow this step you'll end up with some error like:
/cygdrive/c/Program Files/Erlang/5.5.4/bin/erl -noshell -pa ../ebin -s mime_type_c compile
make[1]: /cygdrive/c/Program: Command not found
- Follow the same process to add quotes around $(ERLC) in www\shopingcart\Makefile and www\code\Makefile (somewhat weirdly, every other uses of $(ERL) and $(ERLC) have been quoted for us, suggesting this is just something they overlooked, rather than that running on Windows is a blasphemy)
- Whack open a Bash Cygwin shell and cd into the yaws-X.XX directory
- Do the usual "./configure; make" dance
- Open up the newly created yaws file in the bin subdirectory and change the last line so that $erl is in quotes, i.e. from this:
${RUN_ERL} "exec $erl $XEC"
To this:
${RUN_ERL} 'exec "$erl" $XEC'
- From this point on I'm going to assume you need to do a local install: if you want to do your own thing, you can follow the instructions here, but you may need to adapt them based on what I'm going to talk about below. Anyway, run "make local_install" do to the install if you are following along at home
- Now, this is where it can get a bit confusing: although we just built YAWS under Cygwin, since we have a Windows binary of Erlang the paths in yaws.conf (which should have appeared in your home directory) must be Windows paths, but the makefile used Unix ones. Go in and fix all of those (for me, this meant putting "C:/Cygwin" in front of all of them)
- Point your web browser at localhost HTTPS on port 4443 to see what you have wrought
- Sit back and take a deep breath to cleanse your soul of the accumulated Unix gunk

3 comments | posted in Erlang, Solutions, Unix, YAWS