Skip to content

Instantly share code, notes, and snippets.

View jondavidjohn's full-sized avatar

Jonathan D. Johnson jondavidjohn

View GitHub Profile
@jondavidjohn
jondavidjohn / moveAnimate.js
Last active August 23, 2019 03:20
Animate any node to a new parent
/*
Animate any Node to a new parent node, retaining original object reference
Derived From : http://stackoverflow.com/a/5212193/555384
*/
function moveAnimate($element, $newParent){
var oldOffset, newOffset, $temp;
$element = $($element); //Allow passing in either a JQuery object or selector
@jondavidjohn
jondavidjohn / MY_Controller.php
Created July 8, 2011 19:56
Loading Multiple Databases with Codeigniter
<?php
/***
* filepath: application/core/MY_Controller.php
*/
//setup your base controller
class DB_Controller extends CI_Controller {
//declare them globally in your controller
protected $billing_db;
@jondavidjohn
jondavidjohn / keybase.md
Created September 1, 2016 16:48
keybase.md

Keybase proof

I hereby claim:

  • I am jondavidjohn on github.
  • I am jondavidjohn (https://keybase.io/jondavidjohn) on keybase.
  • I have a public key whose fingerprint is 4E8A 39AD 82DD 34CB 8CA3 EDA4 3A65 909D EF42 7B0C

To claim this, I am signing this object:

@jondavidjohn
jondavidjohn / extending_functions.js
Last active December 30, 2015 06:49
How to extend JavaScript functions
Array.prototype.join = (function(_super) {
// return our new `join()` function
return function() {
console.log("Hey, you called join!");
return _super.apply(this, arguments);
};
// Pass control back to the original join()
// by using .apply on `_super`
@jondavidjohn
jondavidjohn / gist:5114868
Created March 8, 2013 07:53
yum repolist all output
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.thelinuxfix.com
* epel: mirror.steadfast.net
* extras: centos.corenetworks.net
* updates: mirror.fdcservers.net
repo id repo name status
C6.0-base CentOS-6.0 - Base disabled
C6.0-centosplus CentOS-6.0 - CentOSPlus disabled
C6.0-contrib CentOS-6.0 - Contrib disabled
@jondavidjohn
jondavidjohn / social_debugger.php
Created November 21, 2012 20:36
Social Debugger WordPress Plugin
<?php
/*
Plugin Name: Social Debugger
Description: Plugin to print debugging information by appending ?social_debug=true to the url within the admin
Version: 0.1
Author: Crowd Favorite
Author URI: http://crowdfavorite.com/
*/
@jondavidjohn
jondavidjohn / gist:3107336
Created July 13, 2012 20:42
Rewrite Wordpress uploads to lorempixel (Nginx)
# if you're requesting anything within '/wp-content/uploads' or '/files'
location ~ (/wp-content/uploads|files) {
# and it doesn't exist
if (!-e $document_root$uri) {
# try and match the dimensions from the filename
rewrite (\d+)(?:x)(\d+)(?:\.(?:[^\.]+)$) http://lorempixel.com/$1/$2 break;
# otherwise just use a default size
rewrite .* http://lorempixel.com/800/600 break;
}
}
@jondavidjohn
jondavidjohn / pyshell.py
Created June 13, 2012 21:02
Python shell utility start
import argparse
argparser = argparse.ArgumentParser(description="This is a Description of the Utility")
argparser.add_argument('--foo', '-f', help='help text for --foo argument', default="World")
def main():
"""Script Entry Point"""
print "Hello %s!" % args.foo
@jondavidjohn
jondavidjohn / deploy.rb
Created March 8, 2012 18:00 — forked from ianmurrays/deploy.rb
Runs test locally before deploying on capistrano.
set :test_log, "logs/capistrano.test.log"
namespace :deploy do
before 'deploy:update_code' do
puts "--> Running tests, please wait ..."
unless system "bundle exec rake > #{test_log} 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat #{test_log}` to see what went wrong."
exit
else
puts "--> Tests passed"
@jondavidjohn
jondavidjohn / AppDAL.js
Created February 29, 2012 04:30
A Simple AJAX DAL for use in a web app accessing a RESTful JSON API endpoints
var AppDAL = (function() {
var _BASE_URL = "http://"+ window.location.host +"/api/";
var _request = function(resource_uri, method, s_cback, e_cback, data) {
data = data || null;
var resource_url = _BASE_URL + resource_uri;
var xhr = new window.XMLHttpRequest();
xhr.onreadystatechange = function () {