Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / github-auth.cmd.js
Created February 7, 2009 05:13
Saves your Github login and API token in Ubiquity's keychain. Needed to create new gists via the API
CmdUtils.CreateCommand({
name: "github-auth",
icon: "http://gist.github.com/favicon.ico",
author: {name: "Mike Green", email: "mike.is.green@gmail.com", url: "http://mikedamage.github.com"},
description: "Saves your Github login and API token in Firefox's keychain. Needed to create new Gists via Ubiquity.",
takes: {"username api-token": noun_arb_text},
preview: function(pblock) { pblock.innerHTML = this.description; },
execute: function(userToken) {
var data = userToken.text.split(' ');
var user = data[0];
@mikedamage
mikedamage / gist.cmd.js
Created February 7, 2009 05:15
Uses Gists' API to create a new Gist from selected text.
// Create a new Github Gist from selection
CmdUtils.CreateCommand({
name: "gist",
icon: "http://gist.github.com/favicon.ico",
author: {name: "Mike Green", email: "mike.is.green@gmail.com", url: "http://mikedamage.github.com"},
description: "Creates a new Github Gist from the currently selected text. IMPORTANT: You must give Firefox your Github API token by running github-auth before using this command.",
takes: {"username": noun_arb_text},
preview: function(pblock, user) {
var template = "<b>New gist by ${user}:</b><p><code>${gist}</code></p>";
var selection = CmdUtils.getSelection();
@mikedamage
mikedamage / dbslayer_rails.yaml
Created February 8, 2009 22:49
Rails database.yml config using the DBSlayer adapter
production:
adapter: dbslayer
host: localhost
port: 9090
require 'net/http'
require 'uri'
require 'time'
class Time
def self.gcalschema(tzid) # We may not be handling Time Zones in the best way...
tzid =~ /(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)Z/ ? # yyyymmddThhmmss
# Strange, sometimes it's 4 hours ahead, sometimes 4 hours behind. Need to figure out the timezone piece of ical.
# Time.xmlschema("#{$1}-#{$2}-#{$3}T#{$4}:#{$5}:#{$6}") - 4*60*60 :
Time.xmlschema("#{$1}-#{$2}-#{$3}T#{$4}:#{$5}:#{$6}") :
@mikedamage
mikedamage / geektool_rss.rb
Created February 17, 2009 16:48
Parses RSS feed and prints headlines to STDOUT
#!/usr/bin/env ruby
#
# = Geektool RSS Script
#
# AUTHOR:: Mike Green
# EMAIL:: mike.is.green@gmail.com
# URL:: http://mikedamage.github.com
# LICENSE:: GNU GPL
#
# == Summary
#!/usr/bin/ruby
#
# = Time Machine Log Inspector
#
# by Mike Green <mike.is.green@gmail.com>
# created on 2009-02-10
#
# == Summary
# Meant to be run as a launchd task everytime system.log is modified.
# It scans the latest line of system.log for specific patterns related to Time Machine
@mikedamage
mikedamage / rack_app.rb
Created February 19, 2009 02:38
super simple Rack app
use Rack::ShowExceptions
use Rack::CommonLogger
require 'rack/request'
require 'rack/response'
module Rack
class App
def call(env)
req = Request.new(env)
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
// Get the day of the year as an integer (1..366)
var today = new Date();
var first = new Date(today.getFullYear(), 0, 1);
var theDay = Math.round(((today - first) / 1000 / 60 / 60 / 24) + .5, 0);
// Get day of year by modifying the Date() prototype
Date.prototype.getDOY = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((this - onejan) / 86400000);
}