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
#!/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 |
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
#!/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 |
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 "/etc/drbd.d/global_common.conf"; | |
resource r0 { | |
protocol C; | |
syncer { | |
rate 100M; | |
} | |
on pc1 { | |
device /dev/drbd1; | |
disk /dev/sdb1; |
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
#!/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 |
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
# 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])/ |
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
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"> |
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
# 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 |
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 Newman | |
module ActAsPingPong | |
def self.extended(klass) | |
klass.instance_eval do | |
to(:tag, "ping") do | |
respond(:subject => "pong") | |
end | |
end | |
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
# acid_tests.rb | |
# Add another case: | |
# as you may see it not raises a logical error. it accepts multiple applications | |
describe "Two applications on the same server" do | |
it "emulates a simple mail list and respond to ping pongs" do | |
mailer.deliver_message(:from => "[email protected]", | |
:to => "[email protected]") | |
server.tick([Newman::Examples::SimpleList,Newman::Examples::PingPong]) |
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 Paperclip | |
class << self | |
def each_instance_with_attachment(klass, name) | |
unscope_method = class_for(klass).respond_to?(:unscoped) ? :unscoped : :with_exclusive_scope | |
class_for(klass).send(unscope_method) do | |
class_for(klass).find_in_batches(:batch_size => 20) do |instance_batches| | |
instance_batches.each do |instance| | |
yield(instance) if instance.send(:"#{name}?") | |
end | |
end |