Skip to content

Instantly share code, notes, and snippets.

@anderscarling
anderscarling / disk_free_check.rb
Created April 26, 2009 00:31
Will send mail to root@localhost if disk usage on one or more file systems is above 80 percent
#! /usr/bin/ruby -w
require 'net/smtp'
# Configuration
SMTP_SERVER = "localhost"
FROM_ADDRESS = "root@localhost"
TO_ADDRESS = "root@localhost"
DEFAULT_LIMIT = 80
@anderscarling
anderscarling / Tabs to Clippings.scpt
Created April 26, 2009 11:45
Turn's tabs open in NewsNetWire into Clippings. Relies on UI Scripting access and default keyboard shortcut.
-- Note, this has proven to be quite unreliable if the tabs are not preloaded and your not quite lucky (which I was my first run, i guess).
tell application "NetNewsWire"
activate
tell application "System Events" to tell process "NetNewsWire" to keystroke "\\" using command down
set repeatTimes to number of tabs - 1
repeat repeatTimes times
tell application "System Events" to tell process "NetNewsWire" to keystroke "}" using command down
tell application "System Events" to tell process "NetNewsWire" to keystroke "s" using {command down, option down}
tell application "System Events" to tell process "NetNewsWire" to keystroke "w" using command down
end repeat
@anderscarling
anderscarling / gist:112155
Created May 15, 2009 10:02
This is how you use ruby as your vim pasteboard buffer. For fun, and profit
" Because we can use ruby as our pasteboard buffer (w/o support for newlines), damnit!
" Copy all lines
:1rubydo $x=""
:rubydo $x << $_;
" Will paste on line 6, the line needs to exist
:6rubydo $_=$x
" Copy from line 1 to line 6. Please note that you can even use instance variables.
:1rubydo temp=$_
@anderscarling
anderscarling / RemoteSwitch.rb
Created August 23, 2011 21:31
Remote Switch for ohlzon
# Usage
# # Turn on
# RemoteSwitch.new(params[:id]).on!
#
# # Turn off
# RemoteSwitch.new(params[:id]).off!
#
# Raises exception
# RemoteSwitch.new("not an id")
#
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@anderscarling
anderscarling / add_country_code_to_phone_numbers_in_contacts.scpt
Created April 23, 2016 14:58
Apple Script for adding country code prefix to numbers in address book that doesn't currently have one
#! /usr/bin/env osascript
on run argv
set is_real to (count of argv > 0 and item 1 of argv equals "--real")
if is_real then
log "Running real run, changes will be saved!"
log ""
else
log "Running test run, add --real to save changes.."

Keybase proof

I hereby claim:

  • I am anderscarling on github.
  • I am lowe (https://keybase.io/lowe) on keybase.
  • I have a public key whose fingerprint is D814 3C99 6D75 4946 C58B 5AFF B4DC 2C2B B226 EB49

To claim this, I am signing this object: