Skip to content

Instantly share code, notes, and snippets.

@gmcmillan
gmcmillan / rdio.scpt
Created November 29, 2012 17:27
rdio.scpt
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
on shortenUrl(str)
set curl_cmd to "curl -s https://www.googleapis.com/urlshortener/v1/url"
set json to " -H 'Content-Type: application/json' -d '{\"longUrl\": \"" & str & "\"}'"
set grep_cmd to "grep -Eo 'http:\\/\\/goo\\.gl\\/[0-9A-Za-z]*'"
set command to curl_cmd & json & " | " & grep_cmd
do shell script command
@gmcmillan
gmcmillan / chef.rb
Created July 26, 2012 22:25
Simple Ruby class for manually querying the Chef REST API (using Net::HTTP instead of Chef's REST resources)
require 'base64'
require 'time'
require 'digest/sha1'
require 'openssl'
require 'net/https'
require 'json'
class ChefAPI
# Public: Gets/Sets the http object.
@gmcmillan
gmcmillan / parser.rb
Created April 4, 2012 17:59
my.cnf parser
def self.parse_config(file)
config = {}
File.open(file).each_line do |line|
line.strip!
# skip lines with comments or blank lines
next if /^\#/.match(line)
next if /^\s*$/.match(line)
# store which group in the config the line belongs to (e.g. [mysqld])
@gmcmillan
gmcmillan / .gemrc
Created October 7, 2010 14:53
site5
---
gemhome: /home/USERNAME/.gems
gempath:
- /home/USERNAME/.gems
- /usr/lib/ruby/gems/1.8