Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
ericlbarnes / filters.php
Created July 16, 2013 17:30 — forked from anonymous/filters.php
Laravel CSRF Ajax
/**
* Filter to check for CSRF attacks from the ajax requests.
*/
Route::filter('csrf_header', function()
{
if (Session::token() != Request::header('x-csrf-token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
});
@MichelBartz
MichelBartz / Comments.php
Created January 30, 2011 21:07
Nested Comments using Redis. Rely on the Owlient Redis extension
<?php
/**
* A Nested Comments manager using Redis only
* @author Michel Bartz <michel.bartz@manwin.com>
* @date 01/28/2011
*/
class Comments
{
private $_redis;
@furf
furf / 1-tmpl.js
Created October 26, 2010 05:04
JavaScript Micro Templating
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
// @see http://ejohn.org/blog/javascript-micro-templating/
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?