Skip to content

Instantly share code, notes, and snippets.

View aerickson's full-sized avatar

Andrew Erickson aerickson

View GitHub Profile
#!/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
@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.
@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)
@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.

@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*/
@dwayne
dwayne / 00-install-on-64-bit-ubuntu-14.04.md
Last active January 12, 2024 17:48
Installing node and npm on Ubuntu 12.04 LTS and 64-bit Ubuntu 14.04 LTS.
  1. Navigate to http://nodejs.org/download/ and on the Linux Binaries (.tar.gz) row click to download the 64-bit version of the current latest release.

  2. Say you've downloaded node-v0.10.7-linux-x64.tar.gz into the Downloads directory. Then, open the terminal and type the following:

$ cd ~/Downloads
$ mkdir -p ~/local/node
$ tar xzf node-v0.10.7-linux-x64.tar.gz -C ~/local/node --strip-components=1
$ echo '# Node Enviroment Setup' >> ~/.bashrc
$ echo 'export PATH=$HOME/local/node/bin:$PATH' &gt;&gt; ~/.bashrc
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@tokudu
tokudu / ec2ssh.sh
Created October 27, 2012 23:55
A helper script for SSH'ing into EC2 instances by name
#!/bin/bash
# SSH into an EC2 instance by name
# Author: tokudu@github.com (SoThree.com).
set -e
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` instance_name"
exit 1
fi
#!/usr/bin/env ruby
# Ruby script to create recurring maintenance windows in PagerDuty
#
# Copyright (c) 2012, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
@tribut
tribut / mosh_pc.sh
Last active June 4, 2018 11:33
wrapper for mosh to work with ssh's proxycommand directive. this only makes sense if the target machine is directly reachable from the internet using udp (but probably not via tcp). usage: mosh_pc.sh [host as mentioned in .ssh/config] [public ip of host]
#!/bin/sh
# ########################################################## #
# wrapper for mosh to work with ssh's proxycommand directive #
# this only makes sense if the machine is directly reachable #
# from the internet using udp. #
# ########################################################## #
THISSCRIPT="`basename \"$0\"`"
REMOTE="$1"