Skip to content

Instantly share code, notes, and snippets.

@jhorman
jhorman / redis_promise_pipeline.py
Last active August 29, 2015 14:22
Promises for redis-py
from __future__ import absolute_import
import functools
from aplus import Promise
class PPromise(Promise):
def __init__(self, pipeline):
Promise.__init__(self)
self.pipeline = pipeline
#!/bin/bash
QUEUE=
echo "starting amazon sqs worker for queue $QUEUE"
while true
do
MESSAGE=`aws sqs receive-message --wait-time-seconds=1 --visibility-timeout=600 --queue-url=$QUEUE`
if [ $? -ne 0 ]; then
from __future__ import absolute_import
import signal
import gevent
import gevent.pool
from rq import Worker
from rq.timeouts import BaseDeathPenalty, JobTimeoutException
from rq.worker import StopRequested, green, blue
from rq.exceptions import DequeueTimeout
@jhorman
jhorman / keybase.md
Created April 4, 2014 01:23
keybase.md

Keybase proof

I hereby claim:

  • I am jhorman on github.
  • I am jhorman (https://keybase.io/jhorman) on keybase.
  • I have a public key whose fingerprint is 2A09 5F8E 34F5 2DCC DB20 F8AF FAC7 EEDF 468C D5D2

To claim this, I am signing this object:

@jhorman
jhorman / redis_semaphore.py
Last active April 13, 2022 12:39
Redis semaphore implemented in Python via zsets. Lock expiration is implemented by only scanning the zset for items within a time range.
from __future__ import absolute_import
from time import time, sleep
import uuid
class RedisSemaphore(object):
"""
Redis base semaphore. Supports timeouts of semaphore locks.
"""
# Git prompt
export GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWUNTRACKEDFILES=1 GIT_PS1_SHOWSTASHSTATE=1
export PS1='\w\[\033[01;33m\]$(__git_ps1)\[\033[00m\] \$ '
# less syntax highlighting
# brew install source-highlight
export LESSOPEN="| src-hilite-lesspipe.sh %s"
export LESS=' -R '
///////////////////////////
// JAVASCRIPT RULE ENGINE
///////////////////////////
/*global define*/
define([
'lodash.noconflict'
], function (_) {
'use strict';
function Rules(options) {
@jhorman
jhorman / git_find.sh
Created October 24, 2012 19:37
git log find by content
git config --global alias.find "!gf() { git log -G \"\$1\" --pretty=\"format:%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\" --abbrev-commit --date=relative; }; gf"
@jhorman
jhorman / springpad_oauth.sh
Created December 14, 2011 18:17
Springpad OAuth Help
# http://mojodna.net/2009/08/21/exploring-oauth-protected-apis.html
easy_install oauth-proxy
sudo gem install oauth
oauth --consumer-key XXXXX --consumer-secret XXXXX --access-token-url http://springpadit.com/api/oauth-access-token --authorize-url http://springpadit.com/api/oauth-authorize --request-token-url http://springpadit.com/api/oauth-request-token authorize
oauth-proxy --consumer-key XXXXX --consumer-secret XXXXX -p 8001
@jhorman
jhorman / reddit_userstyle.css
Created December 8, 2011 05:34
Reddit to Hacker News
body { font: normal x-small verdana !important; }
.link { margin-bottom: 4px !important; }
.link .title { font: normal 10pt verdana !important; }
.link .flat-list { padding: 0px !important; }
.tagline { font: normal 7pt verdana !important; display:none !important; }
.link .rank { display: none; }
.sitetable { padding: 10px !important; margin-top: 30px !important; margin-left: 100px !important; margin-right: 100px !important; background-color: #F6F6EF }
.side { display: none; }
a:link { color: black !important; text-decoration: none !important;}
a:visited {color: #828282 !important;}