Skip to content

Instantly share code, notes, and snippets.

# search markdown links and convert
# [do some cool thing](#fn-infer) => <a name="do-some-cool-thing"></a>[do some cool thing](#do-some-cool-thing)
def transform(line)
fn_name = 'fn-infer'
md_regex = %r{[^`]?\[(.*)\]\(##{fn_name}\)}
name_regex = %r{##{fn_name}}
a_regex = %r{\[}
p line
if (line =~ md_regex)
class AnyOldClass
attr_accessor :array_attr
def initialize
self.array_attr = []
this_is_fine
self.array_attr = []
this_also_fine
@eeeschwartz
eeeschwartz / gist:dd18e550ea8da5850c6f
Last active August 29, 2015 14:03
Batch geocode with throttling
// based on https://github.com/mapbox/geo-googledocs
// install the script and run the geocode once to set the api and key
// in the script window, set up a trigger in `Resources > Current Project triggers`
// run geocodeFromCache once a minute
//
// Global variables
var ss = SpreadsheetApp.getActiveSpreadsheet(),
sheet = ss.getActiveSheet(),
activeRange = ss.getActiveRange(),
settings = {};
@eeeschwartz
eeeschwartz / gist:353eacdf6cb3199c14ad
Last active August 29, 2015 14:05
Create a CKAN resource and continually update it by upserting
curl -v $CKAN_BASE_URL/api/action/resource_create \
--form name="Complaints" \
--form id="$resource_id" \
--form package_id="$package_id" \
--form format="csv" \
--form url="http://104.131.23.252/datastore/dump/$resource_id" \
-H "Authorization: $CKAN_API_KEY"
sleep 5
@eeeschwartz
eeeschwartz / createBuildingPermits.sh
Last active August 29, 2015 14:07
Configure datastore entry for code-enforcement CKAN resource
CKAN_BASE_URL=http://www.civicdata.com
CKAN_API_KEY=from-ckan-users-profile-page
resource_id='2691aff1-e555-48d3-9188-aebf1fa8323e'
fields='[{"id":"ID","type":"integer"},{"id":"Date","type":"date"},{"id":"Address","type":"text"},{"id":"Suite","type":"text"},{"id":"PermitType","type":"text"},{"id":"ConstructionCost","type":"integer"},{"id":"OwnerName","type":"text"},{"id":"Contractor","type":"text"},{"id":"parcelId","type":"text"},{"id":"lat","type":"float"},{"id":"lng","type":"float"}]'
curl -v $CKAN_BASE_URL/api/3/action/datastore_create \
-d '{"resource_id": "'$resource_id'", "fields": '$fields', "primary_key":"ID", "force":"true"}' \
-H "Authorization: $CKAN_API_KEY"
@eeeschwartz
eeeschwartz / gist:909a4cfab8e5b81fbb49
Created November 5, 2014 17:51
Quick and dirty esri REST to GeoJSON adapter
def format_leaf_collection(geo_json)
esri_formatted = JSON.parse(geo_json)
features = esri_formatted['features'].map do |feature|
properties = feature['attributes']
title = "Hello! Leaf collection status in your area is now '#{properties['Status']}'."
title += " Collection dates are #{properties['Dates']}" if properties['Dates']
{
type: "Feature",
id: properties['OBJECTID'],
@eeeschwartz
eeeschwartz / close_other_subaccount.sh
Last active August 29, 2015 14:08
Migrate number to citygram subaccount from another subaccount
other_subaccount_sid=
other_phone_sid=
citygram_subaccount_sid=
master_account_sid=
master_account_auth_token=
curl -XPOST "https://api.twilio.com/2010-04-01/Accounts/$other_subaccount_sid.json" \
-d "Status=closed" \
-u "$master_account_sid:$master_account_auth_token"
@eeeschwartz
eeeschwartz / main.js
Last active August 29, 2015 14:10
Greasemonkey script to annotate pocket
// ==UserScript==
// @name annotate
// @namespace annotate
// @include http://getpocket.com/a/read/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js
// @require http://assets.annotateit.org/annotator/v1.2.5/annotator-full.min.js
// @resource UI_CSS http://assets.annotateit.org/annotator/v1.2.5/annotator.min.css
// @grant GM_addStyle
// @grant GM_getResourceText
// @run-at document-start

Keybase proof

I hereby claim:

  • I am eeeschwartz on github.
  • I am eeeschwartz (https://keybase.io/eeeschwartz) on keybase.
  • I have a public key whose fingerprint is 8A1B DE14 101E 084D 91C4 482A 13C7 2B1F 64A2 23CD

To claim this, I am signing this object:

@eeeschwartz
eeeschwartz / bookmarklet.html
Last active August 29, 2015 14:13
Extract descriptions for a day in harvest
<a href="javascript:void(function () {
var jsCode = document.createElement('script');
jsCode.setAttribute('src', 'https://gist.githubusercontent.com/eeeschwartz/7cb6dc00d6a7cba70e1e/raw/extract_harvest_notes.js');
document.body.appendChild(jsCode);
}())">Extract Time</a>