Skip to content

Instantly share code, notes, and snippets.

@iwek
iwek / find-in-json.js
Created October 20, 2012 21:43
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@dhcole
dhcole / form.js
Created November 3, 2012 19:31
Submit data from html form to Google Doc Spreadsheet. Uses Bootstrap components for auto-complete region list and date selection.
$(function(){
var formUrl = '/* ex: https://docs.google.com/a/developmentseed.org/spreadsheet/formResponse?formkey=... */';
// Set up map
var m = mapbox.map('map').addLayer(mapbox.layer().id(' /* mapbox-account.id */ '));
// Set up map ui features with point selector
var ui = mapbox.ui().map(m).auto().pointselector(function(d) {
// Remove all points except the most recent
@springmeyer
springmeyer / bbox2csv.py
Created December 14, 2012 21:20
Convert bbox to polygon and encode as geo csv for TileMill
#!/usr/bin/env python
'''
Usage:
# edit the script below "main" then:
python bbox2csv.py > bounds.csv
'''
def bbox2wkt(minx, miny, maxx, maxy):
@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"
}
@mapsam
mapsam / README.md
Last active June 18, 2023 20:20
D3: Queue.js

A look at Queue.js and how you can load multiple files before running the rest of the code. Simple visualization of populated places in the USA. Files loaded:

  • US States - topojson
  • Populated Places - geojson
@d3noob
d3noob / index.html
Last active November 27, 2021 16:08
Leaflet.draw plugin with options set.
<!DOCTYPE html>
<html>
<head>
<title>Leaflet.draw Plugin</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
<link
@kalxas
kalxas / data-gov-csw-howto.rst
Last active October 25, 2022 14:23
Data.gov CSW HowTo
@kalxas
kalxas / README.txt
Last active September 14, 2021 10:19
Data.gov CSW HowTo v2.0
Based on copy of https://gist.github.com/kalxas/5ab6237b4163b0fdc930 on 20 June 2014 12:27 UTC
@andrewxhill
andrewxhill / class01.md
Last active August 29, 2015 14:05
Maps, Lies & Storytelling | Class 1
@danielfdsilva
danielfdsilva / index.js
Last active August 29, 2015 14:26
DSO blog pagination
DSO.Views = DSO.Views || {};
(function() {
DSO.Views.BlogList = function(opts) {
this.container = opts.container;
var _posts = [];
var _self = this;
var _template = JST['card-list.ejs'];
var _perPage = 9;