This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "O que é mais interessante? Adicionar callbacks(ActiveRecord like) ou criar uma classe encapsulando o comportamento 'extra' desejado." | |
# "What is more interesting? Add callbacks(ActiveRecord like) or create a class that encapsulate the desired 'extra' behavior." | |
class B | |
before :method, :before_method | |
... | |
before :method, :before_methodN | |
after :method, :after_method | |
... | |
after :method, :after_methodN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
def self.money_attributes(*attrs) | |
(attrs || []).each do |attr| | |
attr = attr.to_s | |
define_method attr do | |
read_attribute(attr).tap do |value| | |
value = value.to_money if value | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pthread.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/ipc.h> | |
#include <sys/sem.h> | |
void funcao1(int *id); | |
void funcao2(int *id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bash_profile | |
export CLICOLOR=1 | |
export LSCOLORS=gxfxcxdxbxegedabagacad | |
parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ →\ \1/' | |
} | |
export PS1='\[\e[1;37m\][\[\e[1;35m\]\u\[\e[1;37m\]@\[\e[1;32m\]\h\[\e[1;37m\]:\[\e[1;36m\]\w\[\e[1;31m\]$(parse_git_branch)\[\e[1;37m\]]$ \[\e[0m\]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before debug | |
// debug-start | |
var x = 'hello' | |
console.log(x); | |
// debug-end | |
after debug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
class ReferencedModelA < ActiveRecord::Base; end | |
class ReferencedModelB < ActiveRecord::Base; end | |
class ReferencedModelC < ActiveRecord::Base; end | |
class ModelA < ActiveRecord::Base | |
has_many :referenced_model_a | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
class ModelA < ActiveRecord::Base | |
end | |
class SubModelA < ModelA | |
end | |
p SubModelA.reflections.keys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = 'click change focus'.split(' '), // add more as needed | |
eLen = events.length, | |
eI = 0, | |
els = document.getElementsByTagName('*'), | |
len = els.length, | |
i = 0, | |
el; | |
var debug_mode = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g(x) h(x) f(x) | |
2 8 3 4 11 0 | |
1 6 4 4 11 0 | |
7 0 5 4 11 0 | |
g(x) h(x) f(x) | |
2 8 3 5 8 13 | |
1 0 4 5 8 13 | |
7 6 5 5 8 13 | |
g(x) h(x) f(x) | |
2 0 3 6 10 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Table.h | |
class Table { | |
private: | |
int h; | |
int g; | |
std::vector< std::vector<int> > pecas; | |
int _delta_l_c(int l_ini, int c_ini, int l_fim, int c_fim); | |
Table* parent; | |
public: |