Category: Programming

When To Use MySQL Cursor Classes In Python

I have been writing a lot of code that has been interacting with MySQL lately. Sometimes I find it easier to work the result set in a dictionary form and other times it is easier with an array. But in order to not break all your code, it is necessary to set a default cursor …

By eric

Python Multiprocessing Pools and MySQL

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 …

By eric

Python's MySQLdb 2014 Error – Commands out of sync

While writing a simple Python script to access and process data in a database, I came across an error that said: 1Error 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 …

By eric

Custom Google Maps Marker With YM4R_GM

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. …

By eric

Country-State Select Using Carmen and jQuery

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 …

By eric

Adding AJAX Bookmarks to Your Rails Application (Part 2 of 2)

In part 1 of this series, we discussed the base models, controller, database migrations necessary to get this project off the ground. Now we are going to continue with this functionality Let’s take a look at what needs to go into the models to support this. If you have a model that uses a slug …

By eric

Adding AJAX Bookmarks to Your Rails Application (Part 1 of 2)

It you want to add the ability to bookmark pages in your Rails application, its actually a fairly straightforward thing to do. You can even do them in AJAX. There may be better ways to do this, but this way is somewhat abstract and it works for me, so hopefully it can work for you …

By eric

File Read Write Create with IO::File

Ran into an annoying gotchya with Perl’s IO::File. Apparently opening the file in append mode with read access if the file already exists puts the file position pointer at the end of the file. If it doesn’t exist, it creates the file. Note the +>>, that opens the file r/w/append. You can also use the …

By eric

One Time Modal Windows With Rails and Fancybox

Let’s say that you have a situation that you want to have a modal window show up only once for each user. It’s actually not that difficult although lots of Googling around got me nowhere. I am choosing to use FancyBox for my modal window, but feel free to use your modal framework of choice. …

By eric

Printing New Lines in Bash

Ran across this the other day and decided it required sharing. If you want to print a new line ‘\n‘ in an echo statement in bash, one would think its just as simple as: 12beacon:~ elubow$ echo "This is a test\n" This is a test\n The problem is that this doesn’t interpolate the newline character. …

By eric

Follow My Travels

Buy My Book


  • 2020
  • 2019
  • 2017
  • 2014
  • 2013
  • 2012
  • 2011
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006

New Posts By Email