Skip to content

Instantly share code, notes, and snippets.

View ismaels's full-sized avatar

Ismael Stahelin ismaels

  • Brasil
View GitHub Profile
@ismaels
ismaels / log4j.properties
Created February 8, 2012 11:21
Exemplo de arquivo de configuração do log4j.
### direct messages to file multiagent.log ###
#log4j.appender.agent=org.apache.log4j.RollingFileAppender
#log4j.appender.agent.File=/tmp/app.log
#log4j.appender.agent.MaxFileSize=5000KB
#log4j.appender.agent.MaxBackupIndex=5
#log4j.appender.agent.layout=org.apache.log4j.PatternLayout
#log4j.appender.agent.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%-10.10t] (%F:%L) - %m%n
### direct messages to the standard output ###
log4j.appender.console=org.apache.log4j.ConsoleAppender
@ismaels
ismaels / uninstall_all_gems.sh
Created November 14, 2012 01:39
Desinstalar todas as gems
#!/bin/bash
for x in `gem list --no-versions`; do gem uninstall $x; done
@ismaels
ismaels / sinatra-activerecord-app.rb
Last active December 11, 2015 09:28
Sinatra example app using ActiveRecord ORM
# extracted from http://fernandomantoan.com/javascript/serie-backbone-js-parte-3-model/
require 'sinatra'
require 'json'
require 'active_record'
# O JSON não deve conter um elemento ROOT, apenas os atributos
ActiveRecord::Base.include_root_in_json = false
class Post < ActiveRecord::Base
@ismaels
ismaels / fitler-table.coffee
Created March 1, 2013 13:13
Simple method to filter rows in a html table
# filtering row on a table
_searchItems: () =>
criteria = $("#searchItems").val()
$("#schedules_table tbody tr").css('display', 'table-row')
$("#schedules_table tbody tr").not(":contains('#{criteria}')").each () ->
$(this).css('display', 'none')
@ismaels
ismaels / toggle_element.js
Created March 26, 2013 13:32
Javascript function to toggle an element based on other elements property
//author: Ismael Stahelin
//date: 25.3.2013
//the toggle function
//is based on selected option of a select element. if selected option has the desired property with the desired value
//so another element, in this case a checkbox element is shown, otherwise it is hidden
var toggleTemperature = function(){
var op = $('#tracking_module_tracking_module_model_id option:selected');
if($(op).attr('data-has_temperature_sensor') == 'true'){
$('#temperature_control').show("fast");
}else{
@ismaels
ismaels / polyline_decoder.js
Created September 20, 2013 12:50
Javascript function to decode google maps api polyline
// source: http://doublespringlabs.blogspot.com.br/2012/11/decoding-polylines-from-google-maps.html
function decode(encoded){
// array that holds the points
var points=[ ]
var index = 0, len = encoded.length;
var lat = 0, lng = 0;
while (index < len) {
var b, shift = 0, result = 0;
@ismaels
ismaels / remove_keys_from_redis.sh
Created October 17, 2013 12:24
Remove all keys that follow the indicated pattern from redis using the "redis-cli del" command.
redis-cli keys "TripVo*" | cut -d" " -f 2 | xargs redis-cli del
@ismaels
ismaels / proxy.js
Last active October 20, 2015 22:15
Creates a http proxy server used as a router for two app instances running on different ports
var http = require('http'),
httpProxy = require('http-proxy');
// Create a proxy server with custom application logic
var proxy = httpProxy.createProxyServer({});
//
// Create your custom server and just call `proxy.web()` to proxy
// a web request to the target passed in the options
// also you can use `proxy.ws()` to proxy a websockets request
@ismaels
ismaels / compare_folders.rb
Last active February 3, 2018 17:45
Compare the contents of two folders
#!/usr/bin/env ruby
# encoding: utf-8
require 'fileutils'
errors = []
folderA = 'folder1'
folderB = 'folder2'
# list all files in each folder
@ismaels
ismaels / install_mysql.sh
Created September 25, 2017 20:57 — forked from rrosiek/install_mysql.sh
Vagrant provision script for php, Apache, MySQL, phpMyAdmin, Laravel, and javascript helpers. Tested with Ubuntu 16.04.
#! /usr/bin/env bash
###
#
# install_mysql.sh
#
# This script assumes your Vagrantfile has been configured to map the root of
# your application to /vagrant and that your web root is the "public" folder
# (Laravel standard). Standard and error output is sent to
# /vagrant/vm_build.log during provisioning.