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; | |
| } |
| cd existing_git_repo | |
| git remote add origin [email protected]:[user]/[reponame].git | |
| git push -u origin master |
| 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); | |
| } | |
| } |
| <?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
| import cv2 | |
| import numpy as np | |
| from skimage.measure import compare_ssim as ssim | |
| def mse(imageA, imageB): | |
| # the 'Mean Squared Error' between the two images is the | |
| # sum of the squared difference between the two images; | |
| # NOTE: the two images must have the same dimension | |
| err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2) | |
| err /= float(imageA.shape[0] * imageA.shape[1]) |
| #!/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__) |