Skip to content

Instantly share code, notes, and snippets.

View aerickson's full-sized avatar

Andrew Erickson aerickson

View GitHub Profile
@deenseth
deenseth / gist:1514633
Created December 23, 2011 16:23
Add Google Calendar Event Bookmarklet
javascript: var s;
/*Figure out the selected text*/
if ( window.getSelection ) {
s = window.getSelection();
} else if ( document.getSelection ) {
s = document.getSelection();
} else {
s = document.selection.createRange().text;
}
/*If there isn't any text selected, get user input*/
@joshwand
joshwand / gist:1145669
Created August 15, 2011 03:41
Blocking the new version of the NYTimes paywall

The NYTimes has updated their paywall-- it's slightly more sophisticated. The content is no longer hidden behind a big transparent div, but instead is now actually removed from the page entirely. It's still simple to defeat, though. Using adblock plus (or your preferred adblocking device), block the following URLs:

*://*.nytimes.com/*/gwy.js*
*://*.nytimes.com/*/gw.js*

And you're done.

@ryanking
ryanking / gist:954555
Created May 4, 2011 00:55
Selectively stop classes from being modified in ruby.
# Ever get tired of people messing with your ruby classes?
# now you can put the hammer down and stop them. Just
# include this module and no one will be able to modify the
# class implementation or any instance implementations.
module Stop
module CantTouchThis
def self.included(mod)
@mattknox
mattknox / humanize.rb
Created May 3, 2011 03:28
Numeric#humanize makes numbers more readable.
class Numeric
SCALE_TO_WORD = Hash.new do |h, i|
" * 10^#{i * 3}"
end.merge({ 1 => " thousand",
2 => " million",
3 => " billion",
4 => " trillion"
})
# in my unscientific test, no one really found names beyond trillion useful.
#!/bin/bash
# SPDX-License-Identifier: MIT
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate