Skip to content

Instantly share code, notes, and snippets.

@amalrik
amalrik / add_prefix.sh
Created March 26, 2012 21:39
adicionar um prefixo a todos arquivos de um mesmo padrão de um diretorio e todos os subdiretorios
PREFIX=xyz;
while read line
do
path="$(dirname $line)"
base="$(basename $line)";
mv "${line}" "$path/${PREFIX}${base}"
done < <(find dir1 -name "*.c")
@amalrik
amalrik / compile_all.sh
Created April 12, 2012 21:02
compilar todos os scripts do mediador
nohup dcs_depend_rpt -incscripts -rpt_stdout -rpt_print_raw -rpt_temporary |grep ^"GDC Script:" |awk '{print $3}' |xargs -i cgdc_compiler {}.scr > compile_output.log 2>&1 &
@amalrik
amalrik / changes.md
Created November 24, 2012 11:45 — forked from funny-falcon/changes.md
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@amalrik
amalrik / config.log
Created December 3, 2012 11:17
rvm log data - ruby install with readline
[2012-12-05 06:49:50] ./configure --enable-shared --disable-install-doc --prefix=/Users/amalrik/.rvm/rubies/ruby-1.9.3-p327 --with-opt-dir=/usr/local/opt/readline:/Users/amalrik/.rvm/usr
checking build system type... x86_64-apple-darwin12.2.1
checking host system type... x86_64-apple-darwin12.2.1
checking target system type... x86_64-apple-darwin12.2.1
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
@amalrik
amalrik / otool -L readline.bundle
Created December 5, 2012 19:51
rvm log data - ruby install with readline
$ find /Users/amalrik/.rvm/rubies/ruby-1.9.3-p327/ -name readline.bundle | xargs otool -L
/Users/amalrik/.rvm/rubies/ruby-1.9.3-p327//lib/ruby/1.9.1/x86_64-darwin12.2.1/readline.bundle:
/Users/amalrik/.rvm/rubies/ruby-1.9.3-p327/lib/libruby.1.9.1.dylib (compatibility version 1.9.1, current version 1.9.1)
/usr/local/opt/readline/lib/libreadline.6.2.dylib (compatibility version 6.0.0, current version 6.2.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
@amalrik
amalrik / config.log
Created December 8, 2012 01:01
rvm log data - ruby install with readline after ncurses install
[2012-12-07 22:36:40] ./configure --enable-shared --disable-install-doc --prefix=/Users/amalrik/.rvm/rubies/ruby-1.9.3-p327 --with-opt-dir=/usr/local/opt/readline:/usr/local/opt/ncurses:/Users/amalrik/.rvm/usr
checking build system type... x86_64-apple-darwin12.2.1
checking host system type... x86_64-apple-darwin12.2.1
checking target system type... x86_64-apple-darwin12.2.1
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@amalrik
amalrik / gist:6455567
Last active December 22, 2015 09:59 — forked from alotaiba/gist:913313
rsync -avz /path/to/local/sync/folder -e "ssh -i /path/to/ssh/id_rsa" ubuntu@ec2instance:/path/to/remote/sync/folder
# Setting up a local solr instance on a mac
# install solr with homebrew
brew install solr
# create the base solr index directory
mkdir -p /data/solr
# make sure you can write to the solr logs
sudo chown -R `whoami` /usr/local/Cellar/solr/
#!/usr/bin/env ruby
# 2011-10-10 20:57:53 +1000
def merge_sort(a)
return a if a.size <= 1
l, r = split_array(a)
result = combine(merge_sort(l), merge_sort(r))
end