Skip to content

Instantly share code, notes, and snippets.

View dandye's full-sized avatar

DanDye dandye

View GitHub Profile
@dandye
dandye / quick python script to test mapnik rendering of gdal datasource.sh
Created July 30, 2012 15:33
quick python script to test mapnik rendering of gdal datasource
[ec2-user@ip-10-195-227-243 ~]$ python
Python 2.7.3 (default, Apr 30 2012, 21:18:10)
[GCC 4.7.0 20120416 (Red Hat 4.7.0-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mapnik import *
m = Map(400,500,'+proj=latlong +datum=WGS84')
m.background = Color('transparent')
s = Style()
r = Rule()
@dandye
dandye / fipsToState.json
Created August 22, 2012 18:04 — forked from wavded/fipsToState.json
State FIPS JSON
{
"01": "Alabama",
"02": "Alaska",
"04": "Arizona",
"05": "Arkansas",
"06": "California",
"08": "Colorado",
"09": "Connecticut",
"10": "Delaware",
"11": "District of Columbia",
@dandye
dandye / countyFIPS.js
Created August 22, 2012 18:04 — forked from myersjustinc/countyFIPS.js
Mappings between five-digit county FIPS codes and their corresponding counties
// Source: http://www.census.gov/geo/www/ansi/countylookup.html
var countyToFIPS = {
'Alabama': {
'Autauga County': '01001',
'Baldwin County': '01003',
'Barbour County': '01005',
'Bibb County': '01007',
'Blount County': '01009',
'Bullock County': '01011',
@dandye
dandye / gist:5217288
Created March 21, 2013 22:15
Plotting multiple Bar Charts with R
```{r}
library(ggplot2)
# Multiple plot function
#
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
@dandye
dandye / gist:5223948
Last active December 15, 2015 07:29
global can be declared anywhere in function
def make_global():
global x
x = 1
def some_func():
print x,
def main():
make_global()
some_func()
@dandye
dandye / gist:5268392
Created March 29, 2013 02:45
Generator practice
def roman():
i = ""
for cnt in range(1,30):
if cnt != 1 and cnt % 10 == 0:
i = i[:-5] + "x"
elif cnt != 1 and cnt % 5 == 0:
i = i[:-4] + "v"
else:
i += "i"
print cnt, i
@dandye
dandye / gist:5268469
Created March 29, 2013 03:02
Decorator practice
def make_bold(fn):
def bold():
return "<b>{}</b>".format(fn())
return bold
def make_italic(fn):
def italic():
return "<i>{}</i>".format(fn())
return italic
@dandye
dandye / gist:8029893
Created December 18, 2013 21:10
AVG() ignores NULL values
CREATE TABLE #LocalTempTable(
somenum INT);
INSERT into #LocalTempTable values (2);
INSERT into #LocalTempTable values (4);
INSERT into #LocalTempTable values (6);
select * from #LocalTempTable;
select avg(somenum)
@dandye
dandye / gist:8699831
Created January 29, 2014 23:57
Next PyBulls Meeting
{
"metadata": {
"name": "Next PyBulls Meeting"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@dandye
dandye / gist:8699875
Last active August 29, 2015 13:55
Next Python Meeting
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{