Skip to content

Instantly share code, notes, and snippets.

View lucianosousa's full-sized avatar
💭
🏊 🚴‍♂️ 🏃- 🏋️‍♂️

Luciano Sousa lucianosousa

💭
🏊 🚴‍♂️ 🏃- 🏋️‍♂️
View GitHub Profile
@lucianosousa
lucianosousa / gist:6efea313b6f737282b29
Created August 10, 2014 22:33
prevent double submission on forms
jQuery.fn.preventDoubleSubmission = function() {
$(this).on('submit',function(e){
var $form = $(this);
if ($form.data('submitted') === true) {
e.preventDefault();
} else {
$form.data('submitted', true);
}
});
WARNING: Please be aware that you just installed a ruby that is no longer maintained (2014-02-23), for a list of maintained rubies visit:
http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
Please consider upgrading to ruby-2.1.2 which will have all of the latest security patches.
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
@lucianosousa
lucianosousa / gist:3398c9aa760aa113faa2
Created September 1, 2014 22:37
stress test example from somewhere else
@retained = []
@rand = Random.new(999)
MAX_STRING_SIZE = 100
def stress(allocate_count, retain_count, chunk_size)
chunk = []
while retain_count > 0 || allocate_count > 0
if retain_count == 0 || (@rand.rand < 0.5 && allocate_count > 0)
chunk << " " * (@rand.rand * MAX_STRING_SIZE).to_i
@lucianosousa
lucianosousa / gist:b482b3af57188e0ab497
Created September 8, 2014 03:44
namespace example
namespace :admin do
resources :users, only: [:show] do
collection do
get :search
end
end
end
@lucianosousa
lucianosousa / gist:0b42a418b95bd7eedeea
Created September 10, 2014 01:35
Brazilian Portuguese locale for formtastic
pt-BR:
formtastic:
:yes: 'Sim'
:no: 'Não'
:create: 'Criar %{model}'
:update: 'Atualizar %{model}'
:submit: 'Salvar %{model}'
:cancel: 'Cancelar %{model}'
:reset: 'Resetar %{model}'
:required: 'obrigatório'
@lucianosousa
lucianosousa / formtastic.pt-BR.yml
Created September 10, 2014 01:40
Brazilian Portuguese locale for formtastic
pt-BR:
formtastic:
:yes: 'Sim'
:no: 'Não'
:create: 'Criar %{model}'
:update: 'Atualizar %{model}'
:submit: 'Salvar %{model}'
:cancel: 'Cancelar %{model}'
:reset: 'Resetar %{model}'
:required: 'obrigatório'
pg_dump -U user-name -d database-name -W > backup.sql
scp user-name@server-address:path-to-file my-path
@lucianosousa
lucianosousa / redis.conf
Created January 29, 2015 02:34
/etc/redis/redis.conf for amazon linux/centOS - redis as daemon/service
daemonize yes
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
bind 127.0.0.1
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/var/log/redis.log"
databases 16
@lucianosousa
lucianosousa / redis-server
Last active August 29, 2015 14:14 — forked from tahajahangir/redis-server
redis-server - a config file to put on /etc/init.d/redis-server and set as centOS service
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid