Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / desktop_resolution.scpt
Created January 16, 2009 04:09
Applescript: get desktop resolution
tell application "Finder"
set _b to bounds of window of desktop
set _w to item 3 of _b
set _h to item 4 of _b
end tell
# This is how it would look using the Ruby Regexp class
# Only match one-line comments
@single_line_comments_pattern = Regexp.new(/\/\*.*?\*\//)
# Match single and multi-line comments
@all_comments_pattern = Regexp.new(/\/\*.*?\*\//m)
/* BTJunkie Torrent Search */
CmdUtils.CreateCommand({
name: "btjunkie",
icon: "http://btjunkie.org/favicon.ico",
preview: "Search btjunkie.org for torrents",
author: { name: "Mike Green", email: "mike@fifthroomcreative.com" },
license: "GPL",
takes: {"input": noun_arb_text},
execute: function(input) {
Utils.openUrlInBrowser("http://btjunkie.org/search?q="+encodeURIComponent(input.text));
/* ColorSchemer Search */
CmdUtils.CreateCommand({
name: "color-schemer",
icon: "http://www.colorschemer.com/favicon.ico",
preview: "Search colorschemer.com for color schemes",
author: { name: "Mike Green", email: "mike.is.green@gmail.com" },
license: "GNU GPL",
takes: {"input": noun_arb_text },
execute: function(input) {
Utils.openUrlInBrowser("http://www.colorschemer.com/schemes/search.php?s="+encodeURIComponent(input.text));
/* Lifehacker Blog Search */
CmdUtils.CreateCommand({
name: "lifehacker",
icon: "http://lifehacker.com/favicon.ico",
preview: "Search Lifehacker blog articles",
author: { name: "Mike Green", email: "mike.is.green@gmail.com" },
license: "GNU GPL",
takes: {"input": noun_arb_text},
execute: function(input) {
Utils.openUrlInBrowser("http://lifehacker.com/search/"+encodeURIComponent(input.text));
$.ajax({
dataType: 'jsonp',
data: { count: 3, callback: 'twitterFeed' },
url: 'http://twitter.com/statuses/user_timeline/mikedamage.json',
jsonp: 'twitterFeed'
});
function twitterFeed(feed) {
for (var i=0; i<feed.length; i++) {
$('#twitter-status ul').append('<li class="tweet">'
+ feed[i].text
+ '<br/><em>'
+ jQuery.timeago(parseDate(feed[i].created_at))
+ '</em>'
+ '</li>');
}
}
require 'fileutils'
require 'tempfile'
module Webby
module Filters
# The Tidy filter is used to process HTML (or XHTML) through the _tidy_
# program and outpu nicely formatted and correct HTML (or XHTML).
#
# Options can be passed to the _tidy_ program via the
# = Sinatra Action: Minify Javascript
#
# == Summary
# Takes JS files from the public directory and minifies them using the JSMin Rubygem
get '/js/minify/:file' do
content_type 'text/javascript', :charset => 'utf-8'
@file = Pathname.new("./public/javascripts/" + params[:file])
@mini = JSMin.minify(@file.read)
@mini
# = Sinatra Action: Sass Stylesheet Compressor/Renderer
#
# == Summary
# Renders Sass stylesheets in the specified format.
# Valid formats are: extended, expanded, compact, compressed
get "/sass/:format/:file" do
content_type 'text/css', :charset => 'utf-8'
if params[:file] =~ /\.sass$/
@file = Pathname.new("./views/sass/" + params[:file])