Skip to content

Instantly share code, notes, and snippets.

@gonzalo123
gonzalo123 / DocInject.php
Created April 9, 2012 13:23
DocInject class
<?php
class DocInject
{
public function __construct()
{
$reflection = new ReflectionClass($this);
foreach ($reflection->getProperties() as $property) {
$this->processProperty($property);
}
}
@gonzalo123
gonzalo123 / Dummy.cs
Created October 13, 2011 18:51
Example static and non static functions
class Dummy
@helloStatic: (name)->
"hello #{name} (static)"
hello: (name) ->
"hello #{name}"
alert Dummy.helloStatic("Gonzalo")
dummy = new Dummy
@gonzalo123
gonzalo123 / js.php
Created February 24, 2011 17:07
Combines recursively js files into a single one to speed up page loads
//js.php
require 'jsmin.php';
function checkCanGzip(){
if (array_key_exists('HTTP_ACCEPT_ENCODING', $_SERVER)) {
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) return "gzip";
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) return "x-gzip";
}
return false;
}
@gonzalo123
gonzalo123 / gist:10007768
Created April 6, 2014 15:41
Kata Katayuno Abril Bilbao sin TDD
<?php
echo (new \DateTime())->diff(\DateTime::createFromFormat('Y-m-d H:i:s', json_decode((new Guzzle\Http\Client('http://karmacracy.com'))->get('/api/v1/user/gonzalo123')->send()->getBody(), true)['data']['user'][0]['date_signed']))->format('%y') . "year/s old";