Skip to content

Instantly share code, notes, and snippets.

@bycoffe
bycoffe / index.html
Created June 19, 2014 13:56
Sort & animate divs
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.resort {
padding: 10px;
border: 1px solid black;
background: #ccc;
@bycoffe
bycoffe / polls.go
Created November 18, 2014 19:50
Get the first 50 pages of polls from the Pollster database
package main
import (
"fmt"
"github.com/bycoffe/pollster"
"strconv"
)
func getPolls(pages []string) []pollster.Poll {
ch := make(chan []pollster.Poll)
pager less -niSFX
"""
A small Django app I built last year that looked for people on Twitter saying they were sick.
An example of using Twitter search.
"""
# models.py
from django.contrib.gis.db import models
"""
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.
"""
python -c 'import sys, csv
for row in csv.reader(sys.stdin):
print row[1]' < filename.csv
@bycoffe
bycoffe / csvcut
Created September 14, 2009 18:19 — forked from JoeGermuska/csvcut
#!/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
Usage:
csvcut foobar.csv
@bycoffe
bycoffe / count
Created September 25, 2009 13:40
Count the number of occurrences of each line in a file.
#!/bin/bash
# Count the number of occurrences of each line in a file.
#
# Example:
#
# test.txt:
# A
# A
# B
#!/usr/bin/env python
"""
Copyright (c) 2009, Aaron Bycoffe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@bycoffe
bycoffe / testcsv.csv
Created October 23, 2009 16:49
Test CSV file for csvtosqlite
City Latitude Longitude
Autauga, AL 32.5791817 -86.4996546
Baldwin, AL 30.6010744 -87.7763333
Barbour, AL 31.8172896 -85.354965
Bibb, AL 32.9562798 -87.1422895
Blount, AL 34.0145152 -86.4996546
Bullock, AL 32.0573536 -85.7256372
Butler, AL 32.091673 -88.221233
Calhoun, AL 33.7701576 -85.80766
Chambers, AL 32.9028048 -85.354965
@bycoffe
bycoffe / csvtosqlite.py
Created October 23, 2009 16:52
Creates a sqlite database and table from a CSV file for easier querying
"""
Copyright (c) 2009, Aaron Bycoffe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright