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 'twitter' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = "YOUR_CONSUMER_KEY" | |
config.consumer_secret = "YOUR_CONSUMER_SECRET" | |
config.access_token = "YOUR_ACCESS_TOKEN" | |
config.access_token_secret = "YOUR_ACCESS_SECRET" | |
end | |
n = STDIN.gets |
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
iptables -F | |
iptables -X | |
iptables -Z | |
iptables -P INPUT ACCEPT | |
iptables -P OUTPUT ACCEPT | |
iptables -P FORWARD ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT |
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
p = Place.new(i) do |i| | |
case i | |
when 0 | |
... | |
when 1 | |
... | |
else | |
the_world | |
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
class Place | |
def initialize(..., &proc) | |
... |
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
PROCESSORS = (ARGV[0] || 1).to_i | |
pids = [] | |
workers = PROCESSORS.times.map do |i| | |
uri = "druby://localhost:#{12345 + i}" | |
pids << fork { DRb.start_service(uri, MonteCarlo.new(i)); sleep } | |
DRbObject.new_with_uri(uri) | |
end | |
begin |
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
$shared['x'] = 100 |
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
# -*- coding: utf-8 -* | |
Encoding.default_external = 'UTF-8' | |
require 'pp' | |
dir = "./" | |
hash = Hash.new{|k, v| k[v] = Hash.new} | |
nums = [] | |
Dir::glob(dir + "*.txt").each do |f| | |
nums << n = f.scan(/\d+/)[0].to_i |
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
# -*- coding: utf-8 -* | |
dir = "./" | |
hash = Hash.new{|k, v| k[v] = Hash.new} | |
nums = [] | |
Dir::glob(dir + "*.txt").each do |f| | |
nums << n = f.scan(/\d+/)[0].to_i | |
open(f).read.split("\n").each do |a| | |
count, word = a.split |
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
def fork_join(processor_count) | |
cg = CG.new | |
processor_count.times do | |
p = Place.new do | |
end | |
cg.add_place(p) | |
end | |
yield cg | |
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
=begin | |
def method_missing(name, *argv, &block) | |
if name =~ /^def_/ | |
source, args = block.to_source(argv) | |
def_macro(name, source, args) | |
else | |
p 'macro_' + name.to_s | |
if Ixia.method_defined?(('macro_' + name.to_s).to_sym) | |
Ixia.send('macro_' + name.to_s) | |
else |
NewerOlder