You can subscribe to this list here.
| 2005 |
Jan
|
Feb
(7) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: Todd N. <osx...@ya...> - 2005-03-09 18:18:51
|
I have started to as an exercise, partaking in the Ruby Quiz. Held each week, this quiz challanges the mind of the programmer with trivial but fun exercises and solutions. This week is the conversion of Decimal to Roman and Roman to Decimal numbers. http://sensetalk.dyndns.org/examples/quiz/ The link above is my entry in solution for ST. I hope you can find the handlers in this useful. I have tested it extensively and found no bugs. The functions toRoman() and fromRoman() produce named output, and take as input the opposite. Let me know what you think! Todd Nathan __________________________________ Celebrate Yahoo!'s 10th Birthday! Yahoo! Netrospective: 100 Moments of the Web http://birthday.yahoo.com/netrospective/ |
|
From: Todd N. <osx...@ya...> - 2005-02-28 07:35:33
|
With RSD, or carpal tunnel... It's obvious important
to rest regularly,
particularly those of us that like to hack for days at
a time.
OSX comes with 'leave' a nice little program but
without the
features wanted. This script is a leave+ kinda thing,
I added
a bunch of functionality, so read the code. The
qtplay external is
required, and I renamed it after I compiled it (google
for qtplay,
download, compile, intall in /usr/bin/ or
/usr/local/bin or ~/bin)
installed it. OSX as far as I can tell does NOT come
standard with
a quicktime sound player of any kind. But this is
good, for the
qtplay is a superb example of hacking, works great,
free, source
and you get to learn about the Core stuff it uses.
That all said, here is the timetoleave replacement I
made using
Sensetalk as the core of the solution.
todd$ cat timetorest
#! /usr/bin/st
# a replacement for the 'leave' command, this one will
make statements
# and allow you to choose a sound or sentence to say,
or both.
# alarms will go off at 5 mins before, and of course 1
min and finally
# the alarm time.
# st timetorest -s time -r mins -say words -v name
-sound path -w bool -warnlist list
set the clockFormat to "24 hour" -- makes the long
time "xx:yy:zz" and the time "xx:yy"
put parseParms(the params, "") into opt -- no rules
yet...
if opt's s is EMPTY or not isaTime(opt's s) or s is
not in the keys of opt then put the short time + 60
minutes into opt's s
if opt's r is EMPTY or opt's r is not a number or r is
not in the keys of opt then put 60 into opt's r --
default 1 hour breaks
if opt's v is EMPTY or opt's v is not in
availableVoices() or "v" is not in the keys of opt
then put "Victoria" into opt's v -- Default nice
voice
if opt's w <> true and opt's w <> false or w is not in
the keys of opt then put true into opt's w
if opt's say is EMPTY or say is not in the keys of opt
then put "Time to take a break" into opt's say --
default say "Time to take a break"
if opt's sound is EMPTY or opt's sound is not a file
or sound is not in the keys of opt then put
"/System/Library/Sounds/Submarine.aiff" into opt's
sound -- system sound
if opt's warnlist is EMPTY or warnlist is not in the
keys of opt then put (5,1) into opt's warnlist --
could use this to loop until done
sort opt's warnlist numerically descending
put opt
-- a list of times to play a warning before we
actually tell the person to rest/get up.
repeat with each item in opt's warnlist
put opt's s - (it) minutes into npTime --
next play time.
repeat until the time > time(npTime)
wait 1 seconds
end repeat
if opt's w then -- pl/say if told to do so.
shell("play " & opt's sound)
shell("say -v " & opt's v && it & "
minutes until rest time.") -- ... voice.
end if
end repeat
wait until the time > opt's s
if opt's w then
play opt's s
shell("say -v " & opt's v && items 1 to -1 of
opt's say)
end if
# Test invocation:
# st ./paramParser -a 1 2 3 -b 2 -c 3 -Dash Boulder
-Super man -c 10 11
#
# Current (bogus) output:
# (a:("1","2","3"), b:("2"), c:("3"),
Dash:("Boulder"), Super:("man"))
#
to parseParms params, rules -- 'rules' support is
coming real soon now :)
put a new object into obj
delete word 1 of params -- toss the handler
name
set the itemDelimiter to "-"
delete item 1 of params -- assume params
starts with '-', all filenames at end of CLI
repeat with each item option of params
set the itemDelimiter to ","
put deQuote(item 1 of option) into key
-- the key
put () into vals
repeat with n = 2 to number of items
in option
get deQuote(item n of option)
-- the value
if it is empty then next
repeat -- likely end of option list
insert it after vals
end repeat
put obj plus properties ((key):(vals))
into obj -- why doesn't merge|replace existing values
of key?
end repeat
return obj
end parseParms
to deQuote string -- Removes all leading space
and quotes of a string, returns that string
repeat length of string times -- do leading
junk and ...
if first char of string is not in
quote & space then exit repeat
delete first char of string
end repeat
repeat length of string times -- ... do junk
in trunk
if last char of string is not in quote
& space then exit repeat
delete last char of string
end repeat
return string
end deQuote
to availableVoices
get shell("ls -1
/System/Library/Speech/Voices/ | cut -d\. -f1")
put () into voices
repeat with each line n in it
insert word 1 of n after voices
end repeat
return voices
end availableVoices
-- ugly! :)
to isaTime aTime
if char 3 of aTime is ":" then delete char 3
of aTime
put false into hValid
put false into mValid
get chars 1 to 2 of aTime
if it >= 0 and it < 24 then put true into
hValid
get chars 3 to 4 of aTime
if it >= 0 and it < 60 then put true into
mValid
if hValid and mValid then return chars 1 to 2
of aTime & ":" & chars 3 to 4 of aTime
else return false
end isaTime
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
|
|
From: Todd N. <osx...@ya...> - 2005-02-24 05:08:27
|
Dear Sensetalkers, I was working on a IRC bot/logger for Freenode using Sensetalk and needed the IRC error numbers in constants for my code to work the way I wanted (ie, clean, simple, blah blah blah). I found the page with the IRC 1459 with error codes (from 1993) and decided I want them formated in a function nicely. So, take the output of pbpaste which was used to get them off the webpage, and stuff that into a ST based filter tool, and presto magic most of the output was exactly what I want. http://sensetalk.dyndns.org/examples/irc/ This was a lesson in how to quickly (whip up) a tool that would do the job that I wanted. Could have said been done in awk, sed or grep, sure thing. Perl, you bet. Ruby or Python, no problem. Could have been done in shell. However, it was a 2 minute 'ordeal' in ST and I don't think that would be the case another language, not at least for me. Enjoy the script, its principle is what matters. YOu can get a LOT done with ST in a short amount of time. SenseTalk is a very fast, simple and clean way to devise rather complex filters. Best wishes and warm regards, Todd Nathan IORCC Founder/Judge (SeaForth) irc://irc.freenode.net/iorcc http://iorcc.dyndns.org/ __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail |
|
From: Todd N. <osx...@ya...> - 2005-02-18 07:25:38
|
Take a look, should be useful as a means to show the generic XModules of SenseTalk. Test using OS X 10.3.7 and SenseTalk 1.0.8 and SeaShell. http://sensetalk.dyndns.org/examples/xmodules/GeometricXModule.zip Ejoy! Todd Nathan ----------- some output from helper funcions ------------- put GeometricXModuleUsage() pythagorean(rise, run) -- (hypoteneus) area_volume_sphere(radius) -- (area_of_sphere, volume_of_sphere) area_volume_cylinder(radius, height) -- (area_of_cylinder, volume_of_cylinder) area_volume_cone(radius, height) -- (area_of_cone, volume_of_cone) put GeometricXModuleHandlers() pythagorean geometricXModuleHandlers geometricXModuleVersion area_volume_sphere area_volume_cylinder area_volume_cone __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
|
From: Todd N. <osx...@ya...> - 2005-02-18 07:25:37
|
Take a look, should be useful as a means to show the generic XModules of SenseTalk. Test using OS X 10.3.7 and SenseTalk 1.0.8 and SeaShell. http://sensetalk.dyndns.org/examples/xmodules/GeometricXModule.zip Ejoy! Todd Nathan ----------- some output from helper funcions ------------- put GeometricXModuleUsage() pythagorean(rise, run) -- (hypoteneus) area_volume_sphere(radius) -- (area_of_sphere, volume_of_sphere) area_volume_cylinder(radius, height) -- (area_of_cylinder, volume_of_cylinder) area_volume_cone(radius, height) -- (area_of_cone, volume_of_cone) put GeometricXModuleHandlers() pythagorean geometricXModuleHandlers geometricXModuleVersion area_volume_sphere area_volume_cylinder area_volume_cone __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
|
From: Todd N. <osx...@ya...> - 2005-02-17 22:11:12
|
Hello to you all! I just found one of the coolest apps since TickleServices now available in Beta, and it is called BellHop (formerly Concierge). BellHop is available at www.versiontracker.com, and is a very nice Scriptable Services system which comes stock with AppleScript Context and Ruby Context Support. I am currently working on making the SenseTalk Context available. In the mean time I have found this little standard new file script usable with SeaShell utilizing the Services Menu item once BellHop is installed. I think you will find the combination of SeaShell and BellHop a very pleasing experience. You can write SenseTalk scripts and use them to filter your text in your SeaShell documents (new doc text, comment addition and removal, so forth). Regards Todd Nathan #! /usr/bin/st # # Thu Feb 17 15:49:43 CST 2005 # Copyright (c) 2005, Todd Nathan. All Rights Reserved. # # Filename: newstdoc # Description: Output a standard file with copyright information, used either in # CLI and Terminal, or with the BellHop application (wonderful tool # inspired by TickleServices in NS 3.x). # Dependencies: There are no dependancies # get chars 1 to -2 of shell("date") put parseParams(the params, "") into opt if usage is in the keys of opt then usage if help is in the keys of opt then usage if d is not in the keys of opt or \ -- creation date opt's d is EMPTY then put it into opt's d if h is not in the keys of opt or \ -- copyright holder opt's h is EMPTY then put "<<Copyright Holder Here>>" into opt's h if y is not in the keys of opt or \ -- copyright year opt's y is EMPTY then put last word of it into opt's y -- copyright year if n is not in the keys of opt or \ -- file name opt's n is EMPTY then put "Run_Handler_Name" into opt's n -- file name put "-- " & item 1 of opt's d put "-- Copyright (c) " & item 1 of opt's y & ", " & item 1 of opt's h & ". All Rights Reserved." put "--" put "-- Filename: " & item 1 of opt's n & ".st" & space put "-- Description: Object Description" put "-- Dependancies: Other Objects/Files Used " put "--" put "" get item 1 of opt's n put "to " & it & "()" put " // your code wonderments here!" put "end " & it put "" put "to fName p1, p2" put " // your function code here" put " return ( aValue )" put "end fName" put "" to usage put short name of me & " -d date -h holder -y year -n filename" exit to sensetalk end usage to parseParams params, rules -- 'rules' support is coming real soon now :) put a new object into obj delete word 1 of params -- toss the handler name set the itemDelimiter to "-" delete item 1 of params -- assume params starts with '-', all filenames at end of CLI repeat with each item option of params set the itemDelimiter to "," put deQuote(item 1 of option) into key -- the key put () into vals repeat with n = 2 to number of items in option get deQuote(item n of option) -- the value if it is empty then next repeat -- likely end of option list insert it after vals end repeat put obj plus properties ((key):(vals)) into obj -- why doesn't merge|replace existing values of key? end repeat return obj end parseParams to deQuote string -- Removes all leading space and quotes of a string, returns that string repeat length of string times -- do leading junk and ... if first char of string is not in quote & space then exit repeat delete first char of string end repeat repeat length of string times -- ... do junk in trunk if last char of string is not in quote & space then exit repeat delete last char of string end repeat return string end deQuote __________________________________ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 |
|
From: Todd N. <osx...@ya...> - 2005-02-17 18:23:23
|
# Thu Jan 20 07:25:44 CST 2005 - Copyright (c) 2005,
Todd Nathan. All Rights Reserved
# This is a library to parse out like args does for
shell the parameters passed
# to the script, making into lists the values. Using
a rule based system
# you can make things work pretty much how you want it
to...
#
# (a:3b:c) # means a requires at least 1, and no more
than 3 optiosn
# # means b requires 1 or more options
# # means c is just a toggle
#
# Test invocation:
# st ./paramParser -a 1 2 3 -b 2 -c 3 -Dash Boulder
-Super man -c 10 11
#
# Current (bogus) output:
# (a:("1","2","3"), b:("2"), c:("3"),
Dash:("Boulder"), Super:("man"))
#
# Should be:
# (a:("1","2","3"), b:("2"), c:("3","10","11"),
Dash:("Boulder"), Super:("man"))
# or
# (a:("1","2","3"), b:("2"), c:("10","11"),
Dash:("Boulder"), Super:("man"))
#
# depending on how the default behaviour of the plus
properties functionality is
# to be considered. Personally I think replacement
should be default, and then
# merging as an option.
#
# Proposed syntax:
# put obj plus properties ((key):(vals)) into obj
[by merging|replacing [collisions]]
# put obj plus properties ((key):(vals)) into obj
[with collisions merged|replaced]
put parseParms(the params, "(a:3b:c)")
to parseParms params, rules -- 'rules' support is
coming real soon now :)
put a new object into obj
delete word 1 of params -- toss the handler name
set the itemDelimiter to "-"
delete item 1 of params -- assume params starts with
'-', all filenames at end of CLI
repeat with each item option of params
set the itemDelimiter to ","
put deQuote(item 1 of option) into key -- the key
put () into vals
repeat with n = 2 to number of items in option
get deQuote(item n of option) -- the value
if it is empty then next repeat -- likely end of
option list
insert it after vals
end repeat
put obj plus properties ((key):(vals)) into obj --
why doesn't merge|replace existing values of key?
end repeat
return obj
end parseParms
to deQuote string -- Removes all leading space
and quotes of a string, returns that string
repeat length of string times -- do leading junk and
...
if first char of string is not in quote & space then
exit repeat
delete first char of string
end repeat
repeat length of string times -- ... do junk in
trunk
if last char of string is not in quote & space then
exit repeat
delete last char of string
end repeat
return string
end deQuote
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
|
|
From: Todd N. <osx...@ya...> - 2005-02-13 17:51:38
|
-- Sun Feb 13 11:22:35 CST 2005
-- Copyright (c) 2005, Todd Nathan. All Rights
Reserved.
--
-- Generalized Quote, DeQuote and DeWhiting routines.
-- With of course, examples :)
---
to deQuote words, marks, deWhite
get [me parseParams: words, marks, deWhite]
put item 1 of it's marks into om
put item 2 of it's marks into cm
get it's words
repeat until it does not start with om and it does
not start with cm
if it starts with om then delete first length(om)
chars of it
if it ends with cm then delete last length(cm) chars
of it
end repeat
return it
end deQuote
to enQuote words, marks, deWhite
get [me parseParams: words, marks, deWhite]
put item 1 of it's marks into om
put item 2 of it's marks into cm
get it's words
put om before it
put cm after it
return it
end enQuote
to parseParams words, marks, deWhite
put empty object into params
if marks is not EMPTY then
put first item of marks into om --
open mark
put last item of marks into cm --
close mark
else
if universal quotingMarks is not EMPTY
then
put item 1 of universal
quotingMarks into om
put item -1 of universal
quotingMarks into cm
else
put quote into om
put quote into cm
end if
end if
if deWhite is true or deWhite is EMPTY then
get deWhite(words)
else get words
add properties ("marks":om & comma & cm) to params
add properties ("words":it) to params
return params
end parseParams
to deWhite aStr
return words first to last of aStr
end deWhite
on testquotes -- save doc as, or change name of this
handler
get enQuote("Sensetalk Rules")
put it
put deQuote(it)
get enQuote(it)
put it
put deQuote(it)
put ""
get enQuote("Sensetalk Rules", quote)
put it
put deQuote(it)
get enQuote(it)
put it
put deQuote(it)
put ""
get enQuote("Sensetalk Rules", " -x-x- , -x-x- ")
put it
get deWhite(deQuote(it, "-x-x-", true))
put it
put "<<< , >>>" into universal quotingMarks
get enQuote(it)
put it
put deQuote(it)
put ""
end testquotes
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
|