Archive for April, 2011
Ruby function STFU: temporarily redirect noisy stdout writes to /dev/null
This function is handy if you have some third-party gem that generates writes to stdout or stderr which you wish to suppress. Simple wrap your call to the noisy function in an `stfu’ block. If an exception is thrown, it will be reopened with stdout and stderr pointing to the console again.
def stfu
begin
orig_stderr = $stderr.clone
orig_stdout = $stdout.clone
$stderr.reopen File.new('/dev/null', 'w')
$stdout.reopen File.new('/dev/null', 'w')
retval = yield
rescue Exception => e
$stdout.reopen orig_stdout
$stderr.reopen orig_stderr
raise e
ensure
$stdout.reopen orig_stdout
$stderr.reopen orig_stderr
end
retval
end
require 'some_noisy_gem'
stfu do
some_function_that_generates_a_lot_of_cruft_on_stdout
end
Add an HTTP Host column to Wireshark
Diagnosing HTTP traffic in Wireshark can be a pain because it is not always clear from the Info column where the traffic is going. All those “GET / HTTP/1.1″ blend together. Fortunately it’s easy to add a column.
Go to Edit -> Preferences -> User Interface -> Columns. Click “+ Add”, and for “Field type” select Custom. The “Field name” box will now be enabled. In it type “http.host”. Click the “New column” text above to set the display name to “HTTP Host.” Hit OK and you are done!
