barf and slurp with paredit

Posted by Aaron Feng Mon, 24 Mar 2008 00:58:00 GMT

If you are not barfing and slurping with paredit while you are editing your Lisp code in Emacs, you are missing out. You need to read on.

One of the biggest complaints for beginner Lispers (like myself) is the overwhelming parentheses. After working with Lisp code for a couple of weeks, the parens do disappear. However, you still have to match up the parens even if you don't see them any more. This is where paredit comes in. Paredit will manage all the parens for you, so you never have deal with dangling parens again. It feels annoying at first because it will not allow you to delete a closing paren without removing the opening one. Just like anything else, if you can get over that, it can be quiet useful.

Two of my favorite features are barf and slurp. They are best explained with examples.

; starting with the following sexp

(x (y) (z))

; barf forward...

(x (y)) (z)

; barf forward...

(x) (y) (z)

; slurp forward...

(x (y)) (z)

; slurp forward...

(x (y) (z))

; barf backward...

x ((y) (z))

; barf backward...

x (y) ((z))

; slurp backward...

x ((y) (z))

; slurp backward...

(x (y) (z))

You get the point. There are many more features to paredit besides barf and slurp. If you are interested in learning barfing, slurping and other delicious paredit features, check out this link.

Slime video and transcript 2

Posted by Aaron Feng Thu, 14 Feb 2008 05:30:00 GMT

Learning Lisp has been a challenge so far. I'm plunging my way through Practical Common Lisp at a decent pace though. Learning Lisp development environment is another story. Since all the hardcore Lisp hackers are all using emacs with slime I figured I would do the same. I have no previous experience with emacs, so I'm simultaneously learning 3 things at once.

One night I came across Maco Baringer's slime video. After I watched the video, all the dots in my head started to connect. In the video, Maco demonstrated the usage of slime while he developed a morse code application. I kept rewinding to figure out the key strokes used. Recently Peter Christensen wrote a transcript for the slime video. This made the video much easier to follow. Christensen also has a transcript for Baringer's Hello World video using Uncommon Web framework.

Besides the transcripts, Christensen is also working on emacs/slime cheat sheet. As a noob learning Lisp, I need all the help I can get.

Bring in the new year with Gutsy Gibbon, Parallels, Ruby, and Rails

Posted by Aaron Feng Wed, 02 Jan 2008 04:35:00 GMT

A few days ago I came up with an idea for a side ruby (possibly using rails too) project. After doing the initial research, I realized it makes more sense to test out the idea on Linux instead of OS X. I don't want to change the setup of my MacBook since I'm just toying with the idea, so I decided to install Linux using Parallels. Parallels is a virtual machine for Mac that is capable of running any operating system.

There has been a lot of hype around Ubuntu, so I decided to give it a try. The latest version at the time of this writing is 7.10 (codename Gutsy Gibbons). Installing Ubuntu on my MacBook via Parallels was a much more difficult task than I expected. Shortly after I started the installation, I was faced with the following error:

The display server has been shut down about 6 times in the last 90 seconds

After some googling, I found the fix on Shane Duffy's blog - Ubuntu 7.10 Install guide - Parallels Macbook pro. The installation worked as expected. However, Unbuntu wasn't able to connect to the internet during the installation, so the software package management system (apt-get) configuration file was commented out. apt-get is similar to MacPorts on Mac. I uncommented all the locations in the /etc/apt/source.list. I ran the following command to get the system up to date:

apt-get update
apt-get dist-update

The apt-get is pretty slick. Learning more about it will definitely pay off in the future. A good place to start is the AptGetHowto.

Moving on to the ruby and rails installation. apt-get wants to manage all the packages it installs, so installing gem using apt-get won't be feasible. Walter Wilfinger has posted complete instructions on how to get ruby and rails running in his post Installing Ruby and Ruby on Rails in Ubuntu 7.10 Gutsy Gibbon.

Last but not least, I found it annoying that I can't use the apple key as control key in Ubuntu. Once again I found a post written by Stuart Colville on how to remap the apple keys.

Wait, the system is not complete if you can't watch videos on youtube. When I tried to open a video on youtube firefox prompted me to install the missing flash plugin. Don't install it, it won't work. Download the Linux flash player from Adobe from here. Open a terminal window and run the following commands:

# exist firefox before running these commands
tar xvfz install_flash_player_9_linux.tar.gz
cd install_flash_player_9_linux
./flashplayer-installer
# at this point, the installer should ask you where the firefox
# directory is, it should be in /usr/lib/firefox

