Skip to content

Instantly share code, notes, and snippets.

View westonwatson's full-sized avatar

Weston Watson westonwatson

View GitHub Profile
@westonwatson
westonwatson / effect_r.js
Created July 30, 2011 19:57
effectR - a small jquery effects plugin for simple animation.
/**
* @author wwatson
*
* the semicolon at the beginning is there on purpose in order to protect the
* integrity of the script when mixed with incomplete objects, arrays, etc.
*
*/
;(function($) {
@westonwatson
westonwatson / getRequests
Created January 23, 2012 17:08
URI Parsing in CodeIgniter
//Codeigniter, a clever way to get data out of the Request URI.
private function getRequests(){
//get the default object
$CI =& get_instance();
//declare an array of request and add add basic page info
$requestArray = array();
$requests = $CI->uri->segment_array();
foreach ($requests as $request)
{
@westonwatson
westonwatson / gist:1830818
Created February 14, 2012 21:52
grab_leads method, grabs lead counts of all account under a reseller organized by service
//searchin' for what?
$id = $_REQUEST['id'];
//no layout, via AJAX
$this->render_layout=false;
//No id to request
if (!$id) exit;
//leads by service
$leads_by_service = array();
//find reseller by id
$reseller = new Reseller;
@westonwatson
westonwatson / gist:1831022
Created February 14, 2012 22:20
javascript method to grab_leads for resellers
<script language="javascript" type="text/javascript">
jQuery.noConflict();
function fill_leads(reseller_id){
jQuery.getJSON('/resellers/grab_leads/' + reseller_id, function(data) {
jQuery.each(data, function(key, val) {
jQuery('#service_leads_' + reseller_id + '_' + key).html(val);
});
});
function display_object($object,$parameters,$action=null){
//this is all a bit redundant, on purpose i guess...
$partial[name] = strtolower( get_class($object) ) . strtolower($action?"_{$action}":"");
//view to render
$partial[filename] = "{$partial_name}.phtml";
//path to check with file_exists
$partial[path] = TRAX_ROOT . "/app/views/includes/" . $partial[filename];
//path within app to use with render_partial
$partial[relative] = "includes/" . $partial[filename];
@westonwatson
westonwatson / derp.serialize.js
Created September 13, 2012 20:29
DERP, Serialize JSON objects for use in URI's
var DERP = {
serialize : function(a1){t=[];for(x in a1)t.push(x+"="+encodeURI(a1[x]));return t.join("&");}
};
@westonwatson
westonwatson / gist:3757211
Created September 20, 2012 17:27
Polyfill for Object.create();
if (!Object.create) {Object.create = function (o) {if (arguments.length > 1) {throw new Error('Object.create implementation only accepts the first parameter.');}function F() {}F.prototype = o;return new F();};}
@westonwatson
westonwatson / db.php
Created September 23, 2012 08:29
SIMPLE JSON FLAT FILE DATABASE
<?php
if ($_GET['id']) push_out( read_record($_GET['id']));
if ($_POST){
if (is_numeric($_POST['id'])){
//update record
push_out(json_encode(save_record($_POST)));
}elseif(is_numeric($_POST['_delete_record'])){
@westonwatson
westonwatson / sort-table.js
Created October 1, 2012 13:31
Sortable Tables With Javascript
/*
Table sorting script by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
Based on a script from http://www.kryogenix.org/code/browser/sorttable/. <-- this script didn't offer dynamic sorting!
Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk.
Version 1.5.7
* 8-22-2012 Modified for LV
@westonwatson
westonwatson / css_lightbox.html
Created October 18, 2012 18:45
Pure CSS Lightbox Solution.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>LIGHTBOX EXAMPLE</title>
<style>
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;