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
class NetLinx::Parser | |
token IDENTIFIER | |
token DPS NUMBER DECIMAL STRING COMMENT | |
token CHAR WIDECHAR INTEGER SINTEGER LONG SLONG FLOAT DOUBLE DEV DEVCHAN | |
token IF ELSE IF ELSE SELECT ACTIVE SWITCH CASE FOR WHILE MEDIUM_WHILE LONG_WHILE BREAK DEFAULT RETURN | |
token DEFINE_CALL DEFINE_COMBINE DEFINE_CONNECT_LEVEL DEFINE_CONSTANT DEFINE_DEVICE DEFINE_EVENT DEFINE_FUNCTION DEFINE_LATCHING DEFINE_MODULE DEFINE_MUTUALLY_EXCLUSIVE DEFINE_PROGRAM DEFINE_START DEFINE_TOGGLING DEFINE_TYPE DEFINE_VARIABLE PROGRAM_NAME | |
token BUTTON_EVENT CHANNEL_EVENT DATA_EVENT LEVEL_EVENT REBUILD_EVENT | |
prechigh |
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
#!/usr/bin/env ruby | |
# ----------------------------------------------------------------------------- | |
# | |
# The MIT License (MIT) | |
# | |
# Copyright (c) 2014 Alex McLain | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
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
require '0mq' | |
@server_keys = ZMQ::Curve.keypair | |
@client_keys = ZMQ::Curve.keypair | |
@path = 'tcp://127.0.0.1:5050' | |
# @path = 'ipc://test.ipc' | |
@server = ZMQ::Socket.new ZMQ::PULL | |
@server.set_opt ZMQ::CURVE_SERVER, 1 |
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
# Moved to: | |
# https://github.com/amclain/icslan-config |
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
require '0mq' | |
require 'pry' | |
address = 'tcp://127.0.0.1:10000' | |
pull = ZMQ::Socket.new ZMQ::PULL | |
pull.bind address | |
# Push a message after a delay. | |
Thread.new do |
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
# Send a multipart message as an array of strings | |
def send_array(array) | |
ary = array.to_a | |
ary[0...-1].each { |str| send_string str.to_s, ZMQ::SNDMORE } | |
send_string ary.last.to_s | |
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
it "send_array attempts an array conversion if the object is not an array" do | |
data = Object.new.tap {|obj| | |
obj.instance_eval { def to_a; [1,2,3,4]; end } | |
} | |
push_sock.send_array data | |
pull_sock.recv_array.should eq data.to_a.map {|i| i.to_s } | |
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
require 'pry' | |
class Read | |
def initialize value = 0 | |
@value = value | |
end | |
def to_s | |
"#{@value}:Read" | |
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
# Works w/ zeromqrb updates. | |
require 'ffi-rzmq' | |
require 'zeromqrb' | |
Thread.abort_on_exception = true | |
class ZeroMQ::Socket | |
def recv_array | |
parts = [] | |
str = '' |
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
require 'zeromqrb' | |
require 'timeout' | |
ctx = ZeroMQ::Context.new | |
# Subscriber | |
sub_thread = Thread.new do | |
sub_sock = ctx.socket ZMQ::SUB | |
sub_sock.setsockopt ZMQ::SUBSCRIBE, '' #Subscribe to everything. |