Skip to content

Instantly share code, notes, and snippets.

View shaneshifflett's full-sized avatar

Shane Shifflett shaneshifflett

View GitHub Profile
@shaneshifflett
shaneshifflett / gdoc_to_timeline_converter.rb
Created February 21, 2014 23:37
convert a google spreadsheet to a json file that can be read by timeline.js
task :jsonify_timeline => :environment do
require 'csv'
require 'json'
require 'open-uri'
def scrub(text)
if text.include? '--'
text = text.gsub(/--/, '—')
end
return text
@shaneshifflett
shaneshifflett / routes.geojson
Created September 1, 2015 03:53
sfmtaroutes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shaneshifflett
shaneshifflett / dump.txt
Created September 18, 2015 02:47
tracker investigation local
| results | BASE TABLE |
| resultview3 | VIEW |
| resultview_sub1 | BASE TABLE |
| resultview_sub2 | BASE TABLE |
| resultview_sub3 | BASE TABLE |
| resultview_sub3a | BASE TABLE |
RESULTSVIEW3 is confirmed to be a view
mysql> select * from trackertouse;
@shaneshifflett
shaneshifflett / change_mysql_engine_type.sh
Created February 16, 2011 20:27
Change the engine types of all tables in a mysql db from the command line
mysql -u<USERNAME> -p<PASSWORD> <DB_NAME> -e "show tables" | \
grep -v Tables_in|awk '{print "ALTER table",$1" ENGINE=InnoDB;"}'
@shaneshifflett
shaneshifflett / create_local_remote_branches.sh
Created February 17, 2011 06:07
Track all remote GIT branches locally
for remote in `git branch -r | grep -v master `;
do git checkout --track $remote ;
done;
@shaneshifflett
shaneshifflett / gen_path
Created July 14, 2011 00:05
Generate a document's path!
def generate_document_path(instance, filename):
return u"uploaded/documents/%s/%s/%s/%s" % (datetime.now().year,\
datetime.now().month, instance.slug, filename)
DOCUMENTS_PATH=generate_document_path
@shaneshifflett
shaneshifflett / ft_template.js
Created December 19, 2011 00:09
Fusion Tables GMAP Layer Template
<script type='text/javascript' src='http://media.baycitizen.org/js/jquery-1.4.2.min.js'></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" charset="utf-8">
var ft_id = INSERT_FUSION_TABLE_ID;
function Legend(controlDiv, name, title) {
// Set CSS for the control border
var controlUI = document.createElement('DIV');
controlUI.style.cursor = 'default';
controlUI.style.textAlign = 'left';
@shaneshifflett
shaneshifflett / rcv.py
Created December 18, 2011 22:32
rcv main loop
#keep track of the round number
round = 1
while next_round:
if round == 1:
#the world is our oyster, keep track of all the candidates still in play and their 1st,2nd,3rd place votes
avail_candidate_list = all_candidates
#all the ballots in the race
ballots = all_ballots
dropped_candidates = []
else:
@shaneshifflett
shaneshifflett / rm_files_despues_tres_dias.sh
Created February 1, 2012 06:21
delete files greater than 3 days old
find DIR_PATH -type f -mmin +4320 -delete
@shaneshifflett
shaneshifflett / maplegend.js
Last active October 6, 2015 14:18
Generate a legend for a map... updated to not require jquery
function MapLegendView(el, values, headerText, footerText){
/*
Class to dynamically generate a legend for a given map
el: containing element
values: array of key, value objects
ex: var legendItems = [
{text: 'text to display next to color', colorStr: 'color of legend item (hex preferred)'},
]
you'll want your container element and map to be contained in the same parent element
and to position the containing element to float over the map like so: