Archive for December, 2009

Git Command Aliases

Monday, December 28th, 2009

This is kind of a tip of the day, but I just think its cool so I am sharing it with everyone. And being a recent convert to Git and the fact that I have to use Subversion at my place of work, I find myself constantly doing things like this out of habit.

$ git st  && git ci

Well now I can do that (although it may not be a good idea) with git alias:

elubow@beacon (master) supportskydivers$ git config --global status
elubow@beacon (master) supportskydivers$ git config --global commit
elubow@beacon (master) supportskydivers$ git st && git ci
# On branch master
nothing to commit (working directory clean)

Now st and ci are git aliases for status and commit respectively.

What Does Web 2.0 Mean To You?

Wednesday, December 23rd, 2009

I have been doing a lot of reading and a lot of thinking and trying to decide what exactly Web 2.0 means. What massive advancement in an emerging technology called the internet advocates an increment in major version number?

Some people say its the looks. The new feel of the internet with crazy CSS and rounded corners and a lighter more airy feeling. I don’t think that’s it.

Some people say that its the AJAX layer that has been added to the internet. This refers to the layer of interactivity a page web page can give you. I don’t think it’s this either.

Python Multiprocessing Pools and MySQL

Monday, December 21st, 2009

There really isn’t a solid Python module for multiprocessing and MySQL. Now this may be because MySQL on a single server is disk bound and therefore limited in speed or just because no one has written it. So here is a quick and dirty example using the Pool module in multiprocessing in Python 2.6 and MySQLdb.

I also tried using PySQLPool. This was designed for threading and not forking as I am doing with Pool method. Although I am sure it is possible to use PySQLPool with forking by passing the connection (pool) object down to the child process or possibly doing something with IPC, I decided to keep it simple (although slightly more expensive) and instantiate MySQLdb connections upon fork.

Python's MySQLdb 2014 Error – Commands out of sync

Friday, December 18th, 2009

While writing a simple Python script to access and process data in a database, I came across an error that said:

Error 2014: Commands out of sync; you can't run this command now

After quite a bit of Googling and with very little findings, I had to dive in a little and try to figure out what was going on. The whole error looked like this:

Sitemaps On Rails

Thursday, December 17th, 2009

SEO being an interest of mine, I couldn’t quite wrap my head around releasing a webapp without a sitemap. The problem is that there aren’t any really great sitemap plugins for Rails. Now I will grant that creating a sitemap in Rails is a challenging proposition and one that I would not like to undertake on my own unless absolutely necessary. But I was hoping that there would be a rails sitemap “killer app” like there is with almost everything else in Rails.

So I dove in and tried a few options until I found one that worked. First I wrote some code to generate an XML file and then created a sitemap_index.xml.gz file by hand. This was very kludgy and definitely not a permanent solution. I had also read suggestions about doing it in a sitemap_controller.rb file, but that seemed just as kludgy as using a view to generate the XML. It was then time to explore the plugin world.

Custom Google Maps Marker With YM4R_GM

Monday, December 14th, 2009

In one my Rails applications, I allow the user to search for surrounding businesses from their current location. I always showed them a You Are Here marker. The issue I had with this was that the marker was always the icon as the search results. Differentiating these markers is actually extremely easy with ym4r_gm plugin.

First thing is to find a custom icon that you want to use. You can just Google for custom Google maps icons. I chose to use their default icon, just in a different blue. (You can download it here so you are working with what I am working with for this example). The next thing I did was to use the Google custom markers web site to find the proper config options for the icon.

Git Branch Name in Your Bash Prompt

Friday, December 11th, 2009

I work with a few repositories at any given time. And during that time, I typically have multiple branches created for each repository. I figured that it would make my life easier if I knew which branch and/or repository I was working in. Luckily, very little hackery is required here since the git distribution already comes with such a tool. (Note: If you didn’t build Git from source, then you may not have this file.)

AT&T – Reactive vs. Proactive

Thursday, December 10th, 2009

As much as I hate to steal a title or a good joke, I want to title this post iPhone Outage? There’s An App For That. Why? Because it’s funny.

So why am I talking about reactive vs. proactive? In case you haven’t seen it yet, AT&T recently came out with an app called AT&T Mark The Spot. The idea behind the app is that if you have a dropped call or bad reception, that you open the app, click your problem and it will mark the spot by sending the information to AT&T. I am still not entirely sure how this app works in an area where there is NO reception, how does it know where you are to tell AT&T?

Transferring Email From Gmail/Google Apps to Dovecot With Larch

Wednesday, December 9th, 2009

As regular readers of this blog know, I am in the process of trying to back up Google Apps accounts to Dovecot. Well I have finally found my solution. Not only does it work, but its in Ruby.

First thing that you’ll need to do is grab yourself a copy of Larch. I did this simply by typing and it installed everything nicely, but click the link to the repository on Github if it doesn’t work for you.

Country-State Select Using Carmen and jQuery

Monday, December 7th, 2009

I’ve been wanting to find a way to use drop down menus for countries and their states when they exist. But keeping a list on my own would have been a huge pain in the ass. So rather reinvent the wheel, I found the Carmen plugin for Rails. All I have to do is keep the plugin updated and my list of countries and their states will be kept updated as well.

How do I do all this with unobtrusive Javascript and Rails you ask? Good question. Let me show you. Don’t forget to install the plugin (or use the gem).

Let’s start out by adding the drop down menu to our view. In my case I have it in a partial for the address part of a form. You’ll have to modify this slightly to pick up the values of the form if the partial handles edits as well. This one is just for a new method as it uses a default country of US and its states. Note the div ID here of addressStates; we will be using this later in the javascript.

Backing Up Gmail/Google Apps to a Dovecot Server

Thursday, December 3rd, 2009

I have been trying to find a way to copy everything from a Gmail account to a Dovecot mail server. The way I have ended up doing it so far is simply by using Apple Mail (if you regularly read this blog, you’d know that I use a Mac). The steps are as follows:

  1. Create 2 accounts in Apple Mail: Gmail and the Dovecot account
  2. Sync the Gmail account to your local computer
  3. Copy everything to the Dovecot server

This works, but I have to use a slow connection (my home connection) and I have a lot of accounts to do this for, so I would much prefer to script this. The problem is that I have been trying to get this to work with either imapsync or imapcopy. Neither seem to work properly.