Skip to content

Instantly share code, notes, and snippets.

View micah1701's full-sized avatar
🧰
Open to work

Micah J. Murray micah1701

🧰
Open to work
View GitHub Profile
@micah1701
micah1701 / gist:3902167
Created October 16, 2012 21:29
jQuery Digital Clock that attempts to extend accuracy by removing lag time caused by slow processors
<script>
/**
* Show the time and update it every second
*
* clock_id (string) DOM id value of element to update
* offset (int) Optional value to modify local time by, usefull if synchronizing to another clock
*/
function clock(clock_id, offset)
{
if(offset == null || offset == ""){ offset = 0; }
@micah1701
micah1701 / stateList.php
Created October 15, 2012 21:04
PHP array of the American state names and their respective 2-letter postal codes
/**
* formatted as: array("2-letter state code" => "State Name")
*
* example usage:
* <select>
* <?php $selected = "CT"; //default to this selected state
* foreach( $stateList as $code => $state_name ){ ?>
* <option value="<?=$code ?>" <?=($selected==$code) ? " SELECTED" : "" ?> ><?=$state_name ?></option>
* <? } ?>
* </select>
@micah1701
micah1701 / cURL_follow_location.php
Created October 3, 2012 18:22
Recursive cURL function to follow links when local server does not allow CURLOPT_FOLLOWLOCATION
/**
* use cURL to get the contents on a remote page uses redirect headers
* necessary when local server does not allow location
*/
function curl($url,$recursive_attempt=0){
if (!function_exists('curl_init')) { return false; }
$content = false;
$can_follow = ( ini_get('safe_mode') || ini_get('open_basedir') ) ? false : true; //cURL can't follow redirects in safe mode or if open_basedir is on