Skip to content

Instantly share code, notes, and snippets.

View justinabrahms's full-sized avatar

Justin Abrahms justinabrahms

View GitHub Profile
@justinabrahms
justinabrahms / gist:4199302
Created December 4, 2012 00:16
virtualenv code saves 2 minutes per build on our boxen.
# Installing things takes a while. Skip if if nothing has changed.
# jenkins requires things to be html escaped to work properly, hence the weird command below
VENV_DIR=`md5sum requirements/* | md5sum 2>&1 | awk '{print $1}'`
if [ -e $VENV_DIR ]; then
. /tmp/$VENV_DIR/bin/activate
else
virtualenv --no-site-packages /tmp/$VENV_DIR
. /tmp/$VENV_DIR/bin/activate
pip install --download-cache /var/lib/jenkins/.pip_download_cache -r requirements/ci.txt
fi
description "autoreply - twitter bot which redirects users to new acccount"
author "Justin Abrahms <justin@abrah.ms>"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
respawn
env LOGFILE=/srv/justinlilly-autoreply/history.json
env ENV_ROOT=/srv/justinlilly-autoreply/env
env APP_ROOT=/srv/justinlilly-autoreply/autoreply
@justinabrahms
justinabrahms / gist:4227986
Created December 6, 2012 20:21
Response to recruiter emails.
Hey,
I just want to say thanks so much for getting in touch. While I'm not
looking for work directly at this moment, I do think a partnership
could be possible. Have you seen https://sprint.ly/ ? Its a really
great, next-gen project management tool that helps connect business
users to developers in ways that make sense to both sides. Maybe your
company or a company you know might be able to make use of it? There
are a great number of companies already shipping great software with
it and there is a 30 day free trial, no questions asked.
@justinabrahms
justinabrahms / gist:4232768
Created December 7, 2012 11:43
Sprint.ly Deploy API GET response.
[{
"environment": "staging",
"items": [{
"status": "completed",
"product": {
"archived": false,
"id": 1,
"name": "sprint.ly"
},
"description": "http://support.sprint.ly/discussions/problems/222-not-sure-what-some-things-mean",
@justinabrahms
justinabrahms / gist:4232813
Created December 7, 2012 11:53
Sprint.ly Deploy API POST response.
{
"environment": "staging",
"items": [{
"status": "completed",
"product": {
"archived": false,
"id": 1,
"name": "sprint.ly"
},
"description": "http://support.sprint.ly/discussions/problems/222-not-sure-what-some-things-mean",
@justinabrahms
justinabrahms / gist:4449707
Created January 4, 2013 03:40
A little utility to jump to the next available character in emacs just like in vim.
(defun jump-to-next-char (c &optional count)
"Jump forward or backward to a specific character. With a
count, move that many copies of the character."
(interactive "cchar: \np")
(when (string= (string c) (buffer-substring (point) (+ 1 (point))))
(setq count (+ 1 count)))
(and
(search-forward (string c) nil t count)
(> count 0)
// Make a single api call to meetup.com and grab event info for all (11) PyLadies locations. Create individual objects for each so that meetups can be added to each pyladies group's div on pyladies.com/locations page.
//helper function to discover event urls and make active links
//credit to http://www.sencha.com/forum/archive/index.php/t-12379.html for code this is based on
function create_urls(input) {
return input
.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim, '"$&" target="_blank"')
.replace(/([^\/])(www[\S]+(\b|$))/gim, '"http://$2" target="_blank"');
} //end url parsing helper function
@justinabrahms
justinabrahms / gist:5041966
Created February 26, 2013 20:41
Example of a Schematics SubclassField which will dispatch to different model types based on a mapping dict and property of the input.
class Parent(Model):
model_type = StringType(required=True)
class Person(Parent):
name = StringType()
class Item(Parent):
description = StringType()
class Container(Model):
@justinabrahms
justinabrahms / 1_original.py
Last active December 15, 2015 15:29
A few attempts at refactoring a datastructure for holding activity items that powers gitstreams.
class ActivityCollector(object):
"""
The goal of this class is to take Activity objects and output a data
structure like this:
{
'people': {
'justinabrahms': {
'orphan_events': [
'WatchEvent': [..watches..],
@justinabrahms
justinabrahms / gist:5465490
Last active December 16, 2015 16:49
A method of getting per-user logs in python logging. It turns out my original plan which is /var/log/myapp/user.<pk>.log isn't a very good idea from performance b/c you're basically sitting there with a bunch of open files and a bunch of logging handlers each with their own per-user id filter applied. After you get logs in this format, you can w…
class UserLog(object):
"""
Simple log that will output specially formatted user id for logging
purposes.
-1 is used as a sentinal value to mean "no user". Otherwise, the user's `pk`
attribute is logged instead.
An explicit decision was made not to use a LoggerAdapter with a custom
format string because if we attach it to something that isn't the logger