Skip to content

Instantly share code, notes, and snippets.

import os
import csv
extra = [
'extra_column',
]
csvfile = open(os.path.join(options.output_directory,options.output_name+'.csv'), "wb")
writer = csv.writer(csvfile, delimiter=',')
header = ['id','Longitude','Latitude','path']
@jczaplew
jczaplew / array.map.js
Last active August 29, 2015 14:04
Array.map confusion
var data = [
{"name": null},
{"name": "a"},
{"name": "b"},
{"name": null},
{"name": null},
{"name": "c"}
];
var doesNotWork = data.map(function(d) {
@jczaplew
jczaplew / test.js
Last active August 29, 2015 14:03
JS Scopes
var test = {
a: function() {
console.log("function a");
},
b: function(a) {
console.log(a*a);
},
c: function() {
@graydon
graydon / country-bounding-boxes.py
Created April 23, 2014 00:03
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),

Abridged History of Tech & Related Reads

Way back in the day devseed did Drupal. We saw two main problems with it:

  • It tried to hit lots of different usecases and handled this by growing ever-larger instead of becoming modular
  • It was slow

We couldn't respond to #2 because it was the 'essential quality' of Drupal being built on PHP/MySQL and having 'make everything dynamic' as an essential property.

We responded to #1 with the 'smallcore idea': http://developmentseed.org/blog/2009/oct/28/smallcore-manifesto-help-us-build-better-teddy-bear/ This was semi-successful but was a hard sell because Drupal's module infrastructure was brittle and had the impossible goal of making programming-like tasks available as configuration.

@jczaplew
jczaplew / postgis2geojson.py
Last active March 23, 2023 19:08
A tool for extracting data from PostGIS into GeoJSON and TopoJSON. UPDATE: Added a dedicated repo for contributions - https://github.com/jczaplew/postgis2geojson
'''
A simple tool for exporting from a PostGIS table to GeoJSON and TopoJSON. Assumes Python 2.7+,
psycopg2, and TopoJSON are already installed and in your PATH.
Adapted from Bryan McBride's PHP implementation
(https://gist.github.com/bmcbride/1913855/)
by John Czaplewski | jczaplew@gmail.com | @JJCzaplewski
TODO:
- Add argument for SRS
@ranchodeluxe
ranchodeluxe / gist:6707360
Created September 25, 2013 22:57
Examples of Q.js promises with github API ( concurrent and synchronized ) to get started
#
# Sam, for some weird reason the promise.done()
# function wasn't able to work for me now,
# I'll figure it out later...for now were are using
# .then for concurrent requests...let's chat about this
#
#
# this is a standalone example
# so just copy to a file and load into your browser
@benbalter
benbalter / geojson-conversion.sh
Last active April 23, 2024 13:16
Bulk convert shapefiles to geojson using ogr2ogr
# Bulk convert shapefiles to geojson using ogr2ogr
# For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/
# Note: Assumes you're in a folder with one or more zip files containing shape files
# and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere)
#geojson conversion
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
}
@font-face {
font-family: 'EntypoRegular';
src: url('font/entypo.eot');
src: url('font/entypo.eot?#iefix') format('embedded-opentype'),
url('font/entypo.woff') format('woff'),
url('font/entypo.ttf') format('truetype'),
url('font/entypo.svg#EntypoRegular') format('svg');
font-weight: normal;
font-style: normal;
}
<?php
// STEP 1: read POST data
// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {