Skip to content

Instantly share code, notes, and snippets.

View assertchris's full-sized avatar

Christopher Pitt assertchris

View GitHub Profile
@assertchris
assertchris / gist:4975460
Created February 18, 2013 06:31
Questions for Taylor Otwell

Taylor Otwell

  • Who are you?

Laravel

  • What is Laravel?
  • Why create another framework?
  • What frameworks/methodologies have been instrumental in shaping Laravel?
@assertchris
assertchris / gist:4737485
Created February 8, 2013 08:39
Found in production code...
myfunc = (num) ->
if num is 1
return "num is 1";
else
return "not 1";
@assertchris
assertchris / gist:4202584
Created December 4, 2012 10:45
ArrayIterator with ->previous()
class ArrayIterator extends \ArrayIterator
{
protected $_previous;
public function next()
{
$this->_previous = $this->key();
parent::next();
}
function create($name, $parameters = [])
{
$name = str_replace(".", "\\", $name);
$reflection = new ReflectionClass($name);
return $reflection->newInstanceArgs($parameters);
}
create("Some.Namespaced.Class", [$arg1, $arg2]); # -> new Some\Namespaced\Class($arg1, $arg2)
@assertchris
assertchris / gist:4168707
Created November 29, 2012 12:27
A man's PHP require!
if (!function_exists("_path"))
{
function _path()
{
return dirname(__DIR__);
}
}
if (!function_exists("_require"))
{
<?php
define('TYPEHINT_PCRE' ,'/^Argument (\d)+ passed to (?:(\w+)::)?(\w+)\(\) must be an instance of (\w+), (\w+) given/');
class Typehint
{
private static $Typehints = array(
'boolean' => 'is_bool',
'integer' => 'is_int',
@assertchris
assertchris / t.js
Created September 28, 2012 13:19 — forked from wayneashleyberry/t.js
simple templating
/**
* simple mustache-like templater
* http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/
* -----------------------------------------------------------------------------------------
* t('Hello, {{planet}}!', {'planet': 'World'});
* returns 'Hello, World!';
*/
function t(s,d){
for(var p in d)
s=s.replace(new RegExp('{{'+p+'}}','g'), d[p]);
@assertchris
assertchris / gist:3749323
Created September 19, 2012 12:09
Vanilla JavaScript, Canvas Confetti
// I don't usually inline my javascript, but when I do it is in Greg's HTML.
(function () {
var last = 0,
vendors = ["ms", "moz", "webkit", "o"];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"];
<?php
class Collection implements IteratorAggregate, ArrayAccess, Countable
{
// ...
public function toJSON()
{
$return = array();
@assertchris
assertchris / gist:3619634
Created September 4, 2012 10:19
Wonderful PHP object creation!
$obj = new Generic([
"var1" => "foo",
"var2" => "bar",
"func1" => function()
{
echo $this->var1;
},