Skip to content

Instantly share code, notes, and snippets.

View jcarbaugh's full-sized avatar
🍳

Jeremy Carbaugh jcarbaugh

🍳
View GitHub Profile
@jcarbaugh
jcarbaugh / json-ld.js
Last active December 17, 2015 06:59
JSON-LD v plain old JSON
{
format: "linked-data-api",
version: "0.2",
result: {
_about: "http://environment.data.gov.uk/doc/bathing-water/ukl1702-36800.json",
definition: "http://environment.data.gov.uk/meta/doc/bathing-water/_eubwid.json",
extendedMetadataVersion: "http://environment.data.gov.uk/doc/bathing-water/ukl1702-36800.json?_metadata=all",
primaryTopic: {
_about: "http://environment.data.gov.uk/id/bathing-water/ukl1702-36800",
country: {
@jcarbaugh
jcarbaugh / serve
Last active December 26, 2015 08:49
Start a local server. Specify server and port.
#!/bin/bash
PORT=8000
IP=127.0.0.1
while getopts p: opt; do
case $opt in
i)
IP=$OPTARG
echo "Setting IP address to $IP"
@jcarbaugh
jcarbaugh / SFAutomaticPagingCongressAPIClient.py
Last active December 31, 2015 06:29
A paging wrapper for python-sunlight?
import sunlight.services.congress
class PseudoService(object):
def __init__(self):
self.service = self.service_class()
def __getattr__(self, name):
attr = getattr(self.service, name)

Keybase proof

I hereby claim:

  • I am jcarbaugh on github.
  • I am jcarbaugh (https://keybase.io/jcarbaugh) on keybase.
  • I have a public key whose fingerprint is E091 3E44 E120 8073 5B9D C05E 08E1 D212 24F6 DCC0

To claim this, I am signing this object:

@jcarbaugh
jcarbaugh / birthdays.py
Created March 27, 2014 20:03
Happy birthday, Congress!
import datetime
import sys
import icalendar
import requests
SUNLIGHT_KEY = sys.argv[1]
URL = 'https://congress.api.sunlightfoundation.com/legislators'
FIELDS = ('title', 'first_name', 'nickname', 'last_name',
@jcarbaugh
jcarbaugh / ughxml.py
Created April 3, 2014 14:46
Ugh... XML.
import re
from lxml import etree
def empty_generator():
return
yield
@jcarbaugh
jcarbaugh / dreamcast2.js
Created April 24, 2014 22:04
dreamcast2.js 2D game engine
/*************************
* framework
************************/
var dreamcast2;
if (window.log === undefined) {
window.log = function() {
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if (this.console) {
@jcarbaugh
jcarbaugh / ip
Created May 7, 2014 17:59
Show all IP addresses and optionally copy to clipboard
#!/bin/bash
ETH_IP=`ipconfig getifaddr en0 | tr -d "\n"`
WIFI_IP=`ipconfig getifaddr en1 | tr -d "\n"`
EXTERN_IP=`dig +short myip.opendns.com @resolver1.opendns.com`
echo "Local"
echo " ethernet : $ETH_IP"
echo " wifi: : $WIFI_IP"
echo "Remote : $EXTERN_IP"
@jcarbaugh
jcarbaugh / ocemail.js
Last active August 29, 2015 14:07
OpenCongress email address algorithm in various languages
var ocemail = function(url, domain) {
var capitalize = function(s) { return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase(); }
// url parser from http://jsperf.com/url-parsing
var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
var hostname = urlParseRE.exec(url)[11];
if (hostname) {
var domainMatch = /^(?:www[.])?([-a-z0-9]+)[.](house|senate)[.]gov$/;
var match = domainMatch.exec(hostname.toLowerCase());
@jcarbaugh
jcarbaugh / README.md
Created January 19, 2015 19:09
An example Slack bot using sunlightlabs/butterfield

This is an example of using butterfield to create a Slack bot. The bot's behavior is defined in the message handlers found in examplebot.py. botconfig.json defines the two bots that will be created and the plugins and daemons added to each. We run the bots using the butterfield CLI:

$ butterfield botconfig.json

or

$ python -m "butterfield.cli" botconfig.json