Skip to content

Instantly share code, notes, and snippets.

View fabito's full-sized avatar
🐮
Working from home

Fábio Franco Uechi fabito

🐮
Working from home
View GitHub Profile
var socket = io.connect(window.location.host);
var received;
socket.on('data', function (data) {
received = JSON.parse(data);
});
import functools
import logging
from google.appengine.api import memcache
def cached(time=1200):
"""
Decorator that caches the result of a method for the specified time in seconds.
Use it as:
@fabito
fabito / Vagrantfile
Last active August 29, 2015 14:07 — forked from jklein/Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
#!/usr/bin/python
import flac.encoder as encoder
import pyaudio
import sys
import requests
import random
from threading import Thread
from Queue import Queue, Empty
@fabito
fabito / gist:e0c1ab1d9d8ff8d1b5561884acd126ee
Created August 15, 2016 17:13 — forked from robinloxley1/gist:7ea7c4f37a3413b1ca16
sample elasticsearch query to sort parent based on child field
{
"query":{
"has_child":{
"query":{
"function_score":{
"functions":[
{
"field_value_factor":{
"factor":1,
"field":"count"
@fabito
fabito / get_lat_lon_exif_pil.py
Created February 7, 2017 15:29 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
[
{
"name": "project_id",
"type": "string",
"mode": "required"
},
{
"name": "id",
"type": "string",
"mode": "required"
#!/usr/bin/env python
'''Crop an image to just the portions containing text.
Usage:
./crop_morphology.py path/to/image.jpg
This will place the cropped image in path/to/image.crop.png.
For details on the methodology, see
#!/usr/bin/env bash
# Bash3 Boilerplate. Copyright (c) 2014, kvz.io
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"