Skip to content

Instantly share code, notes, and snippets.

View jcarbaugh's full-sized avatar
🍳

Jeremy Carbaugh jcarbaugh

🍳
View GitHub Profile
@jcarbaugh
jcarbaugh / jobs-jobs-jobs.md
Last active October 16, 2017 15:21
Open Positions at ISL
@jcarbaugh
jcarbaugh / discover.py
Created September 30, 2015 17:33
DIAL examples
import httplib
import socket
import StringIO
# generic
SSDP_ALL = 'ssdp:all'
UPNP_ROOT = 'upnp:rootdevice'
# devices
DIAL = 'urn:dial-multiscreen-org:service:dial:1'
@jcarbaugh
jcarbaugh / redactionmachine.html
Created March 4, 2015 17:24
Redaction Machine demo
<!doctype html>
<html lang="en-us">
<style>
html { font-family: sans-serif; }
p.document {
border: 1px solid #999999;
font-family: serif;
font-size: 120%;
line-height: 150%;
padding: 2em;
@jcarbaugh
jcarbaugh / index.html
Created February 19, 2015 19:11
Tweet at the legislators that represent your ZIP code
<!doctype html>
<!--
Replace YOUR-API-KEY-HERE with your API key.
Register for a key at http://sunlightfoundation.com/api/
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tweet at Congress</title>
</head>
@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
@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 / 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 / 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 / ughxml.py
Created April 3, 2014 14:46
Ugh... XML.
import re
from lxml import etree
def empty_generator():
return
yield
@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',