Skip to content

Instantly share code, notes, and snippets.

View klhall1987's full-sized avatar

Kenny Hall klhall1987

View GitHub Profile
@klhall1987
klhall1987 / 0_reuse_code.js
Last active August 29, 2015 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
$phone = array( 'HTC', 'One M8', 'Android' );
list($brand, $model , $os ) = $phone;
//echos "I have a HTC One M8 running Android."
echo "I have a $brand $model running $os.";
@klhall1987
klhall1987 / gist:b79cb4646f929c015aec
Last active October 9, 2015 13:37
Compact Example
<?php
//Describes phone
$brand = "HTC";
$model = "One M8";
$os = "Android";
//Creates the phone array using the variables above as key value pairs.
$phone = compact("brand", "model" , "os");
@klhall1987
klhall1987 / gist:8b138aacbc083c0f66b2
Last active October 9, 2015 13:39
Extract Example
<?php
//Describes phone
$brand = "HTC";
$model = "One M8";
$os = "Android";
//Sets each string to a key value pair in an array.
$phone = compact("brand", "model" , "os");
@klhall1987
klhall1987 / gist:77f40367011b49d52ecc
Created October 8, 2015 18:16
Normal jQuery Call
$(document).ready(function(){
$(#somefunction)
});
@klhall1987
klhall1987 / gist:da7f3606029be6d03c96
Last active February 8, 2016 14:25
noConflit jQuery Function
//Set $ as a wrapper for jQuery
jQuery(document).ready(function($){
//Everything inside this function can use the $ wrapper to call jQuery.
$(#somefunction)
});
//Reassign jQuery call to a variable.
var $j = jQuery;
//Then use the variable as a wrapper for the jQuery call.
$j(#somefunction);
@klhall1987
klhall1987 / MethodChaining.php
Last active October 27, 2015 14:33
Method Chaining
<?php
//Example of single class method chaining
class stringExample
{
private $str;
function __construct()
{
$this->str = '';
@klhall1987
klhall1987 / set_transient.php
Created October 27, 2015 13:34
Setting Transient
set_transient( $transient , $value , $expiration);
$transient //This is a string that will be used as a unique identifier for your cached data. It must be less than 45 characters.
$value //This will be an array, object, or variable you wish to cache.
$expiration //An integer of the maximum of seconds to keep the data before expiring.
@klhall1987
klhall1987 / PhoneMethodChaining.php
Last active October 29, 2015 13:03
Method Chaining with phones
<?php
class Phone
{
//Creating private properties
private $_type;
private $_os;
public function setType( $type )