text
stringlengths
0
15.7k
source
stringlengths
6
112
set secondSpan to maxDate - minDate
randomDateAndTime.applescript
set daySpan to secondSpan div 60 / 60 / 24
randomDateAndTime.applescript
set randomDays to random number from 0 to daySpan
randomDateAndTime.applescript
set randomDate to minDate + randomDays * 24 * 60 * 60
randomDateAndTime.applescript
set time of randomDate to random number from minSeconds to maxSeconds
randomDateAndTime.applescript
return randomDate
randomDateAndTime.applescript
end randomDateAndTimeInRange
randomDateAndTime.applescript
-- Create data
Script 28-2.applescript
set n to 1000
Script 28-2.applescript
set x to createarray n
Script 28-2.applescript
set y to runningsum (randomarray n range {-1, 1})
Script 28-2.applescript
set y to multlist y with sqrt (3)
Script 28-2.applescript
set c to QuickCurve(x, y, 0)
Script 28-2.applescript
set v to c's container -- The curve belongs to a plot ...
Script 28-2.applescript
set w to v's container -- ... which belongs to a window
Script 28-2.applescript
set c1 to QuickCurve(x, "sqrt(x)", v)
Script 28-2.applescript
set c2 to QuickCurve(x, "-sqrt(x)", v)
Script 28-2.applescript
set name of v to "A random walk of " & n & " steps"
Script 28-2.applescript
set legend kind of v to 3
Script 28-2.applescript
set legend abscissa of v to n / 2
Script 28-2.applescript
set legend text size of v to 14
Script 28-2.applescript
set legend fill color of v to {1, 1, 1, 1}
Script 28-2.applescript
set label text size of v to 14
Script 28-2.applescript
set xlabel of v to "n"
Script 28-2.applescript
set name of c to "\\Sigma_{i=1.." & n & "}\\ Rnd_i"
Script 28-2.applescript
set name of c1 to "n^{1/2}"
Script 28-2.applescript
set name of c2 to "-n^{1/2}"
Script 28-2.applescript
draw w
Script 28-2.applescript
fmGUI_CustomFunctions_Open({})
fmGUI_CustomFunctions_Open.applescript
on fmGUI_CustomFunctions_Open(prefs)
fmGUI_CustomFunctions_Open.applescript
if fmGUI_NameOfFrontmostWindow() starts with "Manage Custom Functions for" then
fmGUI_CustomFunctions_Open.applescript
set manageFunctionsMenuItem to first menu item of menu 1 of menu item "Manage" of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Custom Functions"
fmGUI_CustomFunctions_Open.applescript
fmGUI_ClickMenuItem({menuItemRef:manageFunctionsMenuItem})
fmGUI_CustomFunctions_Open.applescript
windowWaitUntil({windowName:"Manage Custom Functions for", windowNameTest:"contains", whichWindow:"front"})
fmGUI_CustomFunctions_Open.applescript
set sortPopup to pop up button "View by" of window 1
fmGUI_CustomFunctions_Open.applescript
fmGUI_PopupSet({objRef:sortPopup, objValue:"function name"})
fmGUI_CustomFunctions_Open.applescript
error "unable to fmGUI_CustomFunctions_Open - " & errMsg number errNum
fmGUI_CustomFunctions_Open.applescript
end fmGUI_CustomFunctions_Open
fmGUI_CustomFunctions_Open.applescript
on fmGUI_PopupSet(prefs)
fmGUI_CustomFunctions_Open.applescript
set objRefStr to coerceToString(objRef of prefs)
fmGUI_CustomFunctions_Open.applescript
tell application "htcLib" to fmGUI_PopupSet({objRef:objRefStr} & prefs)
fmGUI_CustomFunctions_Open.applescript
end fmGUI_PopupSet
fmGUI_CustomFunctions_Open.applescript
execute front window's active tab javascript "console.log('Apple script')"
Javascript-demo.applescript
set __PATH to "/Users/ytakamoto/Google Drive/THE iDOLM@STER"
folders_to_itunes_playlist.applescript
set __ROOT_PLAYLIST_NAME to "THE iDOLM@STER"
folders_to_itunes_playlist.applescript
on songExists(p, pl)
folders_to_itunes_playlist.applescript
set songList to tracks in pl
folders_to_itunes_playlist.applescript
if p is in songList then
folders_to_itunes_playlist.applescript
log "did not exist"
folders_to_itunes_playlist.applescript
end songExists
folders_to_itunes_playlist.applescript
on folderPlaylistExists(plName, pl)
folders_to_itunes_playlist.applescript
if pl is not "" then
folders_to_itunes_playlist.applescript
set foldNames to every playlist whose parent is pl
folders_to_itunes_playlist.applescript
repeat with fold in foldNames
folders_to_itunes_playlist.applescript
if name of fold is plName then
folders_to_itunes_playlist.applescript
set tempthing to some folder playlist where name is plName
folders_to_itunes_playlist.applescript
end folderPlaylistExists
folders_to_itunes_playlist.applescript
on playlistExists(plName, pl)
folders_to_itunes_playlist.applescript
repeat with fold in (some playlist where name is plName and special kind is none)
folders_to_itunes_playlist.applescript
if parent of fold is pl then
folders_to_itunes_playlist.applescript
end playlistExists
folders_to_itunes_playlist.applescript
on isDirectory(somePath) -- someItem is a file reference
folders_to_itunes_playlist.applescript
if kind of (info for (POSIX file somePath)) is "folder" then
folders_to_itunes_playlist.applescript
end isDirectory
folders_to_itunes_playlist.applescript
on strip(input)
folders_to_itunes_playlist.applescript
set filePath to input as text
folders_to_itunes_playlist.applescript
set Trimmed_filePath to do shell script "echo " & quoted form of filePath & " | sed -e 's/^[ ]*//' | sed -e 's/[ ]*$//'"
folders_to_itunes_playlist.applescript
on createPlaylistFolder(path)
folders_to_itunes_playlist.applescript
end createPlaylistFolder
folders_to_itunes_playlist.applescript
on recTraverse(_PATH, pathList, currPlaylist)
folders_to_itunes_playlist.applescript
set parentPlaylist to ""
folders_to_itunes_playlist.applescript
set firstTime to true
folders_to_itunes_playlist.applescript
repeat with i in list folder _PATH
folders_to_itunes_playlist.applescript
copy pathList to newPathList
folders_to_itunes_playlist.applescript
if parentPlaylist is "" and _PATH is not my __PATH then
folders_to_itunes_playlist.applescript
set parentPlaylist to parent of currPlaylist
folders_to_itunes_playlist.applescript
set newItem to (do shell script "perl -pe 's|\\[.*?\\] ||' <<<" & quoted form of i)
folders_to_itunes_playlist.applescript
set end of newPathList to newItem
folders_to_itunes_playlist.applescript
set newPath to (POSIX path of _PATH & "/" & i)
folders_to_itunes_playlist.applescript
if my isDirectory(newPath) and newItem is not in {"Scans", "scans", "scan", "Scan"} then
folders_to_itunes_playlist.applescript
if not my folderPlaylistExists(newItem, currPlaylist) then
folders_to_itunes_playlist.applescript
make folder playlist in currPlaylist with properties {name:newItem}
folders_to_itunes_playlist.applescript
set newPlaylist to (some folder playlist where name is newItem)
folders_to_itunes_playlist.applescript
my recTraverse(newPath, newPathList, newPlaylist)
folders_to_itunes_playlist.applescript
else if newPath ends with ".mp3" then
folders_to_itunes_playlist.applescript
if firstTime then
folders_to_itunes_playlist.applescript
make playlist in parentPlaylist with properties {name:item -2 of newPathList}
folders_to_itunes_playlist.applescript
set newPlaylist to (some playlist where name is item -2 of newPathList and special kind is none)
folders_to_itunes_playlist.applescript
set firstTime to false
folders_to_itunes_playlist.applescript
delete currPlaylist
folders_to_itunes_playlist.applescript
if not my songExists(newPath, newPlaylist) then
folders_to_itunes_playlist.applescript
add (newPath as POSIX file as alias) to newPlaylist
folders_to_itunes_playlist.applescript
log "Meh."
folders_to_itunes_playlist.applescript
log _PATH & "/" & i
folders_to_itunes_playlist.applescript
end recTraverse
folders_to_itunes_playlist.applescript
if not my folderPlaylistExists(my __ROOT_PLAYLIST_NAME, "") then
folders_to_itunes_playlist.applescript
make folder playlist with properties {name:my __ROOT_PLAYLIST_NAME}
folders_to_itunes_playlist.applescript
set rootPlaylist to some playlist where name is my __ROOT_PLAYLIST_NAME and special kind is folder
folders_to_itunes_playlist.applescript
my recTraverse(__PATH, {}, rootPlaylist)
folders_to_itunes_playlist.applescript
setDesktopPicture("/Library/Desktop Pictures/Solid Colors/Black.png")
setDesktopPicture.applescript