Skip to content

Instantly share code, notes, and snippets.

View stevenwoodson's full-sized avatar

Steve Woodson stevenwoodson

View GitHub Profile
@stevenwoodson
stevenwoodson / filters.php
Created March 23, 2014 17:31
Laravel 4 - Handling TokenMismatchException
App::error(function(\Illuminate\Session\TokenMismatchException $exception)
{
return Redirect::back()->withErrors('Your session has expired. Please try again.');
});
@stevenwoodson
stevenwoodson / gist:95dc4dc10e0c73d32408
Last active August 29, 2015 14:06
Javascript Timestamp - GMT & Specified Timezone Examples
// Make sure to use the decimal fraction of a second in the examples below
// Came across issues in Safari when they weren't used, see http://www.w3.org/TR/NOTE-datetime for more info
// September 10th 2014, 5pm GMT
new Date('2014-09-10T17:00:00.000').getTime()
// September 10th 2014, 5pm ET
new Date('2014-09-10T17:00:00.000-04:00').getTime()
@stevenwoodson
stevenwoodson / gist:ce23ca45caa8f38fbaf0
Created October 30, 2014 16:15
Random Unique String
<?php
// Generates a string of random bytes of the provided number (7 in the example below) and then converts that binary to hexadecimal
// The hexadecimal conversion doubles the string size so the final result in the example below will be 14 characters long.
echo bin2hex(openssl_random_pseudo_bytes(7));
@stevenwoodson
stevenwoodson / gist:6ad009f82ca890bb76cd
Created December 3, 2014 23:13
Laravel - Output the latest queries executed
dd(DB::getQueryLog());
@stevenwoodson
stevenwoodson / gist:105f2f37d479161a8622
Created December 11, 2014 17:45
MySQL Compare timestamps
SELECT if( TIMEDIFF('2014-12-11 11:00:00','2014-12-11 11:39:30') < 0, 'older','newer')