Skip to content

Instantly share code, notes, and snippets.

@ericlagergren
ericlagergren / gist:10184049
Created April 8, 2014 20:13
Eric Lagergren's PGP public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (GNU/Linux)
mQINBFM0besBEADZdB3frS1S/uslISsWwyUcU5bRXAT2jXieZYWKHdZDFzl+RO/a
UXsom7YKYwxk85UK+lx0lyrxbSq9vsTO7ckPkCT1wonX3Lk+IhGJHvLBFBY6UUvd
XKRYUBs6/GkKD+j3GVWQDFeh20KAh970LoZEfY3GrADwRKd8mSSaJAEV2SHUkZso
wO7nVwdSo5Pxu5HUGowQ4RcqKDqoQf/aBle2WF20e2EFXIbDm+g7scpcW3fUELaY
85VK4wOhWPq0/lPiVvdSAeO6Nz8IE2buXR1FhiJfhpV367KK54ESKVxSDYwz014i
m1WHD/j8sDqqf314CpV2bSTkrUUzDohsyzQv46d7LZNm4ZROcQi2/EGJuYMEJBMH
+3lvzdBnAggYrLRw2mCnX13gStV6qxUDFXpN32tf6JdTHSEp+Uc1n8+UInGE68FW
<!-- ios standalone web app -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- ios status bar appearance, options: black, black-translucent -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- ios icon, just one size because ios will scale it, remove "-precomposed" if you want ios to add effects -->
<link href="icon@144x144.png" sizes="144x144" rel="apple-touch-icon-precomposed">
<!-- ios startup images -->
(function(c){return c.replace(/\s+\^COMMA/g,",").replace(/\^SEMICOLON/g,";").replace(/\^COLON/g,":").replace(/\^PERIOD/g,".").replace(/\^BANG/g,"!").replace(/\^DASH/g,"-").replace(/\^HYPHEN/g,"h-h").replace(/\^EMDASH/g,"-e-").replace(/\^OPENQUOTE/g,' "').replace(/\^CLOSEQUOTE/g,'" ').replace(/\s+\./g,".").replace(/\s+\!/g,"!").replace(/\s+\,/g,",").replace(/\s+\;/g,";").replace(/\s+\:/g,":").replace(/\s\h\-\h\s/g,"-").replace(/[^!,"'.]\"\s/g,'"').replace(/\s+\-\e-\s+/g,"--").replace(/.+?[\.\?\!](\s|$)/g, function(b){return b.charAt(0).toUpperCase()+b.substr(1)}).replace(/\"[a-z]/g,function(b){return b.charAt(0)+b.charAt(1).toUpperCase()})})(a);
// Set the variables R, C, and U equal to 'replace', 'charAt', and 'toUpperCase'
// Replace searches a string and replaces characters
// charAt finds the char at a certain position
// toUpperCase makes things uppercase
R="replace",
C="charAt",
U="toUpperCase";
// alert causes an on-screen pop-up, needed for this competition because I have to write to STDOUT
@ericlagergren
ericlagergren / StatePartyWebsiteLists
Last active August 29, 2015 14:03
JS key-value pair, JSON, and XML lists of all Republican and Democrat state parties and their respective websites 6/26/2014
===== KEY VALUE PAIR =====
var gopparties = {
"AL":"http://www.algop.org/"
"AK":"http://alaskarepublicans.com/"
"AZ":"http://www.azgop.org/"
"AR":"http://www.arkansasgop.org/"
"CA":"http://www.cagop.org/"
"CO":"http://www.cologop.org/"
"CT":"http://www.ctgop.org/"
import csv
import datetime
ld = '' # Input wanted LD
legdistrict = []
reader = csv.DictReader(open('active.txt', 'rb'), delimiter='\t')
for row in reader:
if row['LegislativeDistrict'] == 'ld':
#!/bin/bash
for ((i=1; i<51; i++))
do
echo $i | python data.py >> c;
done
#!/bin/bash
for ((i=1; i<51; i++))
do
(echo $i | python data.py >> b) &
done
@ericlagergren
ericlagergren / gist:6bc4f7c462703657c25a
Created July 9, 2014 07:24
Count lines in large csv files
#!/usr/bin/env python
def bufcount(filename):
f = open(filename)
lines = 0
buf_size = 1024 * 1024
read_f = f.read # loop optimization
buf = read_f(buf_size)
while buf:
0 ;) eric@crunchbang ~/sbdmn/republican/CsvCount/CsvCount $ time (wc -l file.txt)
3898815 file.txt
real 0m0.333s
user 0m0.164s
sys 0m0.160s
0 ;) eric@crunchbang ~/sbdmn/republican/CsvCount/CsvCount $ time python ./lines.py
3898815 lines
real 0m1.128s