Jun 28, 2012

Feb 14, 2012

Jquery FullCalendar Hacks

I was working on a calendar app (Duh!) using Jquery FullCalendar, encountered some problems and this is how I fixed them.

Problem 1: Resize, Drag & Drop stopped working

Problem 2: Unique events when dragging and resizing

Problem 3: Same as problem 2, but for external drop events

 


Supervisord: Stop/Start gunicorn processes with XMLRPC and python

Supervisor: A Process Control System, as stated on supervisor's site. I used it to "supervise" gunicorn services which serves my Django sites.

I have a use case where I need to restart a gunicorn instance from Django itself. Supervisor supports XMLRPC, but instructions to use them weren't very well documented (no examples for lazy me). After some research (google + stackoverflow), I finally figured out how to do so.

As suggested from one of the stackoverflow post, supervisor is pure python implementation, so naturally it will use python libs to implement xmlrpc. That's exactly the codes we need to connect to supervisord's xmlrpc server.

from xmlrpclib import ServerProxy s = ServerProxy("http://localhost:10000") s.supervisor.stopProcess('process1') s.supervisor.startProcess('process1', False)

Jan 17, 2012

Checking for variable (Javascript vs Python)

Javascript

if (typeof q != 'undefined' || q != '' || q !== null) {  }

Python

if q: pass