Skip to content

Instantly share code, notes, and snippets.

View mhfs's full-sized avatar

Marcelo Silveira mhfs

View GitHub Profile
root@server:~# export CMDTEST='su cpfcnpj_mhfs_com_br -c "/usr/local/bin/unicorn -D -E production -c config/unicorn.rb"'
root@server:~# echo $CMDTEST
su cpfcnpj_mhfs_com_br -c "/usr/local/bin/unicorn -D -E production -c config/unicorn.rb"
root@server:~# $CMDTEST
su: invalid option -- 'D'
U
@mhfs
mhfs / gist:726872
Created December 3, 2010 11:53
VIM Strip Trailing Whitespaces
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
Creating a gist from textmate
class Note; end
class C < Note; end
class Cs < C; end
class D < Note; end
class Db < D; end
class Ds < D; end
class E < Note; end
@mhfs
mhfs / gist:468180
Created July 8, 2010 15:45
Textmate shortcuts
Ctrl-L gives a hashrocket with spaces
Shift-Ctrl-[ alternate between {} and do/end blocks
Shit-Cmd-D open the require file in another window
Ctrl-shift-V validates syntax of ruby file
Ctrl-shift-E executes the line
Ctrl-shift-; alternate between string and symbol
Shift-Option-Cmd-Down show possible destinations
Ctrl-Shift-H create partial from selection
Ctrl-P gives params[:id]
@mhfs
mhfs / bmp_negator.py
Created June 14, 2010 17:31 — forked from mcrisc/bmp_negator.py
Jau Py
# coding: utf-8
import struct
with open('in.bmp', 'rb') as fd, open('out.bmp', 'wb') as out:
s = fd.read(1)
count = 1
while s:
if count < 37: # header bytes
out.write(s)
@mhfs
mhfs / imagemagick_rmagick.rb
Created February 3, 2010 17:57
Homebrew ImageMagick formula that plays nice with RMagick
require 'formula'
# some credit to http://github.com/maddox/magick-installer
# NOTE please be aware that the GraphicsMagick formula derives this formula
def ghostscript_srsly?
ARGV.include? '--with-ghostscript'
end
def x11?
@mhfs
mhfs / factories.rb
Created February 2, 2010 01:58 — forked from technicalpickles/factories.rb
Factory Girl Attachment
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
def mod10_febraban(value)
result_string = ""
factor = 2
total = 0
value.each_char do |c|
result_string << (c.to_i * factor).to_s
factor = (factor == 2 ? 1 : 2)
end
result_string.each_char { |c| total += c.to_i }
result = 10 - total % 10
# My Method
def mymethod
# My puts
puts "Ruby Rocks"
end