Skip to content

Instantly share code, notes, and snippets.

View bithive's full-sized avatar

bithive bithive

  • Reed College
  • Portland, OR
View GitHub Profile
@bithive
bithive / arp.rb
Created June 3, 2011 22:16
ARP for eth0:*
#!/usr/bin/env ruby
# ARPs for all the IPs aliased to this machine.
data = %x[ifconfig -a].split /\n\n/
data.each do |block|
d = /(eth\d:\d+)\s+/.match(block)
a = /inet addr:(\d+\.\d+\.\d+\.\d+)/.match(block)
@bithive
bithive / totp.rb
Created May 23, 2011 23:19
Generate Google Authenticator codes in Ruby (requires base32 gem)
#!/usr/bin/env ruby
require 'rubygems'
require 'base32'
require 'openssl'
int = 30
now = Time.now.to_i / int
key = Base32.decode File.read('secret.key').strip