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
# 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 |
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
# 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 |
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
sudo ipfw pipe 1 config bw 15KByte/s | |
sudo ipfw add 1 pipe 1 src-port 80 | |
sudo ipfw delete 1 |
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 "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 |
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 "net/http" | |
threads = [] | |
1000.times do | |
threads << Thread.new do | |
while true do | |
Net::HTTP.new("www.example.com").get("/") | |
end | |
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
# 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" |
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
# 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! |
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
# Pluralised single letter | |
"p's & q's" |
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 "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'}) |
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 "tumblr" | |
require "builder" | |
class TumblrSitemap | |
@@posts = [] | |
def initialize(tumblr_url) | |
@tumblr_url = tumblr_url | |
end | |