Skip to content

Instantly share code, notes, and snippets.

@drewda
drewda / gist:1257765
Created October 2, 2011 18:51
selectively changing d3 elements when Backbone model changes
# note that this function is called whenever a GeoPoint model changes
# Backbone will pass in geo_point, which refers to the changed model
# @geo_points refers to the entire collection of GeoPoint models
# update the bound data
geo_points = @geo_points.reject (gp) => gp.get('markedForDelete')
geoPointMarkers = d3.select('#geo-point-layer').selectAll("g")
.data geo_points, (d) =>
d.cid
@drewda
drewda / gist:1257835
Created October 2, 2011 19:41
using d3 to draw line segments on a Polymaps map
class App.Views.SegmentLayer extends Backbone.View
initialize: ->
@segmentDefaultStrokeWidth = @options.segmentDefaultStrokeWidth
@segmentSelectedStrokeWidth = @options.segmentSelectedStrokeWidth
@segments = @options.segments
@segments.bind 'reset', @change, this
@segments.bind 'change', @change, this
@segments.bind 'add', @change, this
@drewda
drewda / gist:1299198
Created October 19, 2011 18:23
Jenks natural breaks classification
# code from http://danieljlewis.org/files/2010/06/Jenks.pdf
# described at http://danieljlewis.org/2010/06/07/jenks-natural-breaks-algorithm-in-python/
def getJenksBreaks( dataList, numClass ):
dataList.sort()
mat1 = []
for i in range(0,len(dataList)+1):
temp = []
for j in range(0,numClass+1):
temp.append(0)
@drewda
drewda / sign_in.html
Created December 7, 2011 19:28
sign in form using Bootstrap
<div class="container">
<div class="row">
<div class="span4 columns">
&nbsp;
</div>
<div class="span8 columns">
<form accept-charset="UTF-8" action="/users/sign_in" class="user_new" id=
"user_new" method="post" name="user_new">
<div style="margin:0;padding:0;display:inline">
@drewda
drewda / gist:5752218
Created June 10, 2013 20:56
OSM groups: an initial draft of a migration
create_table :groups do |t|
t.string :name
t.string :slug
t.text :description
t.decimal :nw_longitude
t.decimal :nw_latitude
t.decimal :se_longitude
t.decimal :se_latitude
t.integer :owner_user_id
t.timestamps
@drewda
drewda / index.html
Created August 8, 2013 21:23
via:geojson.io
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.marker-properties {
border-collapse:collapse;
@drewda
drewda / map.geojson
Created August 9, 2013 17:19
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drewda
drewda / map.geojson
Created August 12, 2013 15:48
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drewda
drewda / map.geojson
Created August 14, 2013 15:18
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drewda
drewda / map.geojson
Created August 16, 2013 21:43
via:geojson.io
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.