Skip to content

Instantly share code, notes, and snippets.

@jmah
jmah / Random Unwatched Movie.applescript
Created May 16, 2012 21:16
Suggest an unwatched movie from Delicious Library
tell front document of application "Delicious Library 2"
-- Choose a random unwatched movie
set unwatchedItems to every movie whose experienced is false
if (count of unwatchedItems) is 0 then
display dialog "You don't have any unwatched movies." buttons {"OK"} default button "OK"
return
end if
set randomIndex to random number from 1 to (count of unwatchedItems)
set candidateItem to item randomIndex of unwatchedItems
@jmah
jmah / Ratings.scpt
Created May 17, 2012 20:52
Basic example AppleScript for Delicious Library
tell front document of application "Delicious Library 2"
set howMany to count of (every medium whose rating ≥ 4)
end tell
tell application "TextEdit"
make new document with properties ¬
{text:"There are " & howMany & " items in Delicious Library rated at least 4 stars."}
end tell
-- Menu Path: "Item"
tell front document of application "Delicious Library 2"
repeat with theItem in (get selected media)
if class of theItem is book and isbn of theItem is not missing value then
set theISBN to isbn of theItem
tell application "Safari"
activate
open location ("http://openlibrary.org/search?q=" & theISBN)
end tell
@jmah
jmah / loan.applescript
Created October 10, 2012 22:04
Creating Loans with Delicious Library 2
tell front document of application "Delicious Library 2"
set f to first friend
set m to first item of (get selected media)
set due to (current date) + 2 * weeks
make new loan with properties {due date:due, borrower:f, medium:m}
end tell
@jmah
jmah / keybase.md
Created March 28, 2014 04:34
Rebase Keybase

Keybase proof

I hereby claim:

  • I am jmah on github.
  • I am jmah (https://keybase.io/jmah) on keybase.
  • I have a public key whose fingerprint is CDE3 A069 8566 DC89 85B1 FE93 2CB3 42F6 6E8A 5FB9

To claim this, I am signing this object:

@jmah
jmah / tail-recursion.m
Last active August 29, 2015 14:01
Tail Recursion Experiments in Objective-C
//
// Created by Jonathon Mah on 2014-05-24.
// Released into the public domain.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface ListNode : NSObject
- (ListNode *)next {
if (_next) {
ListNode *nextCopy = [[ListNode alloc] init];
nextCopy.name = _next.name;
nextCopy.next = _next.next;
return nextCopy;
} else {
return nil;
}
}
@jmah
jmah / DictEnumTests.m
Created April 19, 2015 23:19
NSDictionary Enumeration Benchmark
//
// DictEnumTests.m
//
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
@interface DictEnumTests : XCTestCase
@end