text
stringlengths
0
15.7k
source
stringlengths
6
112
repeat while str ends with " "
Alfred Library.applescript
set str to items 1 thru -2 of str as text
Alfred Library.applescript
return str
Alfred Library.applescript
end q_trim
Alfred Library.applescript
on q_clean_list(lst)
Alfred Library.applescript
if lst is missing value or class of lst is not list then return lst
Alfred Library.applescript
set l to {}
Alfred Library.applescript
repeat with lRef in lst
Alfred Library.applescript
set i to contents of lRef
Alfred Library.applescript
if i is not missing value then
Alfred Library.applescript
if class of i is not list then
Alfred Library.applescript
set end of l to i
Alfred Library.applescript
else if class of i is list then
Alfred Library.applescript
set end of l to my q_clean_list(i)
Alfred Library.applescript
end q_clean_list
Alfred Library.applescript
on q_encode(str)
Alfred Library.applescript
if class of str is not text or my q_is_empty(str) then return str
Alfred Library.applescript
set s to ""
Alfred Library.applescript
repeat with sRef in str
Alfred Library.applescript
set c to contents of sRef
Alfred Library.applescript
if c is in {"&", "'", "\"", "<", ">", tab} then
Alfred Library.applescript
if c is "&" then
Alfred Library.applescript
set s to s & "&amp;"
Alfred Library.applescript
else if c is "'" then
Alfred Library.applescript
set s to s & "&apos;"
Alfred Library.applescript
else if c is "\"" then
Alfred Library.applescript
set s to s & "&quot;"
Alfred Library.applescript
else if c is "<" then
Alfred Library.applescript
set s to s & "&lt;"
Alfred Library.applescript
else if c is ">" then
Alfred Library.applescript
set s to s & "&gt;"
Alfred Library.applescript
else if c is tab then
Alfred Library.applescript
set s to s & "&#009;"
Alfred Library.applescript
set s to s & c
Alfred Library.applescript
end q_encode
Alfred Library.applescript
on q_date_to_unixdate(theDate)
Alfred Library.applescript
set {day:d, year:y, time:t} to theDate
Alfred Library.applescript
copy theDate to b
Alfred Library.applescript
set b's month to January
Alfred Library.applescript
set m to (b - 2500000 - theDate) div -2500000
Alfred Library.applescript
tell (y * 10000 + m * 100 + d) as text
Alfred Library.applescript
set UnixDate to text 5 thru 6 & "/" & text 7 thru 8 & "/" & text 1 thru 4
Alfred Library.applescript
set h24 to t div hours
Alfred Library.applescript
set h12 to (h24 + 11) mod 12 + 1
Alfred Library.applescript
if (h12 = h24) then
Alfred Library.applescript
set ampm to " AM"
Alfred Library.applescript
set ampm to " PM"
Alfred Library.applescript
set min to t mod hours div minutes
Alfred Library.applescript
set s to t mod minutes
Alfred Library.applescript
tell (1000000 + h12 * 10000 + min * 100 + s) as text
Alfred Library.applescript
set UnixTime to text 2 thru 3 & ":" & text 4 thru 5 & ":" & text 6 thru 7 & ampm
Alfred Library.applescript
return UnixDate & " " & UnixTime
Alfred Library.applescript
end q_date_to_unixdate
Alfred Library.applescript
on q_unixdate_to_date(theUnixDate)
Alfred Library.applescript
return date theUnixDate
Alfred Library.applescript
end q_unixdate_to_date
Alfred Library.applescript
on q_timestamp_to_date(timestamp)
Alfred Library.applescript
if length of timestamp = 13 then
Alfred Library.applescript
set timestamp to characters 1 thru -4 of timestamp as text
Alfred Library.applescript
set h to do shell script "date -r " & timestamp & " \"+%Y %m %d %H %M %S\""
Alfred Library.applescript
set year of mydate to (word 1 of h as integer)
Alfred Library.applescript
set month of mydate to (word 2 of h as integer)
Alfred Library.applescript
set day of mydate to (word 3 of h as integer)
Alfred Library.applescript
set hours of mydate to (word 4 of h as integer)
Alfred Library.applescript
set minutes of mydate to (word 5 of h as integer)
Alfred Library.applescript
set seconds of mydate to (word 6 of h as integer)
Alfred Library.applescript
return mydate
Alfred Library.applescript
end q_timestamp_to_date
Alfred Library.applescript
on q_date_to_timestamp(theDate)
Alfred Library.applescript
return ((current date) - (date ("1/1/1970")) - (time to GMT)) as miles as text
Alfred Library.applescript
end q_date_to_timestamp
Alfred Library.applescript
on q_send_notification(theMessage, theDetails, theExtra)
Alfred Library.applescript
set _path to do shell script "pwd"
Alfred Library.applescript
if _path does not end with "/" then set _path to _path & "/"
Alfred Library.applescript
if theMessage is missing value then set theMessage to ""
Alfred Library.applescript
if theDetails is missing value then set theDetails to ""
Alfred Library.applescript
if theExtra is missing value then set theExtra to ""
Alfred Library.applescript
if my q_trim(theMessage) is "" and my q_trim(theExtra) is "" then set theMessage to "notification"
Alfred Library.applescript
do shell script (quoted form of _path & "bin/q_notifier.helper com.runningwithcrayons.Alfred-2 " & quoted form of theMessage & " " & quoted form of theDetails & " " & quoted form of theExtra)
Alfred Library.applescript
end q_send_notification
Alfred Library.applescript
on q_notify()
Alfred Library.applescript
my q_send_notification("", "", "")
Alfred Library.applescript
end q_notify
Alfred Library.applescript
on q_encode_url(str)
Alfred Library.applescript
local str
Alfred Library.applescript
return (do shell script "/bin/echo " & quoted form of str & ¬
Alfred Library.applescript
" | perl -MURI::Escape -lne 'print uri_escape($_)'")
Alfred Library.applescript
end q_encode_url
Alfred Library.applescript
on q_decode_url(str)
Alfred Library.applescript
" | perl -MURI::Escape -lne 'print uri_unescape($_)'")
Alfred Library.applescript
end q_decode_url
Alfred Library.applescript
on encode(theString)
Alfred Library.applescript
if class of theString is not text then return theString
Alfred Library.applescript
if theString contains "\"" then set theString to my SearchandReplace(theString, "\"", "\\\"")
Alfred Library.applescript
end encode
Alfred Library.applescript
set limitBTsync to the value of (make variable with properties {name:"limitBTsync"})
btsync_control.scpt
set frontApp to name of item 1 of (every process whose frontmost is true)
btsync_control.scpt
tell process "BitTorrent Sync" to set frontmost to true
btsync_control.scpt
set buttonList to every button of toolbar 1 of window 1 of process "BitTorrent Sync"
btsync_control.scpt
repeat with b in buttonList
btsync_control.scpt