Skip to content

Instantly share code, notes, and snippets.

View justinabrahms's full-sized avatar

Justin Abrahms justinabrahms

View GitHub Profile
@justinabrahms
justinabrahms / git-stash-grep
Created August 13, 2014 23:56
grep your git stash
#!/bin/bash
for i in `git stash list --format="%gd"`; do
git stash show -p $i | grep -H --label="$i" "$1"
done
@justinabrahms
justinabrahms / .pdbrc.py
Created July 23, 2014 21:11
default pdbpp to start with sticky enabled
import pdb
class Config(pdb.DefaultConfig):
sticky_by_default = True
@justinabrahms
justinabrahms / gist:5a29d7e74e0620e23f08
Last active August 29, 2015 14:03
Comparisons of Hay's 2002 translation (bottom) and an older translation on Project Gutenberg (above).

(Classic Translation)

Of my grandfather Verus I have learned to be gentle and meek, and to refrain from all anger and passion.

From the fame and memory of him that begot me I have learned both shamefastness and manlike behaviour. Of

my mother I have learned to be religious, and bountiful; and to forbear, not only to do, but to intend any evil; to content myself with a spare diet, and to

@justinabrahms
justinabrahms / gist:10015289
Last active August 29, 2015 13:58
My PyCon go-to-talk list. Blank indicates I'm considering skipping that block for the hallway track.

April 11 -- Day 1

  • 10:50 -- Computer Science fundamentals for self-taught programmers (my talk)
  • 11:30: Creating bomb-proof data importers
  • 12:10:
  • 1:40/1:55: The Birth & Death of Javascript -- Gary is a fantastic speaker.
  • 2:35:
  • 3:15: Getting Started with SaltStack OR What is Async
  • 4:15/4:30: Maybe Castle Anthrax. Maybe Distributed Computing.
  • 5:10: Python + Geographic Data = BFFs (Support for fellow Portlanders!)

Keybase proof

I hereby claim:

  • I am justinabrahms on github.
  • I am justinabrahms (https://keybase.io/justinabrahms) on keybase.
  • I have a public key whose fingerprint is E0B7 AA7C 81E5 BEC7 991E FA4E 320E 47C9 795A D0D6

To claim this, I am signing this object:

@justinabrahms
justinabrahms / gist:9116933
Last active August 29, 2015 13:56
anti-scraper

So I was writing an article on screen scraping and one of the things that came up is "How do you mitigate against screen scraping?" I think this is actually in interesting question, which brought up the idea of a side project that maybe someone else has time for.

The idea is that to prevent screen scraping, the page being scraped must be mutated as to break a scraper. To do that, you could do things like alter selectors of css resources and html (for instance, changing all ids of "signupButton" to "sarah-goldfarb") or change the structure of the page. Maybe it also mutates the structure of the DOM.

A small node proxy that does this around streams would be particularly cool.

Things you're likely to learn:

  1. More about CSS selector precedence. Which selectors can you easily mutate? Which are harder? Are there examples of selectors which you can't mutate?
  2. What can XPath do? XPath is a mechanism for querying tree structures (notably XML). If you were g
@justinabrahms
justinabrahms / gist:8994424
Created February 14, 2014 01:51
A simple HTTP proxy for speedy static file serving, sending dynamic requests to a backend web server.
/**
* A proxy for loading static files in development. Django doesn't handle this well.
*
* To run, do something like:
* npm install .
* node proxy.js --docroot=$PWD
*
* Then just visit http://localhost:9000/ as you normally would.
*/
var httpProxy = require('http-proxy');
I really want a service where you can enter in 2 wikipedia pages and
it will tell you how they relate. It'd be especially cool if someone
else made it, so I'm writing up how I think it might be done in
Python.
Due to the nature of the queries you want to do (how does x relate to
y), I think this should end up in a graph database. In this graph
database, every page is a node. Links between pages are directed edges
in the graph, annotated with the paragraph of text they're linked
from.
@justinabrahms
justinabrahms / gist:7989647
Created December 16, 2013 16:14
Notes taken regarding interceptor pattern (similar to cujojs) ported to backend request handling. Needs to be better fleshed out and will probably only mean something to @phated
/*
goals:
middleware, like express.
no `.next()`, which express has.
use of promises (rejecting/resolving) unlike node's traditional (err, data) thing
immutable requests, preferring instead an explicit databag for state managment (continuous local storage)
"composable after the routing method"
@justinabrahms
justinabrahms / gist:7311596
Created November 5, 2013 00:02
Use a cached virtualenv during CI
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