Skip to content

Instantly share code, notes, and snippets.

View mojowen's full-sized avatar
🍕
🤔

Scott Duncombe mojowen

🍕
🤔
View GitHub Profile
@mojowen
mojowen / gist:4022522
Created November 6, 2012 04:21
Geolocate an array of addresses
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
var addresses = [ ], // Addresses you want matched
fixed = [ ], // Where they'll get put eventually
g = new google.maps.Geocoder
function newAddress(address) {
var theaddress = address || addresses.shift()
function newAddress(address) {
@mojowen
mojowen / gist:4535115
Created January 15, 2013 01:12
Importing data from Salsa's export system - using a csvImport function
// Use a simple jQuery GET request to get the data from export and return it to myQuery variable
$.get(
'http://hq-salsa.wiredforchange.com/dia/hq/export.jsp?',
{ 'query_KEY': 196951, 'type':'csv','include':'supporter_KEY,First_Name,Last_Name,Email'},
function(result) { myQuery = csvImport( result ); }
)
// Here's a function to parse the CSV and return the results as objects - using the first row as a name sequence
function csvImport( blob ) {
@mojowen
mojowen / shell
Last active December 12, 2015 03:38
Running @facebook/phpsh with WordPress functions
#!/bin/bash
# First install https://github.com/facebook/phpsh
# And ctags https://github.com/mxcl/homebrew/blob/master/Library/Formula/ctags.rb
# From http://vocecommunications.com/blog/2010/12/how-to-setup-an-interactive-wordpress-shell/
if [ ! -f ./.wp-shell.php ];
then
echo '<?php include_once("wp-load.php"); include_once("wp-admin/includes/admin.php"); ?>' > ./.wp-shell.php
fi
@mojowen
mojowen / functions.php
Last active December 12, 2015 08:18
Adding custom javascript to a WordPress Theme. These would both go in your theme or child-theme's directory.
<?php
function add_my_script() {
wp_enqueue_script(
'my-script', // The name of your script
get_stylesheet_directory_uri().'/my-script.js', // Your script
array('jquery') // Dependencies - so it knows to put your script AFTER jQuery
);
}
add_action('wp_enqueue_scripts', 'add_my_script'); // The action that will add your script
@mojowen
mojowen / index.html
Last active December 13, 2015 18:18 — forked from darwin/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<body>
<scene id="scene1">
<label t="translate(0,346)">
<tspan x="0" y="0em">Comix Sample</tspan>
</label>
<actor t="translate(150,49)" pose="-11,9|-5,117|-11,99|-11,89|-11,79|-11,59|-16,34|-21,9|-6,34|-1,9|-18,79|-18,59|-6,79|-1,59">
@mojowen
mojowen / gist:6313088
Last active December 21, 2015 13:29 — forked from recamshak/gist:4124194
setting up graphit / statsd on webfaction
# this script will install whisper, carbon and graphite-web on the current directory
# Modified to reflect current WebFaction python best practices
mkdir -p $HOME/lib/python2.7
# Follow steps here http://theneum.com/blog/webfaction-virtualenv-how-to/
easy_install-2.7 pip
pip-2.7 install virtualenvwrapper
mkdir ~/.virtualenvs
@mojowen
mojowen / tinyxhr.js
Last active March 15, 2016 18:25 — forked from shimondoodkin/tinyxhr.js
A really really really simple AJAX method - forked from the original built by Shimon Doodkin
/* based off of tinyxhr by Shimon Doodkin - license: public doamin - https://gist.github.com/4706967
Added ontop of Simon's code:
- Serialization of the object
- Moved some arguments to line up with jQuery( url, data, callback )
- Will attempt to parse JSON from the response if it's valid JSON
- Added a tinyPost and tinyGet method
Some other things that'd be good:
- Seprate error callback for failed responses
@mojowen
mojowen / readme.md
Last active December 25, 2015 07:29
Target only select Congressional Members using Sunlight API Foundation's API.

Target Congressional Members

Use these handy functions to find congessional targets by zip code. AND optionally filter those members by setting:

  • A target chamber - e.g. House or Senate
  • A target party - e.g. D or R
  • A list of target senators - either an array of names ["Ted Cruz","Mitch McConnell"], twitter handles ["SenTedCruz","McConnellPress"], or Bioguide IDs ["B001282","C001098"]

Will return an empty Sunglight API Call { results: [ ], count: 0 } if there are no results after the filter.