Skip to content

Instantly share code, notes, and snippets.

View lachlan's full-sized avatar

Lachlan Dowding lachlan

  • Brisbane, Australia
View GitHub Profile
@lachlan
lachlan / View in Google Cache.url
Created June 16, 2011 03:01
View current web page in Google cache bookmarklet
javascript:(function(){location.href="http://www.google.com/search?q=cache:"+escape(location.href.replace(/^http%5C:%5C/%5C/(.*)$/,"$1"))})()
@lachlan
lachlan / https_post.rb
Created October 13, 2009 23:46
https post a payload to a web server with basic authentication in ruby
# https post a payload to a web server with basic authentication
require 'net/https'
requests = 1
protocol = 'https'
host = 'example.com'
port = 80
user = 'example_username'
pass = 'example_password'
path = '/some/path'
@lachlan
lachlan / text_plain_month.rb
Created October 13, 2009 23:41
prints the current month in plain text format in ruby
# prints the current month in plain text format
require 'rubygems'
require 'activesupport'
# Extend the built-in String class with methods to center a string
class String
# Returns a copy of the string padded with spaces on both the left and the
# right so it is centered within the desired length
def center(length)
self.dup.center!(length)