Python Cheatsheets
http://refcardz.dzone.com/refcardz/core-python
http://rgruet.free.fr/
Learn Python in 10 minutes
http://www.stavros.io/tutorials/python/
https://leanpub.com/learn-python
<?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"; |
Python Cheatsheets
http://refcardz.dzone.com/refcardz/core-python
http://rgruet.free.fr/
Learn Python in 10 minutes
http://www.stavros.io/tutorials/python/
https://leanpub.com/learn-python
//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; | |
} |
class Dummy | |
@helloStatic: (name)-> | |
"hello #{name} (static)" | |
hello: (name) -> | |
"hello #{name}" | |
alert Dummy.helloStatic("Gonzalo") | |
dummy = new Dummy |
<?php | |
class DocInject | |
{ | |
public function __construct() | |
{ | |
$reflection = new ReflectionClass($this); | |
foreach ($reflection->getProperties() as $property) { | |
$this->processProperty($property); | |
} | |
} |
<?php | |
trait DocInject | |
{ | |
public function parseDocInject() | |
{ | |
$reflection = new ReflectionClass($this); | |
foreach ($reflection->getProperties() as $property) { | |
$this->processProperty($property); | |
} | |
} |
cd existing_git_repo | |
git remote add origin git@github.com:[user]/[reponame].git | |
git push -u origin master |
#!/usr/bin/env bash | |
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin | |
# actual battery level | |
BATT=`ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i mouse -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2` | |
# defaults to warn at 20%; accepts other number as 1st argument (useful for testing) | |
COMPARE=${1:-20} | |
if [ -z "$BATT" ]; then |
import logging | |
logging.basicConfig( | |
format='%(asctime)s [%(levelname)s] %(message)s', | |
level='INFO', | |
datefmt='%d/%m/%Y %X') | |
logger = logging.getLogger(__name__) |
from functools import wraps | |
from flask import request, abort | |
from lib.logger import logger | |
def authorize_bearer(bearer): | |
def authorize(f): | |
@wraps(f) | |
def decorated_function(*args, **kws): | |
if 'Authorization' not in request.headers: |