Skip to content

Instantly share code, notes, and snippets.

[[NSBundle bundleWithPath:'/Library/Frameworks/JSON.framework'] load];
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
#!/usr/bin/macruby
# Need the AddressBook framework
framework 'AddressBook'
# Singleton
ab = ABAddressBook.sharedAddressBook
# me is the ABRecord of the current logged in user
# valueForProperty() is the KVO method to get the constant
@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];