Skip to content

Instantly share code, notes, and snippets.

View mojowen's full-sized avatar
🍕
🤔

Scott Duncombe mojowen

🍕
🤔
View GitHub Profile
@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 / 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 / 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 / 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 / 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:3961783
Created October 26, 2012 21:51
Ballot Data Models
[
{ // Example of a Candidate Race
// The name of the particular race or ballot measure
"contest": "US House",
// The type, can be Federal, State, County, Other, Ballot_Statewide (catch-all for ballot measures), User_Candidate, User_Measure (both are user-generated content)
"contest_type": "Federal",
// Name of the race - auto generated for candidates
@mojowen
mojowen / gist:3910037
Created October 18, 2012 05:35
Embed The Ballot
<iframe src="http://theballot.org/?iframe=500" width="500" height="1000" style="width: 500px; height: 1000px; overflow-y: auto; overflow-x: hidden; border: none;" scrolling="yes" ></iframe>
@mojowen
mojowen / fuckgooglespreadsheetapi.js
Created October 17, 2012 18:53
Functions for Retrieving Google Spreadsheet Data via JSONP
/**
API DOC: https://developers.google.com/google-apps/spreadsheets/
Some things to remember:
- Get the Sheet ID "gid" by using the https://developers.google.com/google-apps/spreadsheets/#retrieving_information_about_worksheets
- Google API cannot handle spaces in it's SQL queries - make sure to wrap queries in " (not ')
- Column A is a "label" column - cannot query on it. Hide it
- Google returns results row contents a comma separated cell - googleParse function can convert into an object - including cell contents with commas. Cells with ': ' (including the space) may break it.
**/