Skip to content

Instantly share code, notes, and snippets.

View guilherme's full-sized avatar
🤔

Guilherme Campos guilherme

🤔
View GitHub Profile
@guilherme
guilherme / gist:1747696
Created February 5, 2012 19:53
bookmailer test.
# application.rb
to(:tag, "put") do
subject = request.subject
title,url = subject.split(' ').map { |x| x.strip }
note = request.body
params = { :title => title, :url => url, :note => note }
bookmarks.add_bookmark(params)
respond :subject => "Bookmark saved #{title}"
end
@guilherme
guilherme / gist:1988720
Created March 6, 2012 20:13
Regexp ruby
1.9.2p290 :013 > "abcd test 123".match(/(?<title>([\p{Word} ]*))((?<test>test 123)|(?<test>123))/)
=> #<MatchData "abcd test 123" title:"abcd test " test:nil test:"123">
# REGEXP Y U NO MATCH THE ENTIRE STRING (test 123) ?
1.9.2p290 :018 > "abcd test 123".match(/([\p{Word} ]*)(test 123|123)/)
=> #<MatchData "abcd test 123" 1:"abcd test " 2:"123">
@guilherme
guilherme / gist:1989028
Created March 6, 2012 21:19
schedule.rb
# encoding : utf-8
class Schedule
TITLE = /([\p{Word} ]*)/
TIME_ADVERB = /(hoje|amanhã|depois de amanhã|semana que vem)/i
DAY_OF_WEEK = /(Domingo|Segunda|Terca|Quarta|Quinta|Sexta|Sabado|Dom|Seg|Ter|Qua|Qui|Sex|Sab)/
MINUTE = /([0-6][0-9])/
HOUR = /([0-2][0-9])/
@guilherme
guilherme / fuck_msnbot.sh
Created March 22, 2012 12:52
aliviando o trafego da aplicação
#!/bin/sh
iptables -A INPUT -s 64.4.0.0/18 -p tcp -j DROP
iptables -A INPUT -s 65.52.0.0/14 -p tcp -j DROP
iptables -A INPUT -s 157.56.0.0/14 -p tcp -j DROP
iptables -A INPUT -s 157.60.0.0/16 -p tcp -j DROP
iptables -A INPUT -s 157.54.0.0/15 -p tcp -j DROP
iptables -A INPUT -s 207.46.0.0/16 -p tcp -j DROP
include "/etc/drbd.d/global_common.conf";
resource r0 {
protocol C;
syncer {
rate 100M;
}
on pc1 {
device /dev/drbd1;
disk /dev/sdb1;
@guilherme
guilherme / drdb_setup_master.sh
Created March 29, 2012 17:32
setup drbd master
#!/bin/bash
ifconfig eth0 192.168.0.35/24 up
hostname pc1
/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
drdbadm -- -o primary r0
#!/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
// 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:
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
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;