This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import os, os.path | |
DEFAULT_PROFILE_NAME = "default.2m2" | |
SESSION_PATH = "Library/Application Support/Firefox/Profiles/%s/sessionstore.js" | |
# TODO consider generalizing the session store to open (different users, different profiles) | |
def session_path(): | |
return os.path.join(os.environ['HOME'],SESSION_PATH % DEFAULT_PROFILE_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Change row[1] to the row index to be printed. row[1] will print the second | |
item in the row. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Leveraged from/motivated by an example from @bycoffe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Leveraged from/motivated by an example from @bycoffe | |
Should use something better than getopt, but this works... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strfix <- function(s) { | |
s = gsub("(^ +)|( +$)", "", s) | |
s = sub("^(.*)$","\\U\\1",s, perl=TRUE) | |
return (s) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Should use something better than getopt, but this works... | |
Usage: | |
csvcut foobar.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Should use something better than getopt, but this works... | |
Usage: | |
csvcut foobar.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import csv | |
input_file = sys.argv[1] | |
r = csv.reader(open(input_file)) | |
w = csv.writer(sys.stdout) | |
w.writerow(['column','start','length']) | |
for row in r: | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv, json | |
from collections import defaultdict | |
r = csv.reader(open("data.csv")) | |
headers = r.next() | |
countries = headers[1:] | |
out_rows = [] | |
for row in r: | |
area = row[0] | |
out_row = [area] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Chicago Tribune is seeking a CAR journalist who can serve a 2-year | |
residency for the newsroom. The candidate for this Computer Assisted | |
Reporting position should have proven watchdog skills and experience | |
with every facet of story development, from filing FOIA requests to | |
finishing a polished draft of a newspaper story and its digital | |
package. Clips should show proven results of this kind of work. | |
A key part of the job is to work with suburban reporters assigned to | |
specific towns to tell stories that can be told only by those with | |
command of hard data. This journalist also will be looking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from icalendar import Calendar, Event | |
from datetime import timedelta | |
from dateutil.parser import parse | |
from dateutil.tz import tzlocal | |
from pyquery import PyQuery as pq | |
from urlparse import urljoin | |
urls = { |
OlderNewer