text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
theRTFD's mutableString()'s replaceOccurrencesOfString:(character id (current application's NSAttachmentCharacter)) withString:"" options:0 range:{0, theRTFD's |length|()} | lns1.scpt |
thePasteboard's clearContents() | lns1.scpt |
thePasteboard's writeObjects:{theRTFD} | lns1.scpt |
set listOfStrings to paragraphs of "5e9204033debb66ef9d06cbf__Board 1 | To Do | lns1.scpt |
5e9210c43823383ffec282dd__Board 11 | Done | lns1.scpt |
5e91deb9b5477c7bf6831ab9__Board 1 | List 1 | lns1.scpt |
5e91dec34033e73893cad871__Board 1 | List 2 | lns1.scpt |
5e9203d1918b11356052f065__Board 2 | To Do | lns1.scpt |
5e91dfae766168544765167f__Board 2 | Test for Attachments | lns1.scpt |
5e9203e3b964487863f7b4ed__Board 2 | Done" | lns1.scpt |
set theDict to current application's NSMutableDictionary's dictionary() | lns1.scpt |
set AppleScript's text item delimiters to "__" | lns1.scpt |
repeat with aString in listOfStrings | lns1.scpt |
(theDict's setObject:(aString's last text item) forKey:aString) | lns1.scpt |
set theResult to (theDict's keysSortedByValueUsingSelector:"localizedStandardCompare:") as list -- or just "compare:" | lns1.scpt |
set listOfStrings to "5e9204033debb66ef9d06cbf__Board 1 | To Do | lns1.scpt |
5e9210c43823383ffec282dd__Board 1 | Done | lns1.scpt |
set theDb to open db in file missing value with can create | lns1.scpt |
update db theDb sql string "create table test (a, b)" | lns1.scpt |
batch string update db theDb sql string "insert into test values (?, ?)" with data listOfStrings using delimiter "__" | lns1.scpt |
set theResult to query db theDb sql string "select a||'__'||b from test order by b" | lns1.scpt |
close db theDb | lns1.scpt |
set theResult to paragraphs of (theResult as text) | lns1.scpt |
set listOne to {{firstname:"John", gender:"male", uid:"40"}, {firstname:"Jane", gender:"female", uid:"30"}} | lns1.scpt |
set listTwo to {{firstname:"Joe", gender:"male", uid:"20"}, {firstname:"June", gender:"female", uid:"30"}} | lns1.scpt |
set cleanedList to getCleanedList(listOne, listTwo) --> {{firstname:"John", gender:"male", uid:"40"}, {firstname:"Joe", gender:"male", uid:"20"}, {firstname:"June", gender:"female", uid:"30"}} | lns1.scpt |
on getCleanedList(list1, list2) | lns1.scpt |
property listOne : list1 | lns1.scpt |
property listTwo : list2 | lns1.scpt |
property uidList : {} | lns1.scpt |
property cleanedList : {} | lns1.scpt |
repeat with anItem in o's listTwo | lns1.scpt |
set end of o's uidList to uid of anItem | lns1.scpt |
repeat with anItem in o's listOne | lns1.scpt |
set anItem to contents of anItem | lns1.scpt |
if (uid of anItem) is not in o's uidList then | lns1.scpt |
set end of o's cleanedList to anItem | lns1.scpt |
return o's cleanedList & o's listTwo | lns1.scpt |
end getCleanedList | lns1.scpt |
use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later | lns1.scpt |
set list1 to {{arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"The Origin and Goal of History", uid:"118304"}, {arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"DUPLICATE", uid:"118305"}, {arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"The Origin and Goal of History", uid:"118306"}, {arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"DUPLICATE", uid:"118307"}} | lns1.scpt |
set list2 to {{arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"The Origin and Goal of History", uid:"118300"}, {arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"The Origin and Goal of History", uid:"118302"}, {arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"The Origin and Goal of History", uid:"118305"}, {arg:"118305", match:"The Origin and Goal of History", subtitle:"", title:"The Origin and Goal of History", uid:"118307"}} | lns1.scpt |
set array1 to current application's class "NSMutableArray"'s arrayWithArray:(list1) | lns1.scpt |
set array2 to current application's class "NSArray"'s arrayWithArray:(list2) | lns1.scpt |
set uids2 to array2's valueForKey:("uid") | lns1.scpt |
set uidFilter to current application's class "NSPredicate"'s predicateWithFormat_("NOT uid IN %@", uids2) | lns1.scpt |
tell array1 to filterUsingPredicate:(uidFilter) | lns1.scpt |
tell array1 to addObjectsFromArray:(array2) | lns1.scpt |
set sortOnUID to current application's class "NSSortDescriptor"'s sortDescriptorWithKey:("uid") ascending:(true) | lns1.scpt |
tell array1 to sortUsingDescriptors:({sortOnUID}) | lns1.scpt |
set newList to array1 as list | lns1.scpt |
set theRange to theApp's NSMakeRange(1, theString's |length|()) | lns1.scpt |
set posixNewpath to "/Users/Chris/Documents/" | lns1.scpt |
set newDocName to "new.pdf" | lns1.scpt |
set outFolderNSURL to (current application's |NSURL|'s fileURLWithPath:posixNewpath) | lns1.scpt |
set outNSURL to (outFolderNSURL's URLByAppendingPathComponent:newDocName) | lns1.scpt |
set theNewPDFDocument to current application's PDFDocument's new() | lns1.scpt |
repeat with p from 1 to (count of items of fullDoc) | lns1.scpt |
set thePDFPage to item p of fullDoc | lns1.scpt |
(theNewPDFDocument's insertPage:thePDFPage atIndex:0) | lns1.scpt |
(theNewPDFDocument's writeToURL:outNSURL) | lns1.scpt |
script "JSTest.scpt" -- errors if lib is JXA | lns1.scpt |
on error from jsLib | lns1.scpt |
property myJSLib : missing value | lns1.scpt |
set {my myJSLib, theError} to current application's OSAScript's alloc()'s initWithContentsOfURL:(current application's |NSURL|'s fileURLWithPath:jsLibPath) |error|:(reference) | lns1.scpt |
set aString to current application's NSString's stringWithString:"It costs $4.50 each way" | lns1.scpt |
set aString to (aString's stringByReplacingOccurrencesOfString:"\\$([0-9,.]+)" withString:"€$1" options:(current application's NSRegularExpressionSearch) range:{0, aString's |length|()}) as text | lns1.scpt |
set theRange to aString's rangeOfString:"(?<=\\$)[0-9,.]+" options:(current application's NSRegularExpressionSearch) | lns1.scpt |
set theResult to (aString's substringWithRange:theRange) as text | lns1.scpt |
set {theExpr, theError} to current application's NSRegularExpression's regularExpressionWithPattern:"\\$([0-9,.]+)" options:0 |error|:(reference) | lns1.scpt |
set theMatches to theExpr's matchesInString:aString options:0 range:{0, aString's |length|()} | lns1.scpt |
set theRange to (aMatch's rangeAtIndex:1) -- ie, $1 | lns1.scpt |
set end of theResults to (aString's substringWithRange:theRange) as text | lns1.scpt |
property LF : linefeed | lns1.scpt |
set sourceStr to " 2016-01-11 and some text and 2017-02A-22" | lns1.scpt |
set reFind to "(\\d{4})-(\\d{2})(A)?-(\\d{2})" | lns1.scpt |
set reFirstMatch to my regexFind:reFind inString:sourceStr findAll:false | lns1.scpt |
set reAllMatches to my regexFind:reFind inString:sourceStr findAll:true | lns1.scpt |
on regexFind:pFindRegEx inString:pSourceString findAll:pGlobalBool | lns1.scpt |
local theFinds, theResult, subResult, groupCount | lns1.scpt |
set pSourceString to current application's NSString's stringWithString:pSourceString | lns1.scpt |
set {theRegEx, theError} to current application's NSRegularExpression's regularExpressionWithPattern:pFindRegEx options:0 |error|:(reference) | lns1.scpt |
if theRegEx is missing value then error ("Invalid RegEx Pattern." & LF & theError's localizedDescription() as text) | lns1.scpt |
if (pGlobalBool) then ### FIND ALL MATCHES ### | lns1.scpt |
set theFinds to theRegEx's matchesInString:pSourceString options:0 range:{0, pSourceString's |length|()} | lns1.scpt |
else ### FIND FRIST MATCH ### | lns1.scpt |
set theFind to theRegEx's firstMatchInString:pSourceString options:0 range:{0, pSourceString's |length|()} | lns1.scpt |
set theFinds to current application's NSMutableArray's array() | lns1.scpt |
(theFinds's addObject:theFind) | lns1.scpt |
set theResult to current application's NSMutableArray's array() | lns1.scpt |
repeat with aFind in theFinds | lns1.scpt |
set subResult to current application's NSMutableArray's array() | lns1.scpt |
set groupCount to aFind's numberOfRanges() | lns1.scpt |
repeat with i from 0 to (groupCount - 1) | lns1.scpt |
set theRange to (aFind's rangeAtIndex:i) | lns1.scpt |
if |length| of theRange = 0 then | lns1.scpt |
(subResult's addObject:"") | lns1.scpt |
(subResult's addObject:(pSourceString's substringWithRange:theRange)) | lns1.scpt |
(theResult's addObject:subResult) | lns1.scpt |
end repeat -- theFinds | lns1.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.