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 / gist:911692
Created April 9, 2011 19:24
Generating CSV files using sqlcmd and groovy
def username = args[0]
def password = args[1]
def host = args[2]
def database = args[3]
def dir = './'
def ant = new AntBuilder()
def p = ~/.*\.sql/
new File( dir ).eachFileMatch(p) { f ->
@fabito
fabito / jenkins_nginx_ci.template.json
Created November 9, 2012 22:47
AWS Cloudformation template which creates a server based on Amazon Linux and automatically installs jenkins with nginx (working as a reverse proxy).
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to deploy jenkins/nginx.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
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);
}
$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() {
@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
*/
var socket = io.connect(window.location.host);
var received;
socket.on('data', function (data) {
received = JSON.parse(data);
});
@fabito
fabito / GaeNamespaceManagerTests.java
Created June 4, 2014 03:54
SearchServices behaves different from other NamespaceManager compatible services such as MemcacheServices and DatastoreServices. After a NamaespaceManager.set() invocation its necessary to obtain a new SearchService instance from SearchServiceFactory. http://stackoverflow.com/questions/11019473/change-namespacemanager-on-full-text-search-gae
package com.ciandt.d1.commons.cloud;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.google.appengine.api.NamespaceManager;