Skip to content

Instantly share code, notes, and snippets.

@filipechagas
filipechagas / snippet_html_to_haml
Created May 25, 2012 03:33
Converting ERB to HAML
$ find . -name '*erb' | \
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \
bash
from: http://shifteleven.com/articles/2008/06/08/converting-erb-to-haml-snippet
source: http://www.winksaville.com/blog/linux/git-applying-patches/
Today learned some things about git and applying patches. First when applying my trec/ace/kshmem patches to 2.6.25-rc2 they wouldn’t apply because now there only an x86 architecture (arch/x86) instead of two architectures i386 and x86_64. That was to be expected actually and there’s going to be some hand work in doing that.
To do this hand work I really need to see what my current patches look like and there isn’t quite enough context in the patch file to do that, at least for me. So I cloned the current linux-2.6 tree into a new directory linux-2.6-x and did a checkout of 2.6.21-rc6 which is what my patches should apply against.
Well almost, there was still some need for a little tweaking; First git am will take my series of patches which were generated using git format-patch and apply them extracting from the email the commit message and the patch. It then creates a commit. But if there is a problem in a series only those that applied cl
@filipechagas
filipechagas / gist:3053925
Created July 5, 2012 14:16
Using grep to search a specific file type
grep -r --include=*.rb "some_string" some_directory
source: http://www.daniweb.com/community-center/threads/85626/limiting-grep-searches-to-a-given-file-type
@filipechagas
filipechagas / gist:3060452
Created July 6, 2012 14:25
Removing files with specific extension in one line
find . -name *.swp -exec rm -f {} \;
@filipechagas
filipechagas / gist:3077677
Last active October 7, 2015 00:37
Mac tips
Command + Option + Esc
pra encerrar o aplicativo em primeiro plano Command + Option +
Shift + Esc por uns 3 segundos
Acento Agudo (´): Option + E
C Com Cedilha (Ç): Option + C
Til (~): Optin + N
Acento Circunflexo (^): Option + I
Trema (¨): Option + U
@filipechagas
filipechagas / gist:3129202
Created July 17, 2012 12:41
Missing host to link to problem
# application_controller.rb
before_filter :mailer_set_url_options
...
def mailer_set_url_options
ActionMailer::Base.default_url_options[:host] = request.host_with_port
end
@filipechagas
filipechagas / gist:3130579
Created July 17, 2012 16:55
OSX irb utf-8 problem
Install ruby after defining cppflags and ldflags pointing to readline
$ brew install readline
$ export CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include
$ export LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib/
$ rbenv install 1.9.3-rc1
@filipechagas
filipechagas / gist:3138147
Created July 18, 2012 19:09
Soap4r problem - no such file to load -- soap/wsdlDriver
Clone that guy:
git clone https://github.com/spox/soap4r-spox.git
and install running ruby setup.rb all
@filipechagas
filipechagas / gist:3181923
Created July 26, 2012 13:03
Rails DateTime Localization - Var format meaning
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
@filipechagas
filipechagas / gist:3277012
Created August 6, 2012 17:40
Mountain Lion - Ruby compilation errors
# Install the gcc compiler 4.2
brew tap homebrew/dupes
brew install apple-gcc42
# Install xquartz http://xquartz.macosforge.org/landing/
export CPPFLAGS=-I/opt/X11/include
CC=/usr/local/bin/gcc-4.2 rvm reinstall ree --disable-tcl --disable-tk
CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7 --disable-tcl --disable-tk