Skip to content

Instantly share code, notes, and snippets.

@mertonium
mertonium / embed_scripts.html
Created July 26, 2012 01:05
Embed scripts for Own The Vote
<!-- User-selected issues -->
<script data-electnext>
(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = 'http://electnext.com/widget/v2.js?key=dae517d92ae38ee6e8c48a23401f52a75a10b362';
var entry = document.getElementsByTagName('script')[0];
entry.parentNode.insertBefore(script, entry);
@mertonium
mertonium / appconfig.json
Created November 15, 2011 23:49
Config file for the Public Art Finder
{
"_id": "appconfig",
"doc_type": "config",
"city_name": "San Francisco",
"brought_to_you_by": "SF Arts Commision",
"google_analytics": "UA-XXXXXXXX-X"
}
@mertonium
mertonium / massupload.js
Created September 12, 2011 03:20
Node.js script that loads a CSV into a Couch. I used it to upload a stop_times.txt file from the Twin Cities GTFS feed.
var csv = require('csv'),
cradle = require('cradle');
var docs = [];
var successCount = 0,
failCount = 0,
curproc = 0,
throttle = 5;
[
{
"rmt":"276/0",
"latitude":"42.325384",
"longitude":"-71.075201",
"markername":"orange",
"opts":{
"title":"Roxbury Friendship Fence"
},
"text":"<div class=\"gmap-popup\"></div>"
@mertonium
mertonium / tcase_transform.js
Created August 16, 2011 17:46
Recline transform to Title Case
function(doc) {
doc['clean_address'] = doc['ALL_meSSed_uP_addr'].toLowerCase().replace(/\b[a-z]/g, function() { return arguments[0].toUpperCase();});
return doc;
}
@mertonium
mertonium / categoryexcluder.php
Created August 13, 2011 05:34
Copy of the default WordPress category widget - but you can pass a list of IDs to exclude. (Children categories will be excluded as well)
<?php
/*
Plugin Name: Category Excluder
Plugin URI: https://gist.github.com/1143511
Description: Added a way to pass a list of IDs to be excluded from the default Wordpress Categories widget.
Author: @mertonium
Version: 0.1
Author URI: http://mertonium.com
*/
/**
@mertonium
mertonium / philly311_scraper.rb
Created May 5, 2011 16:45
This script cycles through the Philly311 Knowledgebase, devouring FAQs.
#!/usr/bin/env ruby
###############################################################################
# Philly Open311 Knowledgebase Scraper
###############################################################################
require 'nokogiri'
require "net/http"
require "uri"
require "CSV"
@mertonium
mertonium / couchdb_replicator.php
Created April 19, 2011 02:50
Replicates all the dbs from one couch instance to another
<?php
// Config variables
define("FULL_OVERWRITE", true);
$source_couch = "http://yourcouchinstance.com";
$destination_couch = "http://yourothercouchinstance.com";
// Counter
$db_count = 0;
// Time check (we'll use this later)
@mertonium
mertonium / couchapp_mass_installer.php
Created April 19, 2011 02:48
Little php script to install the same couch app on a bunch of dbs in the same instance
<?php
// Configure control variables
$couch_url = "http://yourcouchinstance.com";
$path_to_couchapp = "/local_path_to/couchapp/";
// Counter
$db_count = 0;
// Time check (we'll use this later)
$start_ts = time();