Skip to content

Instantly share code, notes, and snippets.

@defsprite
defsprite / gist:6264429
Last active December 21, 2015 06:29
Create a totally fake mac address.
# create a fake mac address
(1..6).map { '%02X' % rand(256) }.join(":")
class SimpleHashRingBuffer < Hash
def initialize(max_keys = 4096)
@max_keys = max_keys - 1
end
def []=(key, value)
if self.size > @max_keys
[sassi@csassenberg ~]$ irb
1.9.3-p125-perf :001 > require 'date'
=> true
1.9.3-p125-perf :002 > require 'time'
=> true
1.9.3-p125-perf :003 > DateTime.new.to_time
=> -4712-01-01 00:00:00 +0000
1.9.3-p125-perf :004 >
@defsprite
defsprite / strophe.websocket.js
Created March 7, 2011 19:05 — forked from processone/strophe.websocket.js
a (w)hacky strophe websockets connection implementation
/** Class: Strophe.WebSocket
* XMPP Connection manager.
*
* Thie class is the main part of Strophe. It manages a BOSH connection
* to an XMPP server and dispatches events to the user callbacks as
* data arrives. It supports SASL PLAIN, SASL DIGEST-MD5, and legacy
* authentication.
*
* After creating a Strophe.Connection object, the user will typically
* call connect() with a user supplied callback to handle connection level