Skip to content

Instantly share code, notes, and snippets.

@daguar
daguar / gist:3298859
Created August 8, 2012 21:17
Falling for Ruby: "Holy Crap!" Edition
=begin
Every day I use Ruby I see more and more why people become evangelists.
Take today: I was toying with evaluating different approaches to match two
data sources (API results and a giant local database), and I realized,
"wait! this is a job for yield!"
So I wrote a pleasant little module with a function that:
- Takes a block which attempts to match an API object to rows in the
@daguar
daguar / gist:5368778
Last active September 18, 2018 03:39
An alternative approach to installing Drake on Mac OS X
# I bumped into some problems installing Drake ( https://github.com/Factual/drake ) on OSX, so here's what I did:
# 1. Follow the installation instructions here up through "Run Drake from the uberjar":
# https://github.com/Factual/drake/blob/251a22b27b5ded1fff522f39f06d3e06c77daf74/README.md
# (This is the specific README version I used.)
# 2. Move the 'drake' directory to Applications:
mv drake/ ~/Applications/
# 3. Install Drip ( https://github.com/flatland/drip ) for speedier load time.
@daguar
daguar / gist:5640767
Created May 24, 2013 01:43
Zillow neighborhood data exploration in Ruby
require 'pry'
require 'rubillow'
Rubillow.configure do |config|
config.zwsid = ENV["ZILLOW_KEY"]
end
hoods = Rubillow::Neighborhood.region_children({ :state => 'IN', :city => 'South Bend', :childtype => 'neighborhood' })
# Hash method -- not using
#hood_region_ids = Hash.new
@daguar
daguar / gist:6188849
Created August 8, 2013 21:18
My git aliases. Put this in ~/.gitconfig
[alias]
amend = commit --amend -a
br = branch
co = checkout
ds = diff --staged
di = diff
fetchall = fetch -v --all
log-fancy = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative
log-me = !UN=$(git config user.name)&& git log --author="\"$UN\"" --pretty=format:'%h %cd %s' --date=short
log-nice = log --graph --decorate --pretty=oneline --abbrev-commit
@daguar
daguar / gist:7932437
Last active December 31, 2015 04:09
Web mapping notes for CodigoCDMX
@daguar
daguar / gist:8389275
Created January 12, 2014 19:29
D3 OOPy quantizer for 1-5 range
// Quantizing data into buckets
function Quantizer(data_array) {
min = d3.min(data)
max = d3.max(data)
this.quantizeNumber = d3.scale.quantize()
.domain([min,max])
.range([1,5]) // Start with only mapping on 1-5 color scale
}
@daguar
daguar / why-no-ruby-in-government-summary-sarah-allen-012714.md
Last active August 29, 2015 13:55
Summary of Sarah Allen's talk ("Why no Ruby in government?") at SF Ruby 1/27/14

"Why no Ruby in government?"

Talk @ SF Ruby, 1/27/14

Sarah's slides are available here.

The speaker was Sarah Allen (ultrasaurus), a returning Presidential Innovation Fellow (PIF) who was at the Smithsonian Institution. Sarah covered a lot about her experiences as a PIF generally, but also had one big point about the technology/government divide:

In her view, a large majority of government web projects are fundamentally CMS systems with a few customizations specific to the project. When she got to DC, she didn't want to use PHP, but -- precisely because Ruby doesn't have any well-supported, "clear winner" CMSs -- she couldn't justify rebuilding a lot of the functionality that Wordpress or Drupal give you out-of-the-box.

While there are a bunch of Ruby CMSs ( https://www.ruby-toolbox.com/categories/content_management_systems ) there's nothing at the point of being a clear winner with a strong commun

@daguar
daguar / shapefile-to-webmap.html
Created February 8, 2014 22:06
Pipe an ESRI shapefile through web ogr2ogr and then to GeoJSON.io (DEFUNCT -- see comment)
<!-- Drag and drop based from @remy's HTML5 demos: https://github.com/remy/html5demos -->
<title>File API</title>
<style>
#holder { border: 10px dashed #ccc; width: 300px; height: 300px; margin: 20px auto;}
#holder.hover { border: 10px dashed #333; }
</style>
<article>
@daguar
daguar / bicycle_thefts.geojson
Created February 9, 2014 21:22
GeoJSON output from ogr2ogr of Philly bike theft data shapefile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@daguar
daguar / ruby-python-js-comparison.md
Last active August 29, 2015 13:56
Comparing the very basics of Ruby, Python, and Javascript syntax with a simple example

Goal

Iterate over an array of numbers and print each value

Python

array = [1,2,3,4]

for number in array: