Load data into Vertica from an HTTP source using cURL – with example

Category : Code · (2) Comments · by Jul 27th, 2014

Recently I needed to load a CSV located in a public Amazon S3 bucket into Vertica. There’s some Vertica documentation for setting up a User Defined Load (UDL) Source, but here I’ll show you how to bring it all together.

In short, there’s a UDL Source for cURL in /opt/vertica/sdk/examples. You build the UDL from the given cpp code using make, and then create a library and source in Vertica for cURL. Finally, you can use cURL with a COPY statement to load data into a table.

Chaplin.js’s container, containerMethod, and listSelector options

Category : Code · No Comments · by Jan 15th, 2014

I’ve been dabbling with Chaplin.js recently, a javascript MVC framework built upon Backbone.js. I’ve used Backbone.js in the past, and found it lacking convention on how to structure your app. Chaplin.js adds sensible structure and convenient ways to avoid common pitfalls in Backbone.js, like memory leaks. This post also highlights some Chaplin.js/Backbone.js code to give you an small sample of how models, collections, views, collectionviews, templates interact.

I recently had a frustrating bug which I solved by tracing through chaplin.js for hours. Granted, the solution was in the docs all along, but sequentially reading every documented method is a tiring and often rushed process. I probably should have asked StackOverflow, found an IRC channel, or posted an issue on github, but alas. So if you’re coming from Google, hopefully this post saves you some time.

So here was the problem: I wanted to add a collection’s child view into a certain DOM element from the template of the CollectionView. The child view had autoAttach and autoRender set to true. I thought the appropriate options to use were container and containerMethod, but child views just weren’t be added in the right place. After some tracing, I realized I needed to look at the insertView method, which led to the listSelector option, which is clearly what I needed.

Wrong way (uses the container option in a child view):

Correct way (uses the listSelector option in the collection view):

tl;dr use listSelector to define the DOM element where child Views are inserted in a CollectionView, not the container option

Python Celery RabbitMQ PicklingError

Category : Code · No Comments · by Jul 30th, 2012

I was getting an error setting up Celery running RabbitMQ as my AMQP in Django. Every time I called a tasks’s delay() method, I got the following error:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/worker/__init__.py", line 371, in process_task
File "/usr/local/lib/python2.7/dist-packages/celery/worker/job.py", line 191, in execute_using_pool
File "/usr/local/lib/python2.7/dist-packages/celery/concurrency/base.py", line 135, in apply_async
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 1135, in apply_async
self._quick_put((result._job, None, func, args, kwds))
PicklingError: Can't pickle : attribute lookup __builtin__.instancemethod failed

Frustrated and without a solution from google, I resigned to a synchronous solution in the meantime. A few days later, I approached the problem again.

On a whim, I checked what version of django-celery I was using:
python -c "import djcelery; print djcelery.__version__"

Turns out I was using 3.0.1. After digging around the changelog for celery, I found the error was solved with celery 3.0.3.

A pip update solved the problem for me:
pip install -U django-celery

tl;dr upgrade celery past 3.0.3

A tour of my apartment in Mountain View, CA

Category : Life · No Comments · by May 22nd, 2011

Thursday was my last final at Cornell for my junior year, and my brothers picked me up to go home. Today, Saturday, I flew into San Fransisco, California and shuttled my way over to Mountain View, where I’ll be living this summer.

My visit home was unfortunately ephemeral, but I still got to see a few of my friends, and I still got to hang out with my bros and family.  I’m rather anxious – in both senses of the word – to start working and meeting new people.  I imagine it’ll be like the first few weeks of freshmen year, in which everyone is abnormally extroverted but all conversation is limited to the collegiate version of “a/s/l.”

I am the first of my three, fellow Cornellian roommates to arrive.  In two words, my apartment is super baller.  Below is a quick tour:



Aeshna is my dear :)

Modify WordPress Permalinks with Apache on Ubuntu 10.04

Category : Code · No Comments · by May 18th, 2011

My site runs WordPress on a Linode instance with Ubuntu 10.04 with nginx as a  front-end proxy to Apache.  (That is, all requests to my machine first hit nginx, which usually serves static files on my Django projects, and then they get re-routed to Apache.)

Today, I wanted to change the link structure on my site so that page resources are more permanent.  I wanted to change the permalinks from:




In wp-admin, go to Settings > Permalinks, and choose from the radio buttons.  I chose “month and name”.  However, when I applied settings and tried to go to a static page like http://sohanjain.com/blog/, I got an HTTP 500 internal server error.

To get permalinks working properly with Apache, you must enable mod_rewrite:
sudo a2enmod mod_rewrite

The command a2enmod just creates symlinks (symbolic links, i.e., ln -s ) between /etc/apache2/mods-available and /etc/apache2/mods-enabled directories.

Finally, add the following to your .htaccess file:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

If you don’t have a .htaccess file, then WordPress can create one for you, given that your root directory has sufficient privileges for WordPress to create files. WordPress will ask to create the file once you update permalinks and it realizes you do not already have a .htaccess file.

Restart apache with sudo /etc/init.d/apache2 restart and you should be good to go.

A night of reflection and nostalgia

Category : Life, Music · No Comments · by May 18th, 2011

After chatting with one of my good friends and graduating senior, Emily, I began to reflect on what I’ve actually accomplished so far in life.  I made this site primarily to document my progress through life, so that I can look back 50 years from now and say, “Hey, I existed”.

One of my proudest moments to date, trumping assorted academic accolades and myriads of resume-worthy material, was when my band placed 3rd in our high school’s Battle of the Bands my senior year.  I’ve been crowd surfing since I was 15, and performing on stage for an audience of cheering friends was such a thrill.  Footage below:


Sup, World?

Category : Life · No Comments · by Mar 30th, 2011

My name is Sohan, and this is my blog.