Skip to content

Instantly share code, notes, and snippets.

View lune-sta's full-sized avatar

lune* lune-sta

  • Rabbit Lab LLC
  • Japan
View GitHub Profile
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
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
p = Place.new(i) do |i|
case i
when 0
...
when 1
...
else
the_world
end
end
class Place
def initialize(..., &proc)
...
@lune-sta
lune-sta / a.rb
Last active August 29, 2015 14:14
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
@lune-sta
lune-sta / a.rb
Last active August 29, 2015 14:14
$shared['x'] = 100
# -*- 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
# -*- 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
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
=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