This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Based on answer found here: | |
# http://stackoverflow.com/questions/7618598/unpack-base64-encoded-32bit-integer-representing-ip-address | |
require 'base64' | |
class App | |
def run(arg) | |
base642ip(arg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'csv' | |
require 'ostruct' | |
require 'optparse' | |
require 'i18n' | |
require 'set' # this should only be required until i18n updates to new rev | |
require 'active_support/core_ext/string/inflections' | |
I18n.enforce_available_locales = true # I18n spams warn unless this is set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using a block allows you to limit the scope of the Interrupt handling code, | |
# as well as providing the opportunity to provide a meaningful exit code. For | |
# more information on exit codes, see: http://tldp.org/LDP/abs/html/exitcodes.html | |
begin | |
sleep 10 | |
rescue Interrupt | |
$stderr.puts "Stopped sleeping..." | |
exit 130 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
('2500'.to_i(16)..'257F'.to_i(16)).map { |i| [i.to_s(16), [i].pack('U')] }.each { |c| puts "%s: %s" % [c[0], c[1]] };0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'lib/portaudio' | |
class AudioTest | |
include PortAudio | |
def initialize | |
PortAudio.init | |
@devices = get_devices | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
alias e puts | |
N = "\n" | |
N_TIMES = 550_000 # Run it n times. | |
e 'We will next compare the elimination of the character "f"' | |
e 'by comparing the methods .delete .gsub and .tr'+N+N | |
# Our Test String comes next. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
attr_accessor :baz, :qux, :quux, :corge, :grault, :garply, :waldo, :fred, :plugh, :xyzzy, :thud | |
def initialize(bar) | |
@bar = bar | |
@baz = 'baz' | |
@qux = 'qux' | |
@quux = 'quux' | |
@corge = 'corge' | |
@grault = 'grault' | |
@garply = 'garply' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark/ips' | |
require 'time' | |
if defined?(JRUBY_VERSION) | |
JODA_FMT = org.joda.time.format::DateTimeFormat.for_pattern("Y-M-d H:m:s Z") | |
end | |
def joda_time(time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ByteBuffer | |
attr_reader :bytes | |
# A ByteBuffer accepts encoded string buffers and unpacks them to an | |
# internal array of bytes stored using fixnum so that binary operations can | |
# be easily performed. | |
def initialize(buffer, mode) | |
case mode | |
when 'a' # arbitrary string; converts to ascii char code (this is faster than String#ord) | |
@bytes = buffer.unpack('C*') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ghosttest.c: GHOST vulnerability tester */ | |
/* Credit: http://www.openwall.com/lists/oss-security/2015/01/27/9 */ | |
#include <netdb.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#define CANARY "in_the_coal_mine" | |
OlderNewer