Skip to content

Instantly share code, notes, and snippets.

@stucka
stucka / gist:5342652
Last active October 16, 2018 09:05
Tabula installation instructions for Ubuntu 12.04. Tabula turns PDFs into CSVs! http://source.mozillaopennews.org/en-US/articles/introducing-tabula/
Yeah, this all got outmoded when serious dependency problems with Tabula were removed.
No need to use this. Get Tabula directly. http://tabula.nerdpower.org/
@stucka
stucka / Gemfile
Last active December 16, 2015 07:49
Patches for ruby-opencv to work without photo and gpu modules. Alas, it still wants nonfree, so this doesn't help Tabula.
source "https://rubygems.org"
group :production do
platforms :mri_19, :mri_20 do
gem "algorithms"
gem "nokogiri"
gem "cuba"
gem "foreman"
gem "rake"
gem "resque"
@stucka
stucka / convertmods.py
Created July 24, 2013 13:59
Convert MOD video files to a more usable format, MPG, quickly. Maybe.
import sys
#from subprocess import call
import subprocess
for infile in sys.argv[1:]:
outfile=infile[0:-3] + 'mpg'
print "Trying to convert " + infile + " to " + outfile
sys.stdout.flush()
commandstring = "ffmpeg -i " + infile + " -acodec copy -vcodec copy " + outfile
subprocess.call(commandstring, shell=True)
@stucka
stucka / weather.py
Last active December 20, 2015 05:48
Get nicely formatted local weather. National Weather Service has less-good forecasts available in uppercase via FTP, but not these.
#!/home/mstucka/bin/python
# New Perl-esque version!
#!/home/mstucka/bin/python
#from bs4 import BeautifulSoup
#import requests
#full_url = 'http://forecast.weather.gov/MapClick.php?lat=32.8406946&lon=-83.6324022&site=all&smap=1&searchresult=Macon%2C%20GA%2C%20USA#.UfA_Q23fLTr'
#ul = (BeautifulSoup(requests.get(full_url).text)).find_all("ul", class_="point-forecast-7-day")
#li = str(ul[0].find_all('li')[0])
#print li[(li.rfind("/span")+6):(li.rfind("/li")-1)].strip()
@stucka
stucka / hourtosunrise.py
Last active December 20, 2015 17:28
Run some code an hour before sunrise.
#!/home/mstucka/bin/python
#Want to do something an hour before sunrise?
#sleep `./hourtosunrise.py`
#./dosomething.sh
import ephem
import datetime
import sys
now=datetime.datetime.now()
Macon=ephem.Observer()
@stucka
stucka / popcounty.svg
Created April 9, 2014 14:22
svg stuff
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stucka
stucka / zctasimple.csv
Created October 10, 2014 15:25
ZIP code latitude and longitude, extracted from U.S. Census Bureau's 2013 ZCTA files. ZCTA use comes with many warnings.
We can't make this file beautiful and searchable because it's too large.
"zip5","mylat","mylon"
43451,+41.3183010,-083.6174935
43452,+41.5157923,-082.9809454
43456,+41.6468445,-082.8226641
43457,+41.2673266,-083.4274645
43458,+41.5304461,-083.2133648
43460,+41.6011920,-083.5649985
43462,+41.2837850,-083.7228646
43463,+41.5086650,-083.5080344
43464,+41.4048795,-082.9241092
@stucka
stucka / gist:37d993ac091999a5340d
Created November 20, 2014 15:04
Push BEA local personal income data into one national file with csvkit
rem Have to force New Mexico into UTF-8.
del big1.csv
for /f %%f in ('dir /b CA04_??.csv') do csvgrep -c 2 -m "," %%f >>big1.csv
csvgrep -c 7 -m "Per capita personal income" big1.csv >big.csv
del big1.csv
@stucka
stucka / fips.sql
Created March 7, 2015 20:17
FIPS table for Georgia Secretary of State data
-- MySQL dump 10.13 Distrib 5.1.47, for redhat-linux-gnu (i386)
--
-- Host: localhost Database: editorial
-- ------------------------------------------------------
-- Server version 5.1.47
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
@stucka
stucka / cas_cat.csv
Created May 12, 2015 20:34
Vietnam casualty list lookup tables, courtesy of McClatchy Co.
casualty_category text
ACCIDENT died in an accident
DECLARED DEAD was declared dead
DIED OF WOUNDS died of wounds
HOMICIDE was a homicide victim
ILLNESS died of an illness
KILLED IN ACTION was killed in action
PRESUMED DEAD was presumed dead
SELF-INFLICTED died of self-inflicted causes