Skip to content

Instantly share code, notes, and snippets.


Richard Caceres rchrd2

View GitHub Profile
rchrd2 / gist:6179550
Created Aug 7, 2013
How to link django-social-auth with google-api-python-client I am creating a gist, because this took me way to long to figure out. Maybe it can save you some time!
View gist:6179550
import httplib2
from apiclient.discovery import build
from oauth2client.client import AccessTokenCredentials
def connect_helper(user):
c = user.social_auth.get(provider='google-oauth2')
access_token = c.tokens['access_token']
credentials = AccessTokenCredentials(access_token, 'my-user-agent/1.0')
http = httplib2.Http()
rchrd2 /
Created Nov 4, 2013
Helper script to convert wav files to mp3 with ffmpeg.
# Validate arguments
if [[ "$#" == 0 ]]; then
echo >&2 "Usage: ./ ./exports/*.wav"
exit 1;
rchrd2 /
Created Nov 19, 2013
Watch a directory then automatically render and open profile graphs.
watchmedo shell-command \
--pattern="*prof" \
--ignore-pattern="*png" \
--wait \
--command='find profile_data -name "*\.prof" -exec sh -c "test -f {}.png || (gprof2dot -f pstats {} | dot -Tpng -o {}.png && open {}.png)" \;' \
rchrd2 / johnd1
Last active Dec 29, 2015
These are templates for creating an init.d script for a Procfile that needs to be run with virtualenv. The first uses `daemon`. The second uses `start-stop-daemon`.
View johnd1
# Provides: johnd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
rchrd2 / Restart_Celery
Created Nov 28, 2013
This sends a SIGHUP to the children of a master celery process. The benefit of this is that the master celery process keeps it's same PID.
View Restart_Celery
# Send a SIGHUP to only the children (--ppid is the magic param here).
cat /var/run/ | xargs ps --no-headers --ppid | awk '{print $1}' | xargs kill -HUP
A pretty nice time parsing regex.
@author Richard Caceres, @rchrd2
import re
# The history for this regex is stored in my gist
time_range_regex = re.compile(r'''
rchrd2 / Procfile
Last active Aug 29, 2015
Procfile for gulp + python server in ./public
View Procfile
# Run with "foreman start"
gulp: gulp
server: sh -c 'cd public && python -m SimpleHTTPServer 9876'
rchrd2 /
Last active Aug 29, 2015
First steps to setup a new puppet agent
# Install NTP for clock syncing
apt-get install -y ntp
/etc/init.d/ntp start
# Install Puppet from official packages
mkdir source
cd source
sudo wget
sudo dpkg -i puppetlabs-release-precise.deb
rchrd2 / gist:e5810e7fa15b7beb713d
Created Jun 19, 2014
View gist:e5810e7fa15b7beb713d
# A simple configuration file for monitoring the local host
# This can serve as an example for configuring other servers;
# Custom services specific to this host are added here, but services
# defined in nagios2-common_services.cfg may also apply.
define host{
use generic-host ; Name of host template to use
host_name localhost
alias localhost
rchrd2 /
Created Jun 21, 2014
# A simple nagios check for Redis set length
# It doesn't require any redis libraries and uses the raw api
# @author Richard Caceres (
# @license MIT
# @example check_redis_llen -c 50 -w 10 -k celery -h localhost -p 6379
# Parse -c -w args