Skip to content

Instantly share code, notes, and snippets.

@tlossen
tlossen / siberite_demo.rb
Created January 23, 2017 09:54
playing around with the siberite ruby client
require 'siberite-client'
prefix = ARGV[0]
Thread.new do
queue = Siberite::Client.new('localhost:22133', 'localhost:22144')
i = 0
loop do
i += 1
item = "#{prefix}#{i}"
@tlossen
tlossen / UQuery.cs
Created June 25, 2015 09:50
uquery is like jquery, but for the unity 4.6 ui elements. sort of.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class UQuery : MonoBehaviour
{
protected GameObject GO(GameObject go, params int[] indexes) {
return GO(go.transform, indexes);
}
@tlossen
tlossen / redis_swarmd.rb
Created October 18, 2012 19:49
redis swarm daemon (proof-of-concept implementation)
#!/usr/bin/env ruby
require 'socket'
require 'thread'
require 'set'
REDIS = ['localhost', 6379]
UDP = ['172.18.167.255', 7777]
WHITELIST = ['sadd', 'srem']
class SafeSet < Set
@tlossen
tlossen / xing.rb
Created March 30, 2012 12:47
extract emails from vcf file
#! /usr/bin/env ruby
puts(open("vcards-XING.vcf").lines.map do |line|
$1.chomp if line =~ /^EMAIL.*:(.*)$/
end.compact.uniq.join(','))
@tlossen
tlossen / bunny.rb
Created March 7, 2012 14:25
cloby is magic!
require 'rubygems'
require 'cloby'
class Bunny < Clojure::Object
def initialize
@alive = true
end
def kill!
@alive = false
@tlossen
tlossen / example.rb
Created February 21, 2012 15:54
playing with cloby
require 'rubygems'
require 'cloby'
Ref = Java::clojure.lang.Ref
class Foo < Clojure::Object
attr_accessor :count
def initialize(count = 1)
@count = count
@tlossen
tlossen / diskstore_inspector.rb
Created January 24, 2012 15:33
parse redis diskstore files (which contain hashes)
# encoding: UTF-8
# dependencies:
# - wget http://dist.schmorp.de/liblzf/liblzf-3.6.tar.gz
# - gem install lzfruby
require 'lzfruby'
require 'stringio'
class DiskstoreInspector
@tlossen
tlossen / id.rb
Created December 10, 2009 09:25
how to generate a unique id which can be validated to be authentic
require 'digest'
module Id
SECRET = 'nobody knows the trouble'
def self.generate
a = digest("#{Time.now.to_f}:#{rand}")
b = digest(SECRET + a)
id = a + b