Skip to content

Instantly share code, notes, and snippets.

@ericsaboia
ericsaboia / elasticsearch.yml
Last active April 6, 2018 01:13
Elasticsearch brazlian accent insensitive config.
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/reference/setup/installation.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,
@ericsaboia
ericsaboia / list_routes.js
Created August 14, 2013 23:10
List routes for node restify or express, inspired by rake routes (Rails). Usage: Just put inside your routes folder, and run "node list_routes.js"
var fs = require('fs');
fs.readdir(__dirname, function(err, files) {
sayRoutes(files);
});
function sayRoutes (files) {
files.forEach(function (file) {
read(file, function (routes) {
if (routes.length > 0) {
@ericsaboia
ericsaboia / gist:5564617
Created May 12, 2013 19:30
Ubuntu 13 change places location
1) gedit ~/.config/user-dirs.dirs
remove the list you do not want. however, once you login again, it will reset, so -->
2) echo "enabled=false" > ~/.config/user-dirs.conf
@ericsaboia
ericsaboia / gist:4533936
Created January 14, 2013 22:01
query.fileupload exemple
print $this->Html->script('jquery_file_upload/vendor/jquery.ui.widget');
print $this->Html->script('jquery_file_upload/jquery.iframe-transport');
print $this->Html->script('jquery_file_upload/jquery.fileupload');
$('input[type="file"]').fileupload({
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
start: function() {
$('#'+$(this).attr('id')+'_loading').show();
},
done: function (e, data) {
@ericsaboia
ericsaboia / someTest.php
Created November 30, 2012 18:35
First TDD Step in PHP
class SomeTest extends PHPUnit_Framework_TestCase
{
public function methodRunShouldExist()
{
$example = new ExampleClass();
$this->assertTrue(method_exists($example, 'run'));
}
}
class ExampleClass
public static List<Category> getList() {
Gson gson = new Gson();
String json_string = API.getJSON("http://u8r.herokuapp.com/categories.json");
return Arrays.asList(gson.fromJson(json_string, Category[].class));
}
public static List<Category> getSubList(Integer category_id) {
Gson gson = new Gson();
@ericsaboia
ericsaboia / extend_string.rb
Created October 5, 2011 20:31
Function to make accents insensitives
@@accents = ["(a|á|à|â|ã)","(e|é|è|ê)","(i|í|ì)","(o|ó|ò|ô|õ)","(u|ú|ù)","(c|ç)"]
def accent_insensitive
str = String.new(self)
@@accents.each {|exp| str.gsub! Regexp.new(exp), exp}
str
end
@ericsaboia
ericsaboia / sockect_client.rb
Created September 21, 2011 12:38
TCPSocket Client
socket = TCPSocket.new('localhost', 8081)
socket.write(configs)
stream = ""
while data = socket.read(1024)
stream << data
end
@ericsaboia
ericsaboia / echo_client.rb
Created September 21, 2011 12:27
Eventmachine Client
module EchoClient
ADDRESS = 'localhost'
PORT = 8081
class << self
def get(data)
result = ""
EventMachine::run do
@ericsaboia
ericsaboia / report_server.rb
Created September 21, 2011 12:24
Eventmachine Server
# encoding: utf-8
require 'rubygems'
require 'eventmachine'
require 'java'
require 'lib/report'
require 'lib/filler'
module ReportServer