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
$scope.getCep = function() {
var req = gapi.client.buscacep.cep.get({numeroCep: $scope.numeroCep} );
req.execute(function(response) {
var cep = response.result;
$scope.cep = cep;
$scope.$apply();
});
}
$scope.searchCep = function() {
package org.talesolutions.cep.appengine;
import java.util.List;
import javax.inject.Named;
import org.talesolutions.cep.CEP;
import org.talesolutions.cep.CEPService;
import org.talesolutions.cep.CEPServiceFactory;
@Api(name = "buscacep", description = "Conjunto de serviços para consulta de CEP")
public class CepEndpoint {
private CEPService cepService = new MemcacheCepServiceDecorator(CEPServiceFactory.getCEPService());
@ApiMethod(httpMethod = "GET", name = "cep.get")
public CEP getCep(@Named("numeroCep") String numeroCep) {
return cepService.obtemPorNumeroCEP(numeroCep);
}
@fabito
fabito / gist:5472985
Last active December 16, 2015 17:49
Script used to play a sound when a specific image is present in a page. It fetches the page every 5 minutes and checks for the image presence. If the image is found it starts playing the alarm in a loop.
#!/usr/bin/env groovy
@Grapes( @Grab('org.jsoup:jsoup:1.6.1'))
import org.jsoup.*
import org.jsoup.nodes.*
// a wrapper closure around executing a string
// can take either a string or a list of strings (for arguments with spaces)
// prints all output, complains and halts on error
@fabito
fabito / maven profile
Created July 6, 2013 03:34
Maven profile snippet for smart appengine devserver restarts. It copies static files from src/main/webapp to target directory every time a change is detected. It also synchronizes compiled classes causing the Devserver to restart every time classes are changed.
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
import javax.inject.Inject;
import org.togglz.core.manager.FeatureManager;
import com.google.inject.Provider;
/**
* Utility class to provide static access to FeatureManager.
* @author fabio
*/
@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"