Skip to content

Instantly share code, notes, and snippets.

View m0wfo's full-sized avatar

Chris Mowforth m0wfo

  • Planet Earth
View GitHub Profile
# General format:
# dig {NS} {RECORDTYPE} {zone} {OPTIONS}
# Where RECORDTYPE is normally one of:
# {A,MX,CNAME,TXT,SRV,AAAA,PTR,SIG} etc
# Query type defaults to A records, so
dig google.com
# is equivalent to:
dig A google.com
# A quick & dirty approach:
(1..255).each {|ip| p `dig -x 192.168.1.#{ip} +noall +answer` }
# A more idiomatic solution:
require "socket"
(1..255).each do |ip|
host_info = Socket.getaddrinfo("192.168.1.#{ip}", nil).map {|i| {i[2] => i[3]} unless i[2] == i[3]}[0]
p host_info unless host_info.nil?
end
sudo ipfw pipe 1 config bw 15KByte/s
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw delete 1
@m0wfo
m0wfo / gist:93369
Created April 10, 2009 23:41
Sinatra DAAP Server
require "sinatra"
before do
content_type "application/x-dmap-tagged", :charset => "utf-8"
headers "DAAP-Server" => "Simple"
headers "Expires" => "-1"
headers "Cache-Control" => "no-cache"
headers "Accept-Ranges" => "bytes"
headers "Content-Language" => "en_us"
end
require "net/http"
threads = []
1000.times do
threads << Thread.new do
while true do
Net::HTTP.new("www.example.com").get("/")
end
end
# Singular form
"The beer of the guy" => "The guy's beer"
# Plural form
"The beers of the men" => "The men's beers"
# Plural form ending in 's'
"The beers of the guys" => "The guys' beers"
# A simple assertion like this:
"You are" => "You're"
# or this:
"Should not" => "Shouldn't"
# IS NOT THE SAME AS THIS!!!!
"Your" != "You're"
# OR THIS!
# Pluralised single letter
"p's & q's"
require "net/https"
require "uri"
url = URI.parse('test.sagepay.com/gateway/service/direct3dcallback.vsp')
req = Net::HTTP::Post.new(url.path)
# Pass back the MD and PaRes params from card issuer.
# You can only do this once per transaction.
req.set_form_data({'PaRes' => 'very long PaRes string', 'MD' => 'shorter'})
require "tumblr"
require "builder"
class TumblrSitemap
@@posts = []
def initialize(tumblr_url)
@tumblr_url = tumblr_url
end