This file contains 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 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 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 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 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 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 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 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 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: |
This file contains 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
#!/bin/bash | |
ifconfig eth0 192.168.0.65/24 up | |
hostname pc2 | |
/etc/rc.d/rc.drbd stop | |
modprobe drbd | |
dd if=/dev/zero bs=1M of=/dev/sdb1 count=1 | |
curl https://gist.github.com/raw/2240291/addabf203f711db2c23fcd717a821321cad64e11/drbd.conf > /etc/drbd.conf | |
drbdadm create-md r0 | |
drbdadm up r0 | |
/etc/rc.d/rc.drbd start |