Skip to content

Instantly share code, notes, and snippets.

Avatar

Ry4an Brase Ry4an

View GitHub Profile
@Ry4an
Ry4an / session.py
Created Oct 13, 2015
default dict is your friend
View session.py
from collections import defaultdict, namedtuple
class Session:
def __init__(self):
self.seconds = 0
self.session_id = None
self.events_by_type = defaultdict(int)
def add_event(self, event):
if self.session_id and event.session_id != self.session_id:
View gist:d10b97a3c47c54601c3c
foobar</div>
> quote in code block

quote outside code block

View keybase.md

Keybase proof

I hereby claim:

  • I am ry4an on github.
  • I am ry4an (https://keybase.io/ry4an) on keybase.
  • I have a public key whose fingerprint is 9F62 F388 0680 DB9C 199C E813 D2F8 E7C5 03B7 1364

To claim this, I am signing this object:

@Ry4an
Ry4an / unloved-issue.py
Created Jul 7, 2014
nag least recently updated issue for this release
View unloved-issue.py
#!/usr/bin/python
import json
import pytz
import urllib2
import datetime
import dateutil.parser
import re
import sys
import humanize
View request
curl 'http://api.swiftype.com/api/v1/public/engines/suggest.json?callback=jQuery17202572345747612417_1392736179267&q=lov&engine_key=CywzyscJAHKCwrezfzpN&search_fields%5Bactor%5D%5B%5D=name&search_fields%5Bactor%5D%5B%5D=alt_names&search_fields%5Btag%5D%5B%5D=title&search_fields%5Bseries%5D%5B%5D=title%5E4&search_fields%5Bseries%5D%5B%5D=alt_title%5E2&search_fields%5Bseries%5D%5B%5D=genre&search_fields%5Bseries%5D%5B%5D=tags&search_fields%5Bseries%5D%5B%5D=description&search_fields%5Bseries%5D%5B%5D=description_short&search_fields%5Bseries%5D%5B%5D=description_flipper_es&search_fields%5Bseries%5D%5B%5D=description_es&fetch_fields%5Bactor%5D%5B%5D=external_id&fetch_fields%5Bactor%5D%5B%5D=url&fetch_fields%5Bactor%5D%5B%5D=name&fetch_fields%5Bactor%5D%5B%5D=thumbnail&fetch_fields%5Bactor%5D%5B%5D=series_count&fetch_fields%5Btag%5D%5B%5D=external_id&fetch_fields%5Btag%5D%5B%5D=url&fetch_fields%5Btag%5D%5B%5D=title&fetch_fields%5Bseries%5D%5B%5D=external_id&fetch_fields%5Bseries%5D%5B%5D=url&fetch_fields%5Bseries%
@Ry4an
Ry4an / pre-commit
Created Feb 13, 2014
Put this in your repo's www/.git/hooks as pre-commit to make sure you can't commit with 'KILL ME' in a line
View pre-commit
#!/bin/sh
#
if git diff --cached | grep --quiet 'KILL ME' ; then
echo FORGOT TO REMOVE KILL ME
exit 1
fi
View gist:8736298
class ParanoidContextProxy(object):
"""
This is a poor-man's proxy for a context instance.
Make sure template rendering stops immediately on a KeyError.
"""
def __init__(self, context):
self.context = context
def __getitem__(self, key):
@Ry4an
Ry4an / cors-nginx.conf
Last active Nov 5, 2020 — forked from alexjs/cors-nginx.conf
Here' the minimal Access-Control-Allow-Origin header insertion necessary to allow any whitelisted sites to access resources via CORS headers.
View cors-nginx.conf
#
# Minimal CORS config for nginx
#
# A modification of https://gist.github.com/alexjs/4165271
#
# NB: This relies on the use of the 'Origin' HTTP Header.
location /static {
if ($http_origin ~* (whitelist\.address\.one|whitelist\.address\.two)$) {
@Ry4an
Ry4an / ircsay.sh
Created May 30, 2013
Write to a named pipe (for ii) but don't block forever doing it
View ircsay.sh
#!/bin/bash
# adapted from http://stackoverflow.com/questions/422530/write-to-fifo-pipe-from-shell-with-timeout
case $# in
0) echo "Usage: `basename $0` message..." 1>&2 ;;
esac
{
echo "$@" > /persistent/dramafever/phenny/irc/irc.freenode.net/#dramafever/in
@Ry4an
Ry4an / irc-rant
Created May 10, 2013
My cranky-day rant about people /msg-ing in work IRC
View irc-rant
People keep /MSG-ing me non-secret things in IRC, so I assume everyone's doing it w/ one another too. Everytime someone /msg-s me I ask them to bring it up in the main channel instead, but that's not getting the message across, so: STOP IT.
The whole point of IRC is that there's huge benefit in everyone overhearing things that they're not currently working on. This is why IRC is 1000x better for a tech group than IM. There's incredible value in making things like "Oh, I did that at my last job, consider looking at X" or "Didn't I see you did something with Y last month?" possible, and all of that gets flushed down the drain when you /msg.
Don't worry about the channel getting too chatty. I'm in some channels w/ 200+ members and it works just fine. Your IRC client will figure it out.
There might be no immediate need for [Alice] to hear [Bob] and I discussing the finer points of dynamo throughput settings, but there's no harm in it and if at the end of the month the bill knocks her socks off she's goin