Skip to content

Instantly share code, notes, and snippets.

View lsdr's full-sized avatar

Luiz Rocha lsdr

  • São Paulo, Brazil
  • 09:43 (UTC -03:00)
View GitHub Profile
# make gvim set its servername to the current dir
_basedir() {
basename `pwd`
}
alias gvim='/Applications/MacVim.app/Content/MacOS/Vim -g --servername $(_basedir)'
@lsdr
lsdr / method_missing.rb
Created August 4, 2009 23:25
benchmarking method_missing
# http://www.jroller.com/dscataglini/entry/speeding_up_method_missing
require 'benchmark'
include Benchmark
class A
def foo(a, b, c)
1
end
end
@lsdr
lsdr / upstream.rb
Created August 21, 2009 19:56
Experimentations with Ruby's super
module Upstream
module Streamer
def self.included(receiver)
receiver.extend ExtensionMethods
end
module ExtensionMethods
def streamable!
self.send :include, InstanceMethods
@lsdr
lsdr / results
Created September 8, 2009 20:53
benchmarking Symbol#to_proc on Ruby 1.8.7 and 1.9.1
MAC OS X:
*** ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
user system total real
Symbol#to_proc 97.820000 26.180000 124.000000 (128.542748)
*** ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-darwin9.7.0]
database: &database
adapter: mysql
username: <pwd>
password: <pwd>
host: localhost
encoding: utf8
development:
<<: *database
database: <proj>_development
#!/bin/sh
#
# Stupid script that handles big Rails logs in search for activation emails queued on DelayedJobs.
# Like I said, stupid. No more than the bug that created the need to do this, but still.
#
# And nevermind the name. I decided to look the web for inspiration and got an article on Ford,
# Chrysler and Lee Iacocca. Thus, iacocca.sh.
#
echo "spliting log file in 30M tempfiles..."
@lsdr
lsdr / ccat
Last active April 22, 2019 12:57
stuff I keep on ~/bin
#!/bin/bash
# Font: http://scott.sherrillmix.com/blog/programmer/syntax-highlighting-in-terminal/
if [ ! -t 0 ]; then
file=/dev/stdin
elif [ -f $1 ]; then
file=$1
else
echo "Usage: $0 code.c"
echo "or e.g. head code.c|$0"
exit 1
@lsdr
lsdr / children.txt
Last active September 26, 2015 01:38
Coleção de citações de livros de SCI-FI
... era incapaz de explicar por que tais pensamentos vinham a seu encontro, no
meio da noite, e por que faziam com que se sentisse tão culpado. Agachou-se
dentro de seu manto. A realidade não era nem um pouco como o sonho. O Deserto
Amistoso, que um dia se estendera de um pólo a outro, estava reduzido à metade
de seu tamanho. O paraíso mítico das extensões verdes que se ampliavam o enchia
de angústia.
Não era como o sonho. Enquanto seu planeta mudava, ele também mudava.
Tornara-se uma pessoa mais sutil do que o chefe de sietch que um dia fora. Agora
@lsdr
lsdr / clear-apple-logs.sh
Created June 28, 2012 12:45
a myriad of small scripts and/or cmd-one-liners to do mac maintenance
#!/bin/sh
# http://osxdaily.com/2010/05/06/speed-up-a-slow-terminal-by-clearing-log-files/
rm -rf /private/var/log/asl/*.asl
@lsdr
lsdr / build-python-27.sh
Created August 8, 2012 12:45
alt-install python2.7 on a x86_64 centos6 box
#!/bin/bash
# Install Python 2.7.3 alternatively
# original script:
# https://github.com/bngsudheer/bangadmin/blob/master/linux/centos/6/x86_64/build-python-27.sh
#
yum groupinstall "development tools" -y
yum install -y readline-devel openssl-devel gmp-devel \
ncurses-devel gdbm-devel zlib-devel expat-devel libGL-devel \
tk tix gcc-c++ libX11-devel glibc-devel bzip2 tar tcl-devel \
tk-devel pkgconfig tix-devel bzip2-devel sqlite-devel autoconf \