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
bnagy / Monokai - Soda.tmTheme
Created Jun 28, 2012
ST2 Ruby - highlight ivars / interpolation
View Monokai - Soda.tmTheme
<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>
View zk_monitor.rb
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
View compress_test.rb
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 )
View zk_node.rb
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'),
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
bnagy / searchers.rb
Created Aug 13, 2012
trying to make a threadsafe capybara poltergeist searcher
View searchers.rb
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.configure do |config|
config.run_server = false
config.default_driver = :poltergeist
end
module Searchers
@bnagy
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
end
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
end
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 http://www.opensource.org/licenses/mit-license.php for details.)
require 'ffi'
You can’t perform that action at this time.