Overall, the installation went well, but was time consuming. There were some pitfalls, but they were easy to overcome. Ubuntu runs well on my MacBook with Parallels (I'm actually blogging from it). I'm sure it would run even better on a MacBook Pro. I really enjoy having a complete separate environment for development. I have complete freedom of experimenting with different things without worrying about messing up my system. If you ever wanted to play around with Ubuntu on a Mac, Parallels is definitely the way to go. If this works out well, I might just keep all my development stuff on a separate Parallels image.

Weird characters by Visual Studio 2008 2

Posted by Aaron Feng Fri, 21 Dec 2007 02:57:00 GMT

This week we upgraded to VS 2008 RTM at work. Our solution contains database scripts for both SQL Server and Oracle. I noticed when I ran the script on an Oracle database via sqlplus an error appeared on the first line of the script. After a closer examination with a Hex editor, VS 2008 apparently inserts 3 non-printable characters in the beginning of a new file. Check out the image below:

vs2008

I'm not sure why, or what those characters mean, but they seem to be ignored by most Windows programs except for sqlplus.

Subversion is the most pointless project 4

Posted by Aaron Feng Fri, 26 Oct 2007 04:04:00 GMT

The title is a direct quote from Linus Torvald's talk at Google. Torvald is the creator of the Linux kernel and Git. Git is a distributed source control system that is super high performance and reliable.

Like many developers, Torvald was tired of the complexity of CVS (branching), and how it is often cumbersome (merging) to use. Since the CVS repository is centralized, it requires a network connection for operations like commit which made it not truly offline. The fact that all the source code lives in one central location also made Torvald uneasy. The reason he said Subversion is the most pointless project is because Subversion is basically "CVS done right". Torvald didn't feel Subversion added any value since CVS was never done right to begin with. That's why he took two weeks off from Linux kernel project to write Git.

I had never used Git until I started to play with Rubinius. Git has been around for a couple of years now, and the most known usuage is with the Linux kernel project. Git is not like anything else I have seen before. It is partially inspired by BitKeeper[bit]. It's very different and radical compared to the typical source control system. After understanding why it is designed that way, it actually makes a lot of sense.

Git has no central repository. In fact, everyone has their own copy of the repository. Since there is no central repository, all operations are local, even commits. Local repository also removes any need for permission. The next logical question is how to propagate out the changes? It's easy, when someone is ready, he/she will contact you and say "Hey, I just finished feature X, please pull from me." If you trust this person, you'll "pull" directly from his/her repository. If you are having trouble merging the changes when you are pulling, you can ask the other person to pull from you instead. Once the changes have been merged you can pull again from that person. This is how thousands of people can work together in the same code base concurrently without interfering with each other. Lots of people can do the work, but you will only "pull" from people you trust. Distributed repository also makes backing up unnecessary.

There is a lot more to Git, but this is the 2 second overview of it. For more information on Git, here is a great Git tutorial.

CodeRush is a fat pig 5

Posted by Aaron Feng Wed, 19 Sep 2007 01:28:00 GMT

A few months ago we purchased CodeRush with Refactor Pro from DevExpress in search of higher productivity.

At first glance, it's apparent that CodeRush is extremely flashy. There are huge arrows flying across the screen with every other key stroke. It gets old and tiring real fast. However, the flying arrows can make any demo look impressive, that's about all. All the "intelligent" suggestions CodeRush insists on trying, can drive anyone to the edge of insanity. CodeRush is highly configurable, so everything that is a nuisance can be turned off. That is the very first thing we did.

Despite all the graphical rendering being turned off, it still eats memory for breakfast. It has become so bad, that our machine will just stop responding for 10 to 30 second durations while editing. Eventually we uninstalled it on all of our machines. At any given time, Visual Studio can occupy 600 - 800 MB of memory with CodeRush installed. After uninstalling, Visual Studio consumes around 200 - 300 MB.

We have 36 projects, and around 250k-ish line of code in our solution. We are running 3.2Ghz P4 with 2GB of ram on all of our boxes. After we unintalled CodeRush, our machine started to feel more responsive again. We finally can get work done!

CodeRush does have some pretty cool features, but our sanity and efficiency of our machines out weighs it.

DiffMerge 3.0

Posted by Aaron Feng Fri, 08 Jun 2007 02:40:52 GMT

For anyone that is tired of not being able to do a 3 way merge or directory comparsion with your diff tool- Sourcegear is offering a cross platform diff tool to do just that. Best of all, it's FREE. DiffMerge 3.0 can be downloaded from here.