Skip to content

Instantly share code, notes, and snippets.

@elasticthreads
elasticthreads / notesexporter.applescript
Created August 9, 2018 03:46
bit of code to export notes from Notes.app to a applescript list of records with the note body as HTML.
set exportingNotesList to {}
tell application "Notes"
set theNotes to its notes
repeat with aNote in theNotes
set aNoteBody to body of aNote
set aNoteName to name of aNote
set end of exportingNotesList to {body:aNoteBody, name:aNoteName} as record
end repeat
end tell
@elasticthreads
elasticthreads / bookmarklet
Last active August 29, 2015 14:06
Javascript bookmarklet you can run when in google maps (on OS X) to look at the same location in Apple Maps (useful for transfer to iOS).
javascript:var%20y%20=%20document.location.href;if%20(y.indexOf(%27google.com/maps/%27)%3E=0)%20{if(y.indexOf(%27/preview/search/%27)%3E=0){var%20query=y.indexOf(%27/preview/search/%27)+16;query=y.substring(query,y.length);var%20x=%27http://maps.apple.com/?q=%27+query;document.location=x;setTimeout(function()%20{document.location=y;},%20900);}else{var%20llDex=y.indexOf(%27/@%27)+2;var%20len=y.indexOf(%27/data%27);if(len==-1){len=y.length;}if((len%3E0)&&(llDex%3Clen)){var%20loc=y.substring(llDex,len);llDex=loc.lastIndexOf(",");len=loc.length-1;if((llDex%3E0)&&(llDex+1%3Clen)){var%20zoom=loc.substring(llDex+1,len);loc=loc.substring(0,llDex);var%20x=%27http://maps.apple.com/?ll=%27+loc+%27&z=%27+zoom;document.location=x;setTimeout(function()%20{document.location=y;},%20900);}}}}
@elasticthreads
elasticthreads / nvALT22 teaser
Created February 27, 2012 19:24
nvALT 2.2 beta release teaser
# nvalt 2.2 public beta release notes:
- Requires Leopard & intel procssors now (we had tried previously to support Tiger/PPC, but neither Brett or I have access to either). Also, Leopard is getting increasingly harder to support. If your intel mac runs Leopard, it will run Snow Leopard; and it will run faster on 10.6, and will have more free space. There's really no reason for you to keep an intel mac on Leopard. So it is likely we'll move the minimum OS to Snow Leopard at some time in the next year. At which point we'll stop cutting off support for older OSes so frequently.
### Bug fixes and improvements for 10.5 - 10.7
- Added some initial, optional, markdown auto-completion/syntax tricks (see below).
- Improved auto-pairing
- The "Keep note text width readable" (in Preferences >> "Fonts & Colors") is significantly improved; much less janky. (still needs to be renamed.)
- Hitting cmd-return moves the cursor to the end of your current paragraph, and then inserts a new line (like TextMate).
- Hitting cmd
@elasticthreads
elasticthreads / gist:1224286
Created September 17, 2011 19:50
applescript properties
property aVar : missing value
if aVar is missing value then
set aVar to 0
else
set aVar to aVar + 1
end if
return aVar
@elasticthreads
elasticthreads / cocoaPredicateMkDn
Created September 16, 2011 18:35
nspredicate to find lines containing markdown reference links
- (NSArray *)referenceLinksInString:(NSString *)contentString{
NSString *wildString = @"*[*]:*http*"; //This is where you define your match string.
NSPredicate *matchPred = [NSPredicate predicateWithFormat:@"SELF LIKE[cd] %@", wildString];
/*
Breaking it down:
SELF is the string you're testing
[cd] makes the test case-insensitive
LIKE is one of the predicate search possiblities. It's NOT regex, but lets you use wildcards '?' for one character and '*' for any number of characters
MATCH (not used) is what you would use for Regex. And you'd set it up similiar to LIKE. I don't really know regex, and I can't quite get it to work. But that might be because I don't know regex.
%@ you need to pass in the search string like this, rather than just embedding it in the format string. so DON'T USE something like [NSPredicate predicateWithFormat:@"SELF LIKE[cd] *[*]:*http*"]
@elasticthreads
elasticthreads / gist:1168725
Created August 24, 2011 18:07
fix for Safari 5.1's "do Javascript" bug where it can't just "getSelection()"
tell application "Safari"
set selecTxt to (do JavaScript "var x = ''+document.getSelection();x" in current tab of front window) as string
end tell
@elasticthreads
elasticthreads / ipNOW.js
Created August 21, 2011 18:15
Quickly add a webpage to Instapaper and switch to instapaper
javascript:function%20ipNOW(){var%20d='i'+document.location;document.location=d;}ipNOW();void(0)
@elasticthreads
elasticthreads / gist:990938
Created May 25, 2011 13:07
eject after seconds
delay 60 --number of seconds
tell application "Finder"
eject disk "Audio CD" ---name of disk to eject (exact same as name in finder sidebar, capitalization included)
end tell
@elasticthreads
elasticthreads / AppleScript Googlers
Created March 23, 2011 14:34
some AppleScript gists to open a new tab for web search
BEST (pops up a dialog to enter a search term and then opens that google search in a new tab in whatever browser is default):
activate
set gSearch to the text returned of (display dialog "Google:" default answer "")
set gSearch to "http://www.google.com/search?q=" & gSearch
tell application "System Events" to open location gSearch
Safari:
tell application "Safari"
tell front window to set current tab to make new tab