Skip to content

Instantly share code, notes, and snippets.

Ben Nagy bnagy

Block or report user

Report or block bnagy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2994849
#!/usr/bin/env ruby
require_relative "tabornok/irc"
require_relative "tabornok/logger"
require_relative "tabornok/console"
require "thread"
class Tabornok
def initialize
bnagy / Monokai - Soda.tmTheme
Created Jun 28, 2012
ST2 Ruby - highlight ivars / interpolation
View Monokai - Soda.tmTheme
<string>String interpolation</string>
<string>string source.ruby</string>
View zk_monitor.rb
require 'zk'
require 'msgpack'
class Events
def initialize
@zk =
@root_node = '/fuzz'
@node_metadata=MessagePack.pack 'required_workers'=>3
if @zk.stat( @root_node ).exists?
@zk.set @root_node, @node_metadata
View compress_test.rb
def tc_deflate!( set )
# Single thread / core only!
cached={}! {|elem|
unless (idx=@tc[elem]) #already there
Integer( cur )
View zk_node.rb
require 'zk'
require 'msgpack'
zk =
root_node = '/fuzz'
3.times do
View match_ncd.rb
# Find the closest template to match a crashfile using the Normalised
# Compression Distance (NCD), defined as:
# NCD(x,y)=( C(xy) - min{C(x), C(y)} ) / max{C(x), C(y)}
# Based on my testing, LZMA works best, which is implemented in xz for *nix,
# bzip2 (Burrows-Wheeler) works well enough but zip doesn't differentiate well
# and will be flat out wrong sometimes.
# Author: Ben Nagy Copyright: Copyright (c) Ben Nagy, 2006-2012.
# License: The MIT License
bnagy / searchers.rb
Created Aug 22, 2012
threadsafe search engine automation
View searchers.rb
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.configure do |config|
config.run_server = false
config.default_driver = :poltergeist
module Searchers
View gist:3494934
OPTS=Trollop::options do
opt :config, "Config filename", :type => :string
opt :keep, "Don't overwrite existing trace results", :type=>:boolean
opt :pi, "Calculate Pi (requires md5sum filenames)", :type=>:boolean
opt :strict, "Only send files with the configured extension", :type=>:boolean
opt :debug, "Enable debug output", :type=>:boolean
CONFIG=YAML.load_file( OPTS[:config] ) unless defined? CONFIG
View wintypes.rb
# This is mainly so that the rest of the code will appear consistent with
# Windows documentation, and allows me to quickly prototype new APIs by copying
# directly from MSDN.
# Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2012.
# License: The MIT License
# (See for details.)
require 'ffi'
View gist:5175611
class Player
def initialize(name, health=100)
@name = name.capitalize
@health = health
def say_hello
puts "I'm #{@name} with a health of #{@health}."
You can’t perform that action at this time.