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);
});
@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;
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: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 ->