Skip to content

Instantly share code, notes, and snippets.

@Asmod4n
Asmod4n / sse.rb
Last active December 18, 2015 12:09
Server Sent Events implemented in Ruby with Celluloid-io Eventend Server Reel using asynchronous Features from Celluloid
#!/usr/bin/env ruby
# Run with: ruby server_sent_events.rb
# Test with: curl -vNH 'Accept: text/event-stream' -H 'Last-Event-ID: 1' -H 'Cache-Control: no-cache' http://localhost:63310
require 'time'
require 'reel'
class ServerSentEvents < Reel::Server
include Celluloid::Logger
@Asmod4n
Asmod4n / html5-notifications.js
Last active June 18, 2019 22:57
A Polyfill to fix the differences in WebKit, Blink and Gecko HTML5 Desktop Notifications, also adds a way to add your own Javascript Notifications in case your Browser doesn't support them natively.
/*
Copyright (C) 2013 Hendrik Beskow
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@Asmod4n
Asmod4n / Gemfile
Created August 19, 2013 14:05
Endless loop with redis-pool
source 'https://rubygems.org'
gem 'redis-pool'
gem 'celluloid-redis'
gem 'ohm'
@Asmod4n
Asmod4n / Gemfile
Last active January 4, 2016 17:29 — forked from robertjpayne/server.rb
source 'https://rubygems.org'
platform :rbx do
gem 'rubysl'
end
gem 'reel', github: 'celluloid/reel'
gem 'websocket-driver'
gem 'rack'
@Asmod4n
Asmod4n / gem-public_cert.pem
Created March 3, 2014 18:23
My public gem signing cert
-----BEGIN CERTIFICATE-----
MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MRAwDgYDVQQDDAdoZW5k
cmlrMRYwFAYKCZImiZPyLGQBGRYGYmVza293MRIwEAYKCZImiZPyLGQBGRYCZGUw
HhcNMTQwMzAzMTgwNTUzWhcNMTUwMzAzMTgwNTUzWjA+MRAwDgYDVQQDDAdoZW5k
cmlrMRYwFAYKCZImiZPyLGQBGRYGYmVza293MRIwEAYKCZImiZPyLGQBGRYCZGUw
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrjCXwi7K4cXvKjVrlFNDM
USTsUPwdgnAF8mEGUmm4Xb2njK2gq+D3+i6krQCDiqBvi5h2EG/LK21mDWnkFc3t
809/F3KlPh+otlnL4UQFZNsGNgDHKmTMRfoaR+fOHouRxJQx0qEBf2fbKX/1/DeI
2APra5nRS/nbduIrYeO3zV+P0dGswyWot56K3wWGNA4LvYvpn0b6GYMm1JTOd+Ld
2gl+nxy7Bxu2cArOHwjcv59MsQNnaO9L9Un8AI0ZYCSL1vtfNycvAdcjsc7WiLEH
@Asmod4n
Asmod4n / zmqcurvezap.rb
Last active August 29, 2015 13:57
http://rfc.zeromq.org/spec:27 implementation in ruby Requirements: zeromq build with libsodium, Install: gem install rbnacl celluloid-zmq, Usage: ruby zmqcurvezap.rb
require 'rbnacl'
require 'celluloid/zmq'
require 'socket'
if Celluloid::ZMQ::VERSION == "0.15.0"
module Celluloid
module ZMQ
def self.evented?
actor = Thread.current[:celluloid_actor]
actor.mailbox.is_a?(Celluloid::ZMQ::Mailbox)
require 'json'
require 'active_support/core_ext/numeric/bytes'
require 'delegate'
require 'forwardable'
require 'time'
require 'celluloid/io'
require 'websocket/driver'
require 'webmachine'
require 'webmachine/adapters/rack'
require 'celluloid/autostart'
We couldn’t find that file to show.
@Asmod4n
Asmod4n / Gemfile
Created August 18, 2014 12:40
First stab at a new high level czmq wrapper in ruby
source 'https://rubygems.org'
gem 'pry'
platforms :ruby do
gem 'msgpack'
end
platforms :jruby do
gem 'msgpack-jruby', :require => 'msgpack'
end
@Asmod4n
Asmod4n / speed_test.rb
Last active August 29, 2015 14:07
Speed differences in FFI memory management
require 'ffi'
require 'benchmark'
module LibC
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :malloc, [:size_t], :pointer
attach_function :free, [:pointer], :void
end