Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require_relative "tabornok/irc"
require_relative "tabornok/logger"
require_relative "tabornok/console"
require "thread"
class Tabornok
def initialize
@bnagy
bnagy / Monokai - Soda.tmTheme
Created June 28, 2012 05:28
ST2 Ruby - highlight ivars / interpolation
<dict>
<key>name</key>
<string>String interpolation</string>
<key>scope</key>
<string>string source.ruby</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
require 'zk'
require 'msgpack'
class Events
def initialize
@zk = ZK.new
@root_node = '/fuzz'
@node_metadata=MessagePack.pack 'required_workers'=>3
if @zk.stat( @root_node ).exists?
@zk.set @root_node, @node_metadata
def tc_deflate!( set )
# Single thread / core only!
cur=@tc.size/2
cached={}
set.map! {|elem|
unless (idx=@tc[elem]) #already there
cur+=1
cached[cur]=elem
cached[elem]=cur
Integer( cur )
require 'zk'
require 'msgpack'
zk = ZK.new
root_node = '/fuzz'
3.times do
my_metadata={'value'=>rand(32)}
me=zk.create(
File.join(root_node,'fuzzer'),
# 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
bnagy / searchers.rb
Created August 22, 2012 09:17
threadsafe search engine automation
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.configure do |config|
config.run_server = false
config.default_driver = :poltergeist
end
module Searchers
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
end
CONFIG=YAML.load_file( OPTS[:config] ) unless defined? CONFIG
@bnagy
bnagy / wintypes.rb
Created September 29, 2012 09:31
types
# 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 http://www.opensource.org/licenses/mit-license.php for details.)
require 'ffi'
class Player
def initialize(name, health=100)
@name = name.capitalize
@health = health
end
def say_hello
puts "I'm #{@name} with a health of #{@health}."
end