text
stringlengths
0
15.7k
source
stringlengths
6
112
set outputFileBase to "output_"&(time of (current date))
raytracer.applescript
set outputFile to outputFileBase&".ppm"
raytracer.applescript
set commands to ""
raytracer.applescript
log "starting workers: "&numWorkers
raytracer.applescript
repeat with worker from 0 to numWorkers-1
raytracer.applescript
set commands to commands&"./raytracer.applescript "& worker & " " & outputFileBase & " " &" & "
raytracer.applescript
log "running"
raytracer.applescript
log commands&"wait"
raytracer.applescript
do shell script commands&"wait"
raytracer.applescript
do shell script "touch " & outputFile
raytracer.applescript
set outfile to open for access outputFile with write permission
raytracer.applescript
close access outfile
raytracer.applescript
set workerReverse to (numWorkers-1) - worker
raytracer.applescript
set workerPartFile to getWorkerPartFilename(outputFileBase, workerReverse)
raytracer.applescript
do shell script "tail -n +4 "&workerPartFile&" >> "&outputFile&" && rm "&workerPartFile
raytracer.applescript
set outputFileBase to (item 2 of argv) as text
raytracer.applescript
set worker to (item 1 of argv) as number
raytracer.applescript
set outputFile to getWorkerPartFilename(outputFileBase, worker)
raytracer.applescript
set everythingStartTime to current date
raytracer.applescript
log "rendering to "&outputFile
raytracer.applescript
random number with seed my randomSeed
raytracer.applescript
writeRaytracedImage(outputFile, numWorkers, worker, imageWidth, samplesPerPixel, maxBounces)
raytracer.applescript
log "done in " & (current date) - everythingStartTime & "s"
raytracer.applescript
set _Path to "/Users/will/Desktop/Scripts"
run_script.applescript
set scriptLaunch to text returned of (display dialog "Enter name of script to run" default answer "" buttons "OK" default button "OK")
run_script.applescript
if scriptLaunch contains "" then
run_script.applescript
else if scriptLaunch contains scriptLaunch then
run_script.applescript
set scriptRun to _Path & "/" & scriptLaunch & ".scpt"
run_script.applescript
run script scriptRun
run_script.applescript
scriptRun
run_script.applescript
set mvfiles to selection
Move A Selected File.applescript
set destFolderPath to choose folder
Move A Selected File.applescript
set destFolder to name of destFolderPath
Move A Selected File.applescript
set destFolder to destFolderPath as string
Move A Selected File.applescript
move mvfiles to destFolder
Move A Selected File.applescript
on adding folder items to this_folder after receiving added_items
dropbox-public-link-copy.scpt
set the item_count to the number of items in the added_items
dropbox-public-link-copy.scpt
if the item_count is equal to 1 then
dropbox-public-link-copy.scpt
set theFile to item 1 of added_items
dropbox-public-link-copy.scpt
set theRawFilename to ("" & theFile)
dropbox-public-link-copy.scpt
set theFileName to (text item 7 of theRawFilename) as text
dropbox-public-link-copy.scpt
set theWebSafeFileName to switchText from theFileName to "%20" instead of " "
dropbox-public-link-copy.scpt
// XXX = dropbox id
dropbox-public-link-copy.scpt
set theURL to "http://dl.getdropbox.com/u/XXX/screenshots/" & theWebSafeFileName
dropbox-public-link-copy.scpt
set shortURL to bitlyShorten(theURL)
dropbox-public-link-copy.scpt
set the clipboard to shortURL as text
dropbox-public-link-copy.scpt
display notification shortURL & " copied to clipboard."
dropbox-public-link-copy.scpt
delay 1 --> allow time for the notification to trigger
dropbox-public-link-copy.scpt
to switchText from t to r instead of s
dropbox-public-link-copy.scpt
set text item delimiters to s
dropbox-public-link-copy.scpt
set t to t's text items
dropbox-public-link-copy.scpt
set text item delimiters to r
dropbox-public-link-copy.scpt
tell t to set t to item 1 & ({""} & rest)
dropbox-public-link-copy.scpt
t
dropbox-public-link-copy.scpt
end switchText
dropbox-public-link-copy.scpt
on bitlyShorten(_text)
dropbox-public-link-copy.scpt
set login to "XXXX" -- Put your login name here
dropbox-public-link-copy.scpt
set api_key to "XXXX" -- Put your API key here
dropbox-public-link-copy.scpt
set the _encodedUrl to _urlEncode(_text) of me
dropbox-public-link-copy.scpt
if login is "" or api_key is "" then
dropbox-public-link-copy.scpt
set question to display dialog "Sorry, you need to open the script and provide your bitly username and api key. You can get them from: " & return & "https://bitly.com/a/your_api_key/" & return & "Open this location now?" giving up after 15
dropbox-public-link-copy.scpt
if the button returned of the result is "OK" then
dropbox-public-link-copy.scpt
tell application "Finder" to open location "https://bitly.com/a/your_api_key/"
dropbox-public-link-copy.scpt
set curlCMD to ¬
dropbox-public-link-copy.scpt
¬
dropbox-public-link-copy.scpt
"curl --stderr /dev/null \"http://api.bit.ly/shorten?longUrl=" & _encodedUrl & "&history=1&version=2.0.1&login=" & login ¬
dropbox-public-link-copy.scpt
& "&apiKey=" & api_key ¬
dropbox-public-link-copy.scpt
& "\"| grep shortUrl | grep -o http.*[/a-zA-Z0-9]"
dropbox-public-link-copy.scpt
tell me to set _bitlyUrl to (do shell script curlCMD)
dropbox-public-link-copy.scpt
set AppleScript's text item delimiters to "http://"
dropbox-public-link-copy.scpt
set _bitlyUrl to text item 3 of _bitlyUrl
dropbox-public-link-copy.scpt
set AppleScript's text item delimiters to "\""
dropbox-public-link-copy.scpt
set _bitlyUrl to "http://" & text item 1 of _bitlyUrl
dropbox-public-link-copy.scpt
return _bitlyUrl
dropbox-public-link-copy.scpt
display dialog a
dropbox-public-link-copy.scpt
end bitlyShorten
dropbox-public-link-copy.scpt
on _urlEncode(theText)
dropbox-public-link-copy.scpt
set theTextEnc to ""
dropbox-public-link-copy.scpt
repeat with eachChar in characters of theText
dropbox-public-link-copy.scpt
set useChar to eachChar
dropbox-public-link-copy.scpt
set eachCharNum to ASCII number of eachChar
dropbox-public-link-copy.scpt
if eachCharNum = 32 then
dropbox-public-link-copy.scpt
set useChar to "+"
dropbox-public-link-copy.scpt
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) ¬
dropbox-public-link-copy.scpt
and (eachCharNum < 45 or eachCharNum > 46) ¬
dropbox-public-link-copy.scpt
and (eachCharNum < 48 or eachCharNum > 57) ¬
dropbox-public-link-copy.scpt
and (eachCharNum < 65 or eachCharNum > 90) ¬
dropbox-public-link-copy.scpt
and (eachCharNum < 97 or eachCharNum > 122) then
dropbox-public-link-copy.scpt
set firstDig to round (eachCharNum / 16) rounding down
dropbox-public-link-copy.scpt
set secondDig to eachCharNum mod 16
dropbox-public-link-copy.scpt
if firstDig > 9 then
dropbox-public-link-copy.scpt
set aNum to firstDig + 55
dropbox-public-link-copy.scpt
set firstDig to ASCII character aNum
dropbox-public-link-copy.scpt
if secondDig > 9 then
dropbox-public-link-copy.scpt
set aNum to secondDig + 55
dropbox-public-link-copy.scpt
set secondDig to ASCII character aNum
dropbox-public-link-copy.scpt
set numHex to ("%" & (firstDig as string) ¬
dropbox-public-link-copy.scpt
& (secondDig as string)) as string
dropbox-public-link-copy.scpt
set useChar to numHex
dropbox-public-link-copy.scpt
set theTextEnc to theTextEnc & useChar as string
dropbox-public-link-copy.scpt