cornet's blog
Bash Cures Cancer
cornet — Sun, 2008-02-24 23:47
Another site that I've just added to my feed list.
Quite a few things on here I wasn't aware of such as:
find . -name 'file-*' -delete
is much faster than
find . -name 'file-*' -exec rm {} \;
although I need to test how it compares to:
find . -name 'file-*' | xargs rm
Drupal 6 Released
cornet — Sat, 2008-02-23 18:46
Apparently the Drupal 6.0 passed me by completely..
Will look at upgrading soon to see what's new
Hacking BT Home Hubs
cornet — Tue, 2008-01-15 12:29
So first we have the BT Voyger that gave out your username and password if you asked it nicely.
Then, yet again, BT ship a router which another flaw in it.
I've always had this gut feeling that UPnP was bad. It allows machines on your network to modify, for example, settings on your router without any authentication.
Check Email Script
cornet — Sun, 2008-01-13 02:04
So I've been playing with conky again and wanted it to check all my email accounts for new mail.
I found this script but I wanted to check multiple accounts and show the total mail count in my inbox.
After some hacking here is what I came up with... and yes I've removed the base64 encoding as it doesn't add any security what so ever!
#!/usr/bin/env ruby
require "optparse"
require "net/imap"
#
# Parse options
#
def parse_options(args)
# Hash to hold options
options = Hash.new
parser = OptionParser.new do |opts|
opts.on('-H host', '--host host', 'Host') do |v|
options[:host] = v
end
opts.on('-u user', '--user user', 'User') do |v|
options[:user] = v
end
opts.on('-p password', '--password password', 'Password') do |v|
options[:password] = v
end
opts.on('-h', '--help', 'Displays usage information') do
puts opts
exit 1
end
end
# Parse Parameters
begin
parser.parse!(args)
rescue OptionParser::ParseError => e
puts "Parse Error: " + e
puts parser.to_a
end
# Check for required params
if (options.has_key?(:host) && options.has_key?(:user) && options.has_key?(:password))
#
# Return options
#
options
else
puts parser.to_a
exit 1
end
end
options = parse_options(ARGV)
#
# Lets check some mail!
#
imap = Net::IMAP.new(options[:host])
imap.login(options[:user], options[:password])
#
# Get total mail
#
status = imap.status("inbox", ["MESSAGES", "UNSEEN"])
puts "#{status['UNSEEN']}/#{status['MESSAGES']}"
imap.disconnect
