Skip to content

Instantly share code, notes, and snippets.

View mojowen's full-sized avatar
🍕
🤔

Scott Duncombe mojowen

🍕
🤔
View GitHub Profile
@mojowen
mojowen / functions.php
Last active August 29, 2015 14:19
Redirect WordPress to Subfolder from Non-Base Domain
<?php
// Redirects brooklynkindershule.org to campkinderland.org/shule and respects sub paths
function custom_rewrite_basic() {
if( $_SERVER['SERVER_NAME'] == 'brooklynkindershule.org') {
$location = 'http://campkinderland.org/shule';
if( $_SERVER['REQUEST_URI'] && $_SERVER['REQUEST_URI'] != '/shule' ) $location .= '/'.$_SERVER['REQUEST_URI'];
header( 'Location: '.$location );
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say>Hello World</Say>
<Play>https://api.twilio.com/Cowbell.mp3</Play>
</Response>
@mojowen
mojowen / .aliases
Last active June 21, 2020 10:11
My dotfiles
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# Shortcuts
alias d="cd ~/desktop"
@mojowen
mojowen / gif.sh
Last active August 29, 2015 14:04
Convert jpegs to gif and created animated gif
find . -iname "*.jpg" -type f -exec sh -c 'sips --resampleHeight 500 -s format gif "$0" --out "${0%.JPG}.gif"' {} \;
# http://www.lcdf.org/gifsicle/
gifsicle --delay=30 --loop *.gif > anim.gif
@mojowen
mojowen / index.html
Last active August 29, 2015 14:04 — forked from enjalot/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<style type="text/css">
body {
background: #333;
}
@mojowen
mojowen / fb_api_wrapper.php
Last active December 28, 2015 01:19
An example of a PHP API Interface
<?php
$url = $_POST['url'];
$url_count = get_fb_info( $url );
echo json_encode( $url_count );
function get_fb_info( $site_name ) {
$query = "https://api.facebook.com/method/fql.query?query=select url,share_count,like_count,comment_count from link_stat where url = ";
@mojowen
mojowen / euler_problem.js
Created October 25, 2013 19:16
A solution to a problem
data = [
[75],
[95, 64],
[17, 47, 82],
[18, 35, 87, 10],
[20, 04, 82, 47, 65],
[19, 01, 23, 75, 03, 34],
[88, 02, 77, 73, 07, 63, 67],
[99, 65, 04, 28, 06, 16, 70, 92],
[41, 41, 26, 56, 83, 40, 80, 70, 33],
@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.

@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 / 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