Skip to content

Instantly share code, notes, and snippets.

Gonzalo Ayuso gonzalo123

Block or report user

Report or block gonzalo123

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
#!/usr/bin/env bash
# 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)
if [ -z "$BATT" ]; then
gonzalo123 /
Created Apr 17, 2017
compare images with opencv
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])
View designer.html
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
gonzalo123 / gist:10007768
Created Apr 6, 2014
Kata Katayuno Abril Bilbao sin TDD
View gist:10007768
echo (new \DateTime())->diff(\DateTime::createFromFormat('Y-m-d H:i:s', json_decode((new Guzzle\Http\Client(''))->get('/api/v1/user/gonzalo123')->send()->getBody(), true)['data']['user'][0]['date_signed']))->format('%y') . "year/s old";
View possibleBug.php
// this script doesn't work:
// Fatal error: Call to protected method ShouldBeAbstractButItIsnt::foo() from context 'Dummy'
// it's obvious but if I extends Dummy class with ShouldBeAbstractButItIsnt it works
class ShouldBeAbstractButItIsnt
protected function foo()
return "bar";
View DocInject.trait.php
trait DocInject
public function parseDocInject()
$reflection = new ReflectionClass($this);
foreach ($reflection->getProperties() as $property) {
View DocInject.php
class DocInject
public function __construct()
$reflection = new ReflectionClass($this);
foreach ($reflection->getProperties() as $property) {
gonzalo123 / Dummy.cs
Created Oct 13, 2011
Example static and non static functions
View Dummy.cs
class Dummy
@helloStatic: (name)->
"hello #{name} (static)"
hello: (name) ->
"hello #{name}"
alert Dummy.helloStatic("Gonzalo")
dummy = new Dummy
gonzalo123 / ArraySiblingsTest.php
Created Mar 23, 2011
next/previous sibling of an element in an associative array
View ArraySiblingsTest.php
interface ArraySiblingsInterface
public static function previous($needle, $haystack, $continueAtTop = true);
public static function next($needle, $haystack, $continueAtBottom = true);
class ArraySiblings implements ArraySiblingsInterface
const FORWARD = 'fwd';
You can’t perform that action at this time.