Skip to content

Instantly share code, notes, and snippets.

tell application "Address Book"
set s to selection
set d to (creation date of item 1 of s) as text
set n to name of item 1 of s
display dialog d with title "Creation Date for " & n
end tell
@statonjr
statonjr / replicate.rb
Created July 13, 2010 05:05
Silly ruby script to replicate CouchDB databases
#!/usr/bin/env ruby
require 'optparse'
require 'rubygems'
require 'json'
options = {}
data = {}
optparse = OptionParser.new do |opts|
NSRect mainDisplayRect = [[NSScreen mainScreen] frame];
NSWindow *fullScreenWindow = [[NSWindow alloc] initWithContentRect:mainDisplayRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
[fullScreenWindow setLevel:NSMainMenuWindowLevel+1];
[fullScreenWindow makeKeyAndOrderFront:self];
@statonjr
statonjr / gist:501773
Created July 31, 2010 04:58
Implementing mouseDown: on WebKit input elements
#import "MainWindow.h"
// MainWindow subclasses NSWindow
@implementation MainWindow
@synthesize webView, isHTMLInputElement;
// We intercept the sendEvent: method at the NSWindow level to inspect it.
// If the event type is a click ("NSLeftMouseDown") and the element that the mouse
// is hovering over is an input, then we do something
@statonjr
statonjr / gist:513054
Created August 7, 2010 18:34
Calling unnamed selectors in MacRuby
tf = CAMediaTimingFunction.alloc
tf.send "initWithControlPoints::::".to_sym 0.5, 1.0, 0.5, 0.0
class Object
def descendants
descendants = []
descendants << self.superclass
descendants.each do |klass|
descendants << klass.superclass if klass != BasicObject
end
end
end
:storage => "S3",
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style/:basename.:extension",
:bucket => 'yourbucketname'
var alert = [[CPAlert alloc] init];
[alert setAlertStyle: CPCriticalAlertStyle];
[alert setMessageText:e];
[alert addButtonWithTitle:@"FML"];
[alert setTitle:@"Error!"];
[alert runModal];
tell application "Terminal"
set openWindows to every window
set openTabs to {}
repeat with i from 1 to number of items in openWindows
set this_item to item i of openWindows
set openTabs to openTabs & every tab of this_item
end repeat
repeat with i from 1 to number of items in openTabs
set this_item to item i of openTabs
do script "source ~/.zshrc" in this_item
#!/usr/bin/env/nush
(load "ScriptingBridge") ; Load the ScriptingBridge framework
(set finder (SBApplication applicationWithBundleIdentifier: "com.apple.Finder")) ; Reference to shared instance
(puts (((finder disks) 0) name)) ; Name of the first disk in the Finder