Skip to content

Instantly share code, notes, and snippets.

View film42's full-sized avatar
✔️
Verified

Garrett Thornburg film42

✔️
Verified
View GitHub Profile
start = nil
NATS.start(:servers => ['nats://198.199.103.139:4222']) do
start = Time.now
NATS.subscribe('demo', :queue => 'group.things') do |msg, reply|
puts "Hitting node 1 with #{msg}"
NATS.publish(reply, "Polo1!")
end
NATS.subscribe('demo', :queue => 'group.things') do |msg, reply|
package main
import (
"bytes"
"strconv"
)
////
// Query Builder
//
Thread.new do
trap(:TRAP) do
::Thread.list.each do |thread|
puts <<-THREAD_TRACE
#{thread.inspect}:
#{thread.backtrace.try(:join, $INPUT_RECORD_SEPARATOR)}"
THREAD_TRACE
end
end
end
class EnumDeliveryType < ::Protobuf::Enum
define :STANDARD, 1
define :PRIORITY, 2
define :NEXT_DAY, 3
define :OVERNIGHT, 4
end
# # # # # # # # # # # # # PART 1 # # # # # # # # # # # # #
##
@film42
film42 / ar.rs
Last active September 16, 2015 05:41
trait Queryable {
fn pluralized_table_name(&self) -> String;
fn predicates(&self) -> &Vec<String>;
fn has_limit(&self) -> bool {
return self.limit_value() >= 0;
}
fn limit_value(&self) -> i64;
defmodule Rpc do
defmodule ServiceDirectory do
defmodule Instance do
defstruct address: nil, port: nil, expires_at: nil, uuid: nil
end
##
# USAGE:
#
# Rpc.ServiceDirectory.start_link(port: 53023)
require "socket"
# Detect if a socket is in CLOSE_WAIT
def socket_in_close_wait?(socket)
# Will return empty string on EOF (closed socket)
socket.recv_nonblock(1, ::Socket::MSG_PEEK) == ""
rescue IO::WaitReadable
false
end
class AnyPage
attr_reader :sql
def initialize(sql, options = {})
@page_size = options.fetch(:page_size) { 1000 }
@sql = sql
@total_pages = nil
end
def self.page(sql, nth, options = {})
;;; ujelly-theme-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "ujelly-theme" "ujelly-theme.el" (21808 38161
;;;;;; 0 0))
;;; Generated autoloads from ujelly-theme.el
Benchmark.measure { 10_000.times { ActionSubscriber::Publisher.publish("test", "test", "test") } }
5.590000 2.110000 7.700000 ( 14.262266)
Benchmark.measure { 10_000.times { ActionSubscriber::Publisher.publish_async("test", "test", "test") } }
0.030000 0.000000 0.030000 ( 0.025184)