Skip to content

Instantly share code, notes, and snippets.

@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)
#!/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'
input {
udp {
port => 5300
codec => 'json'
}
}
## the policy_router SQL filter
filter {
if ([type] == "policy_router") {
grok {
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 **
@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
@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 / client2.rb
Last active January 28, 2016 12:24
This is 2nd Client for Celluloid example
require 'celluloid/zmq'
Celluloid::ZMQ.init
class Client
include Celluloid::ZMQ
def initialize
@socket = Socket::Push.new
begin
@meetme2meat
meetme2meat / client1.rb
Last active January 28, 2016 12:24
Celluloid Client-1.
require 'celluloid/zmq'
Celluloid::ZMQ.init
class Client
include Celluloid::ZMQ
def initialize
@socket = Socket::Push.new
begin
...
...
...
use Warden::Manager
use Rack::Mongoid::Middleware::IdentityMap
use ExceptionNotifier
use OmniAuthMiddleware ## <--
use OmniAuth::Builder
run MyAppliction::Application.routes
require 'rubygems'
require 'json-schema'
## /poaster_instance.json
## Seem like the need to have access_control a part of this json
poaster_instance_schema = {
"type" => "object",
"required" => ['id','facades','name'],
"properties" => {
"id" => {"type" => "string"},
"name" => {"type" => "string"},