This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thwait' | |
# Synchronous hand-off between two threads. | |
# Both threads will block until a transfer is successful. | |
class Rendevous | |
def initialize | |
@mutex = Mutex.new | |
@send_flag = ConditionVariable.new | |
@recv_flag = ConditionVariable.new | |
@container = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
class JsonStruct < OpenStruct | |
def initialize(hash = nil) | |
@table = {} | |
@hash_table = {} | |
return unless hash | |
hash.each do |k, v| | |
recursive_initializer(v) if v.is_a?(Array) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Financeiro | |
# Inclui suporte para escrever em um campo com valor monetário | |
# utilizando BigDecimal, ou valor em string seguindo sintaxe | |
# do jQuery MoneyMask | |
# | |
# Para habilitar em um model é preciso primeiro fazer um include no model: | |
# include MoneyAttribute | |
# | |
# Defina cada um dos campos que você quer que tenham o comportamento: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def x(&block) | |
"alguma coisa".tap &block | |
puts "outra coisa" | |
end | |
x { |obj| puts "METAPROGRAMMING: #{obj.inspect}" } | |
# METAPROGRAMMING: "alguma coisa" | |
# outra coisa | |
# => nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file should be placed at /etc/logrotate.d/ | |
/srv/*/shared/log/*.log { | |
daily | |
missingok | |
dateext | |
rotate 30 # amount of days to keep compressed logs (you should backup it up externally) | |
compress | |
delaycompress | |
notifempty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Acrescentando suporte para add-apt-repository" | |
sudo apt-get install -ym software-properties-common python-software-properties apt-transport-https | |
echo "Adicionando repositórios externos" | |
sudo add-apt-repository ppa:brightbox/ruby-ng-experimental | |
# chave pgp do repositório da phusion | |
gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 | |
gpg --armor --export 561F9B9CAC40B2F7 | sudo apt-key add - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update && sudo apt-get dist-upgrade -y | |
sudo update-ca-certificates | |
echo "Instalação de bibliotecas essenciais..." | |
sudo apt-get install -y git build-essential vim curl | |
echo "Instalação do MySQL (cliente e servidor) e bibliotecas para compilar gems..." | |
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "chosen"; | |
.chosen-container { | |
font-size: inherit; | |
margin-bottom: $form-spacing; | |
.chosen-single div { | |
background: none; | |
border-left: none; | |
position: absolute; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install htop -v | |
==> Downloading https://github.com/max-horvath/htop-osx/archive/0.8.2.2.tar.gz | |
Already downloaded: /Library/Caches/Homebrew/htop-osx-0.8.2.2.tar.gz | |
==> Verifying htop-osx-0.8.2.2.tar.gz checksum | |
tar xf /Library/Caches/Homebrew/htop-osx-0.8.2.2.tar.gz | |
==> ./autogen.sh | |
glibtoolize: putting auxiliary files in `.'. | |
glibtoolize: copying file `./ltmain.sh' | |
glibtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'. | |
glibtoolize: copying file `m4/libtool.m4' |