Skip to content

Instantly share code, notes, and snippets.

View mojowen's full-sized avatar
🍕
🤔

Scott Duncombe mojowen

🍕
🤔
View GitHub Profile
@mojowen
mojowen / template_example.js
Last active July 20, 2016 13:42
Prep Salsa Template for Facebook Sharing
<?
// Default Values
var title = 'Welcome'; // What it should say on a page that it can't look up the information
var url = 'http://yoururl.org'; // Your base URL
var template = '00000'; //Your Template Key
var org = 'Your Organization'; //Your Org's Name
var chapter = '9999'; //If this is a chaptered page
var description = "Our slogan"; // Default description
var img = "https://www.google.com/images/srpr/logo3w.png"; //The default image
@mojowen
mojowen / split.js
Created May 25, 2012 06:59
Splitting a name field into first / last
jQuery(document).on(
'submit',
'#id',
function(e) {
var $this = jQuery(this),
name = jQuery('#name',$this).val().split(' '),
first_name = name.length > 1 ? name.shift() : name[0],
last_name = name.length > 0 ? name.join(' ') : '';
jQuery('#fname',$this).val(first_name).nextAll('#lname').val(last_name)
setTimeout(function() { jQuery('input',$this).not('[type=sumbit]').val('') }, 3)
@mojowen
mojowen / jquery.thermometer.js
Created June 14, 2012 18:12
jQuery plugin for making a div into a thermometer
(function($){
$.fn.thermometer = function(fill,total,thing) {
function addCommas(nStr) { // from http://www.mredkj.com/javascript/numberFormat.html
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) x1 = x1.replace(rgx, '$1' + ',' + '$2');
return x1 + x2;
@mojowen
mojowen / remove_word.php
Created June 20, 2012 21:45
Add Filter for Microsoft Word Style elements
<?php
add_filter('the_content', 'remove_microsoft_word');
function remove_microsoft_word($content) {
$find = strpos($content,"<style type=\"text/css\">
<!--
/* Font Definitions */");
while( $find ) {
$end = strpos($content,"
@mojowen
mojowen / gist:3410080
Created August 21, 2012 00:51
Facebook / Tumblr / Twitter link-to-share configurations
var img = '', // Le image you're linking to
link = '', // Le page you're linkg to
message = '' // Le message you want to share ( Twitter / Tumblr only )
/**
NOTE: More customization can be done fore facebook whatever page 'link' is point out on, see https://developers.facebook.com/tools/debug on how to ge this working using OG tags
**/
var facebook = 'http://facebook.com/sharer/sharer.php?u='+escape( link );
@mojowen
mojowen / gist:3444732
Created August 24, 2012 02:09
better jQuery autoselect
/*! jQuery UI - v1.8.23 - 2012-08-15
* https://github.com/jquery/jquery-ui
* Includes: jquery.ui.core.js
* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
(function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.23",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:3
@mojowen
mojowen / gist:3825205
Created October 3, 2012 05:31
Scott's voterfile importing script
#! /usr/bin/ruby
require 'rubygems'
require 'sqlite3'
files = Dir["/Volumes/BALLOT/extracted/*.txt"]
db = SQLite3::Database.new( "voterfile.db" )
@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.
**/
@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 / 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