Skip to content

Instantly share code, notes, and snippets.

View chadhutchins's full-sized avatar

Chad Hutchins chadhutchins

View GitHub Profile
// assuming jquery and the cookie plugin are already included.
$("html").addClass("js");
$(document).ready(function() {
if ($.cookie('exp_alert_banner_newsletter')!='hide') {
$("p.alert").slideDown("slow");
$("p.alert span.hidealert a").click(function() {
$("p.alert").slideUp("slow");
<?php
// custom array merging
// if something exists in the custom array, it should overwrite the default
// otherwise take the default value
$default = array(
"key1" => "val1",
"key2" => "val2",
"key3" => array(
<?php
// custom array merging
// if something exists in the custom array, it should overwrite the default
// otherwise take the default value
$default = array(
"key1" => "val1",
"key2" => "val2",
"key3" => array(
@chadhutchins
chadhutchins / gist:1348192
Created November 8, 2011 16:05
Helper functions to deal with EE custom member fields...
<?php
// member_id not a required param, if member_id param not given
// it will use the current session's member_id, if a session doesn't
// exist, it'll return false
function _save_custom_member_field_value($field_name,$field_value,$member_id=false)
{
// field_name required
if (empty($field_name) or is_null($field_name))
{
@chadhutchins
chadhutchins / gist:1359292
Created November 11, 2011 21:12
A generic javascript class that wraps the default rails scaffolding so you can use javascript/ajax to make calls to the controllers.
var Resource = function(controller) {
// controller param required
var controller = controller ? controller : false;
if (!controller) { console.log("controller parameter required for resource"); return false; }
this.controller = controller;
};
Resource.prototype = {
index: function(callback) {
var type = "GET";
@chadhutchins
chadhutchins / gist:1440602
Created December 6, 2011 23:36
Tarjan's strongly connected components algorithm in Javascript - followed pseudocode from http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
window.onload = function() {
var v0 = new Vertex("0");
var v1 = new Vertex("1");
var v2 = new Vertex("2");
var v3 = new Vertex("3");
var v4 = new Vertex("4");
var v5 = new Vertex("5");
var v6 = new Vertex("6");
var v7 = new Vertex("7");
@chadhutchins
chadhutchins / gist:3372336
Created August 16, 2012 18:18
FuelPHP Form Validation - Require field if another field is set and/or another field has a certain value.
<?php
/*
required_if Custom Validation Method
// Example 1 - require field if another field has been set
// Require the Billing State field if Billing Country has a value
$val = Validation::forge();
$val->add_callable('customvalidation');
<?php
class Break_AjaxUI
{
static $first = false;
function echo_something($bean,$event,$arguments)
{
// echo something once
if (!self::$first)
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_retrieve'] = Array();
$hook_array['after_retrieve'][] = Array(50, 'Echo Something to break AjaxUI','custom/modules/Contacts/Break_AjaxUI.php','Break_AjaxUI', 'echo_something');
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_footer_ui'] = Array();
$hook_array['after_footer_ui'][] = Array(50, 'Echo Something to break AjaxUI','custom/modules/Contacts/Break_AjaxUI.php','Break_AjaxUI', 'echo_something');