Skip to content

Instantly share code, notes, and snippets.

View kisuka's full-sized avatar
🍕

Kisuka kisuka

🍕
View GitHub Profile
@kisuka
kisuka / gist:6072db03fc9a1c90b143
Created July 15, 2014 21:15
Clear remote modal view on Bootstrap 3.1.
// Fix for BS 3.1 modal remote loading.
$(document).on("hidden.bs.modal", function (e) {
$(e.target).removeData("bs.modal").find(".modal-content").empty();
});
@kisuka
kisuka / gist:9995837
Created April 5, 2014 18:18
Laravel : Automatic CSRF
public function __construct()
{
// Perform CSRF check on all post/put/patch/delete requests
$this->beforeFilter('csrf', array('on' => array('post', 'put', 'patch', 'delete')));
}
@kisuka
kisuka / calculate_age.php
Created December 13, 2013 01:08
This function accepts a birth date and returns the age based on that date.
<?php
// Requires PHP >= 5.3
function age($birthdate)
{
return date_create($birthdate)->diff(date_create("today"))->y;
}
?>
@kisuka
kisuka / alphabetical-array.php
Created December 2, 2013 06:28
Sort multidimensional array alphabetically by value of a key.
<?php
// Requires >= PHP 5.3
usort($source_array, function($a, $b) {
return strcmp($a['key'], $b['key']);
});
?>
@kisuka
kisuka / bootstrap.linktabs.js
Last active December 23, 2015 23:28
Twitter Bootstrap : Direct Link Tabs
$(window).load(function(){
if(window.location.hash) {
$('a[href="'+window.location.hash+'"]').click();
}
});