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
@fabito
fabito / exportShortGitCommit.groovy
Last active May 9, 2019 02:31
Exporting short git commit sha1 hash in Jenkins through System Groovy Script build step
import hudson.model.*
def env = build.getEnvironment()
def gitCommit = env['GIT_COMMIT']
def shortGitCommit = gitCommit[0..6]
def pa = new ParametersAction([
new StringParameterValue("SHORT_GIT_COMMIT", shortGitCommit)
])
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.fasterxml.jackson.databind.node.ArrayNode;
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 / cycle_version.py
Created September 18, 2014 14:01
Python script to rotate appengine versions
#!/usr/bin/python
import sys, getopt, yaml
def main(argv):
try:
module_name = 'dev'
yaml_versions_file = 'document.yaml'
stream = file(yaml_file, 'r')
@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.
package com.ciandt.ko.fwc.api.infrastructure.gcs;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.ciandt.ko.fwc.api.domain.model.photo.StorageService.StorageName;
import com.google.appengine.api.appidentity.AppIdentityService;
@fabito
fabito / cloud_storage.py
Created January 10, 2015 04:15
Utilities for upload and download files to Google Cloud Storage using signed URLs within Google App Engine applications
import datetime
import time
import urllib
__all__ = ['sign', 'PolicyDocument', 'CloudStorageURLSigner']
from google.appengine.api import app_identity
from base64 import b64encode
import json
#!/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)