Skip to content

Instantly share code, notes, and snippets.

@meetme2meat
meetme2meat / server1.rb
Last active January 28, 2016 12:20
the server-1 shamelessly copied from Celluloid-ZMQ README.md
## Using this as the Celluloid server the client messages are received in parallel.
require 'celluloid/zmq'
require 'colorize'
Celluloid::ZMQ.init
class Server
include Celluloid::ZMQ
def initialize()
@socket = Socket::Pull.new
@meetme2meat
meetme2meat / server2.rb
Last active January 28, 2016 12:21
Using the server2.rb as the server for the 2 clients does not yield parallelism.
require 'celluloid/zmq'
require 'colorize'
Celluloid::ZMQ.init
class Server
include Celluloid::ZMQ
def initialize()
@socket = Socket::Pull.new
class Ticket
def purchase
puts "** Purchasing the Ticket **"
end
alias_method :call,:purchase
end
## Following are they way you can invoke the download method
Ticket.new.purchase
## => ** Purchasing the Ticket **
input {
udp {
port => 5300
codec => 'json'
}
}
## the policy_router SQL filter
filter {
if ([type] == "policy_router") {
grok {
#!/usr/bin/env ruby
require 'celluloid/zmq'
require 'logger'
require 'airbrake-ruby'
#require 'logstash-logger'
Airbrake.configure do |c|
c.project_id = 123018
c.project_key = '552470f432b338efb3c4aab31412f93a'
c.environment = 'production'
@meetme2meat
meetme2meat / logstash.rb
Last active June 24, 2016 13:31
The following is the logstash-zeromq server for zeromq filter
#!/usr/bin/env ruby
## Please compile and install zeromq before running this script.
require 'rubygems'
require 'ffi-rzmq'
require 'json'
context = ZMQ::Context.new(1)
@meetme2meat
meetme2meat / logstash.conf
Last active June 24, 2016 13:30
The following is a logstash filter conf for zeromq
input {
stdin {
}
}
filter {
zeromq {
address => "tcp://127.0.0.1:8080"
mode => "client"
}
@meetme2meat
meetme2meat / gist:f22f0b62eeb314fb3c51eac96b059f1c
Created July 26, 2016 04:41
Ruby's performance tuning way
@meetme2meat
meetme2meat / test.rb
Created July 29, 2016 06:55
Test rb file.
require 'rubygems'
$zone = "-06:00"
require 'pry'
#inspect.txt
#rinspect.txt
MONTH= {"Jan" => 1,"Feb" =>2,"Mar" => 3,"Apr" => 4,"May" => 5,"Jun" => 6,"Jul" => 7,"Aug" => 8,"Sep" => 9,"Oct" => 10,"Nov" => 11,"Dec" => 12}.freeze
def find_time(time)
day = time.match(/^\d{2}/)[0].to_i
month = MONTH[time.match(/[A-Z][a-z]{2}/)[0]]
year = time.match(/\d{4}/)[0].to_i
@meetme2meat
meetme2meat / test-2.rb
Created July 29, 2016 06:56
Test-2 file
require 'rubygems'
$zone = "-06:00"
require 'pry'
#inspect.txt
#rinspect.txt
MONTH= {"Jan" => 1,"Feb" =>2,"Mar" => 3,"Apr" => 4,"May" => 5,"Jun" => 6,"Jul" => 7,"Aug" => 8,"Sep" => 9,"Oct" => 10,"Nov" => 11,"Dec" => 12}.freeze
def find_time(time)
day = time.match(/^\d{2}/)[0].to_i
month = MONTH[time.match(/[A-Z][a-z]{2}/)[0]]