Skip to content

Instantly share code, notes, and snippets.

View jldupont's full-sized avatar

Jean-Lou Dupont jldupont

View GitHub Profile
@jldupont
jldupont / gist:1644429
Created January 20, 2012 01:35
Python: determining package version # at runtime
>>> import pkg_resources
>>> pkg_resources.get_distribution("blogofile").version
'0.7.1'
@jldupont
jldupont / gist:1644406
Created January 20, 2012 01:34
Python: list of installed packages through easy_install / distutils
import pkg_resources
distros = pkg_resources.AvailableDistributions() # scan sys.path
for key in distros:
for dist in distros[key]:
print dist.name, dist.version
@jldupont
jldupont / gist:1643876
Created January 20, 2012 00:05
Supervisord : access through RPC
>>> import xmlrpclib
>>> x = xmlrpclib.ServerProxy('http://127.0.0.1:9001/RPC2')
>>> x.system.listMethods()
['supervisor.addProcessGroup', 'supervisor.clearAllProcessLogs', 'supervisor.clearLog', 'supervisor.clearProcessLog', 'supervisor.clearProcessLogs', 'supervisor.getAPIVersion', 'supervisor.getAllConfigInfo', 'supervisor.getAllProcessInfo', 'supervisor.getIdentification', 'supervisor.getPID', 'supervisor.getProcessInfo', 'supervisor.getState', 'supervisor.getSupervisorVersion', 'supervisor.getVersion', 'supervisor.readLog', 'supervisor.readMainLog', 'supervisor.readProcessLog', 'supervisor.readProcessStderrLog', 'supervisor.readProcessStdoutLog', 'supervisor.reloadConfig', 'supervisor.removeProcessGroup', 'supervisor.restart', 'supervisor.sendProcessStdin', 'supervisor.sendRemoteCommEvent', 'supervisor.shutdown', 'supervisor.startAllProcesses', 'supervisor.startProcess', 'supervisor.startProcessGroup', 'supervisor.stopAllProcesses', 'supervisor.stopProcess', 'supervisor.stopProcessGroup', 'supervisor.tai
@jldupont
jldupont / partial.py
Created December 12, 2011 19:27
Partial Function application in python
def partial(fn, *pargs):
"""
Partial Function builder
>>> f=lambda p1,p2: p1+p2
>>> pf=partial(f, 66)
>>> pf(44)
110
"""
def _(*args):
plist=list(pargs)
@jldupont
jldupont / map.java
Created September 2, 2011 11:58
GWT Map
/**
* Map
*
* @author jldupont
*/
package com.cdf.front.types.client;
import java.util.Iterator;
import java.util.Set;
@jldupont
jldupont / mswitch.js
Created August 20, 2011 07:28
Lightweight Publish/Subscribe Message Switch
/*
* Message Switch
*
* @desc Each subscriber gets at least the first occurence of a message-type:
* it is the responsibility of the subscriber to return its "interest"
* for a particular 'message type'.
*
* Suscribers must implement the 'mailbox' method.
*
* NOTE: 'no interest' map stored in the Agent
@jldupont
jldupont / runner.js
Created August 20, 2011 07:25
Lightweight Javascript Proc & Task Runner
/*
* A lightweight proc & task runner
*
* runner.js
*
* @author Jean-Lou Dupont
*
* @dependencies:
* - oo.js ('method')
*/
@jldupont
jldupont / get_ip.sh
Created March 24, 2011 12:31
Retrieve IP address associated with eth0 (bash)
ip address | grep eth0 | grep inet | awk -F" " '{print $2}'
@jldupont
jldupont / get_mac.sh
Created March 24, 2011 12:30
Retrieve MAC address of eth0 (bash)
ip link | grep "link/ether" | awk -F" " '{print $2}'
@jldupont
jldupont / backup_rb.bash
Created October 1, 2010 12:16
Backup rhythmbox db to Google Docs
#!/bin/bash
#
# Backup my rhythmbox database over to Google Docs
#
DATE=`date +%d%m%g`
zip /tmp/rb${DATE} ~/.local/share/rhythmbox/rhythmdb.xml
/usr/local/bin/google docs upload --folder=_backup --title=rb${DATE}.zip /tmp/rb${DATE}.zip