Skip to content

Instantly share code, notes, and snippets.

@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:
@daguar
daguar / is-it-cash-only.md
Last active August 29, 2015 13:57
An approach for "is it cash only?"

Super-minimal version approach:

  1. On page load, get the location of the user (latitude + longitude) using HTML5 geolocation. This is done using Javascript, as in this example: http://www.w3schools.com/html/html5_geolocation.asp

  2. Show user a simple form with just a text box and button ("Search"). Then, the user enters the name of the restaurant they're looking for into the box and clicks the button.

  3. The form submits the user's text as well as the latitude/longitude from step 1 (as hidden fields in a POST request), this goes to a URL you've coded on the backend.

  4. On the backend, the web app feeds the text and lat/long into a Yelp API search ( http://www.yelp.com/developers/documentation/v2/search_api#searchGC ) and then grabs the first result, and shows it to the user with whether "accepts credit cards" is true or false [see note below.]

<Response>
<Say>What's up dog.</Say>
</Response>
@daguar
daguar / a-moral-inquiry.md
Last active August 29, 2015 13:58
"A moral inquiry" (George Saunders, excerpt from Tent City USA)

A Moral Inquiry

Retreating down G Street, the PR considered the white girl with red hair. Was she being held against her will? Likely she was a junkie, in some sort of long-term relationship with the tall man, who served as her pimp. Who had she been before she was the white girl with red hair? The PR reminded himself that the white girl with red hair had been a whore in that tent long before he arrived and would be a whore in that tent long after he left. All of these people had been living thus before he arrived and would continue living thus long after he went home. Anything he could do for them would only comprise a small push in a positive direction before the tremendous momentum of their negative tendencies reasserted itself. The PR was put in mind of a single shot from a gun being fired into a massive orbiting planet.

Still, what would happen if he decided to abandon the Study and commit all of his resources to the sole purpose of extracting the white girl with red hair from that tent and getting

#!/usr/bin/env ruby
#
require 'httparty'
require 'json'
require 'pry'
by_categories = Hash.new { |h,k| h[k] = Array.new }
page = 1
total = 0
@daguar
daguar / phaxio-multiple-files-with-curl.sh
Last active August 29, 2015 14:00
Phaxio example: sending a fax of multiple files with curl
curl https://api.phaxio.com/v1/send \
-F 'to=4141234567' \
-F 'filename[]=@/path/to/file1.png' \
-F 'filename[]=@/path/to/file2.png' \
-F 'api_key=API_KEY' \
-F 'api_secret=API_SECRET'
var ArcGIS = require('terraformer-arcgis-parser');
var geojson = ArcGIS.parse({"attributes":{"OBJECTID":1,"UNITNAME":"Admiral William Standley SRA","MgmtStat":"Park Unit or Property"},"geometry":{"rings":[[[-13761597.2359,4814839.6358999982],[-13761525.5836,4814901.4843000025],[-13761000.2678,4814910.8694999963],[-13760905.007300001,4814912.5741999969],[-13760565.695700001,4814918.6353999972],[-13760622.784499999,4814872.6111000031],[-13760668.9476,4814793.0847000033],[-13760674.622099999,4814764.3650000021],[-13760725.478700001,4814669.2823000029],[-13760695.670499999,4814646.4248000011],[-13760706.396400001,4814619.0486999974],[-13760804.101199999,4814662.186999999],[-13760873.4585,4814656.6824999973],[-13760917.006000001,4814585.2906000018],[-13760882.4077,4814508.256099999],[-13760907.517099999,4814462.2704999968],[-13761209.6734,4814565.1185000017],[-13761361.928300001,4814659.2875000015],[-13761409.311099999,4814656.9126999974],[-13761485.3971,4814602.7092999965],[-13761554.1358,4814600.0754999965],[-1