Skip to content

Instantly share code, notes, and snippets.

View taq's full-sized avatar

Eustáquio Rangel taq

View GitHub Profile
@taq
taq / gist:10663010
Created April 14, 2014 16:26
Vim plugins
ack.vim
bufexplorer
camelcasemotion
csv.vim
ctrlp.vim
emmet-vim
L9
nerdcommenter
nerdtree
syntastic
@taq
taq / nginx
Created April 21, 2014 00:47
Nginx Ubuntu service
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@taq
taq / circular.rb
Created February 17, 2015 14:54
Ruby 2.2.0 circular reference problem
class FooBar
def foo
"I'm in foo!"
end
def bar(foo = foo)
puts foo
end
end
@taq
taq / keybase.md
Created May 27, 2015 10:27
keybase.md

Keybase proof

I hereby claim:

  • I am taq on github.
  • I am taq (https://keybase.io/taq) on keybase.
  • I have a public key whose fingerprint is 840B 7492 E475 8DB6 B5DE 81D0 6611 4C70 E7F6 C0C0

To claim this, I am signing this object:

class Test
class << self
attr_accessor :count
end
@count = 0
def initialize
self.class.count += 1
end
end
class ActiveRecord::Base
def self.find_by_sample(sample)
columns = self.columns.reject {|column| %w(id created_at updated_at).include?(column.name) }
cond_str, cond_val = [], []
columns.each do |column|
value = sample.send(column.name)
next if value.nil?
cond_str << "#{column.name}=?"
cond_val << value
end
module ActionView
module Helpers
module FormHelper
def email_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("email", options)
end
def url_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("url", options)
end
def search_field(object_name, method, options = {})
__rvm_ps1 () {
if [ ! -f ~/.rvm/bin/rvm-prompt ]; then
exit 0
fi
RVM_VERSION=$(~/.rvm/bin/rvm-prompt)
FMT="%s"
if ([ -f "$(pwd)/Rakefile" ] ||
[ "$(find . -maxdepth 1 -name '*.rb' | head -n1)" != "" ]) &&
[ ! -z "$RVM_VERSION" ]; then
if [ -n "$1" ]; then
$ rvm install 1.9.2 --trace &> /tmp/rvm.log
1.9.2 --trace
rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
+ /scripts/cli : __rvm_parse_args() 693 > [[ -n '' ]]
+ /scripts/cli : __rvm_parse_args() 694 > export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ /scripts/cli : __rvm_parse_args() 694 > PS4='+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ /scripts/cli : __rvm_parse_args() 722 > [[ -z install ]]
+ /scripts/cli : __rvm_parse_args() 724 > [[ 0 -eq 1 ]]
@taq
taq / binwrite.c
Created April 12, 2012 20:07
Escrevendo no arquivo, em C
#include <stdio.h>
int main(int argc, char **argv) {
int i = 123;
double d = 456789;
FILE *file;
file = fopen("teste.bin","wb");
printf("gravando int com %d bytes\n",sizeof(int));
fwrite(&i,sizeof(int),1,file);
printf("gravando double com %d bytes\n",sizeof(double));