Good resources for TCL/TK

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Good resources for TCL/TK

Cecil Westerhof-5
I found the benefits for TCL/TK. But this is a SQLite mailing list, so not
the right place to ask questions if it is not connected to SQLite also.
What would be good resources for TCL/TK?

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Eric-2
On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <[hidden email]> wrote:
> I found the benefits for TCL/TK. But this is a SQLite mailing list, so not
> the right place to ask questions if it is not connected to SQLite also.
> What would be good resources for TCL/TK?
>

There is the Usenet group comp.lang.tcl , also accessible through Google
Groups at https://groups.google.com/forum/#!forum/comp.lang.tcl .

There is also the Tclers' Wiki at http://wiki.tcl.tk/ which is full
of information. You can ask questions by editing them into the "Ask,
and it shall be given" page http://wiki.tcl.tk/37862 .

Eric
--
ms fnd in a lbry
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Cecil Westerhof-5
2017-11-18 15:14 GMT+01:00 Eric <[hidden email]>:

> On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
> [hidden email]> wrote:
> > I found the benefits for TCL/TK. But this is a SQLite mailing list, so
> not
> > the right place to ask questions if it is not connected to SQLite also.
> > What would be good resources for TCL/TK?
> >
>
> There is the Usenet group comp.lang.tcl , also accessible through Google
> Groups at https://groups.google.com/forum/#!forum/comp.lang.tcl .
>
> There is also the Tclers' Wiki at http://wiki.tcl.tk/ which is full
> of information. You can ask questions by editing them into the "Ask,
> and it shall be given" page http://wiki.tcl.tk/37862 .
>

​Thanks, I will look into those.


By the way TCL can calculate factorial 995 in less as 4 seconds. Not to bad.

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Jungle Boogie
In reply to this post by Cecil Westerhof-5
Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
> I found the benefits for TCL/TK. But this is a SQLite mailing list, so not
> the right place to ask questions if it is not connected to SQLite also.
> What would be good resources for TCL/TK?
>

There's also a pretty active IRC room on freenode, it's #tcl.

Let us know how your experiences go with tcl.



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Cecil Westerhof-5
2017-11-19 23:00 GMT+01:00 jungle boogie <[hidden email]>:

> Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
>
>> I found the benefits for TCL/TK. But this is a SQLite mailing list, so not
>> the right place to ask questions if it is not connected to SQLite also.
>> What would be good resources for TCL/TK?
>>
>>
> There's also a pretty active IRC room on freenode, it's #tcl.
>
> Let us know how your experiences go with tcl.


​I like it very much. It is a bit get used to, but I will manage I think.
;-)

One think I like that global variables are not default exposed in
procedures.

I wrote something to help me choose which (of my about 30) teas I am going
to brew. ;-)
 ​

​I also wrote a program to store systems statistics in a SQLite database:
​    #!/usr/bin/env tclsh

    ### Improvements
    # Get database from conf-file


    package require sqlite3


    proc getCPUTemp {} {
        if {1 != [regexp -all -line {^CPU_TEMP: +\+([0-9.]+)°C } [exec
sensors] -> temp]} {
            error {Did not get exactly a single temperature line from [exec
sensors] output}
        }
        return ${temp}
    }

    proc storeCPUTemp {} {
        storeMessage cpu-temp [getCPUTemp]
    }

    proc storeMessage {type message} {
        db eval "
          INSERT INTO messages
          (type, message)
          VALUES
          (:type, :message)
    "
    }

    proc storeSwap {} {
        storeMessage swap-usage [exec swapon --noheadings --show]
    }

    if {$argc != 1} {
        error "Error: ${argv0} DATABASE"
    }
    sqlite db  [lindex $argv 0]
    while {true} {
        after [expr 1000 * (60 - [clock format [clock seconds] -format %S])]
        set   currentSeconds [clock seconds]
        db transaction {
            storeCPUTemp
            # At the whole hour we save swap usage
            if {[clock format ${currentSeconds} -format %M] == "00"} {
                storeSwap
            }
        }
    }
    # Not really necessary because the above loop never ends
    # But I find this more clear and is robuster against change
    db close

​I am open for improvements.​

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Gerry Snyder-4
It is always a good idea to put the arguments of [expr] in braces. That way
they are byte-compiled.

Gerry

On Dec 4, 2017 6:33 AM, "Cecil Westerhof" <[hidden email]> wrote:

> 2017-11-19 23:00 GMT+01:00 jungle boogie <[hidden email]>:
>
> > Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
> >
> >> I found the benefits for TCL/TK. But this is a SQLite mailing list, so
> not
> >> the right place to ask questions if it is not connected to SQLite also.
> >> What would be good resources for TCL/TK?
> >>
> >>
> > There's also a pretty active IRC room on freenode, it's #tcl.
> >
> > Let us know how your experiences go with tcl.
>
>
> ​I like it very much. It is a bit get used to, but I will manage I think.
> ;-)
>
> One think I like that global variables are not default exposed in
> procedures.
>
> I wrote something to help me choose which (of my about 30) teas I am going
> to brew. ;-)
>  ​
>
> ​I also wrote a program to store systems statistics in a SQLite database:
> ​    #!/usr/bin/env tclsh
>
>     ### Improvements
>     # Get database from conf-file
>
>
>     package require sqlite3
>
>
>     proc getCPUTemp {} {
>         if {1 != [regexp -all -line {^CPU_TEMP: +\+([0-9.]+)°C } [exec
> sensors] -> temp]} {
>             error {Did not get exactly a single temperature line from [exec
> sensors] output}
>         }
>         return ${temp}
>     }
>
>     proc storeCPUTemp {} {
>         storeMessage cpu-temp [getCPUTemp]
>     }
>
>     proc storeMessage {type message} {
>         db eval "
>           INSERT INTO messages
>           (type, message)
>           VALUES
>           (:type, :message)
>     "
>     }
>
>     proc storeSwap {} {
>         storeMessage swap-usage [exec swapon --noheadings --show]
>     }
>
>     if {$argc != 1} {
>         error "Error: ${argv0} DATABASE"
>     }
>     sqlite db  [lindex $argv 0]
>     while {true} {
>         after [expr 1000 * (60 - [clock format [clock seconds] -format
> %S])]
>         set   currentSeconds [clock seconds]
>         db transaction {
>             storeCPUTemp
>             # At the whole hour we save swap usage
>             if {[clock format ${currentSeconds} -format %M] == "00"} {
>                 storeSwap
>             }
>         }
>     }
>     # Not really necessary because the above loop never ends
>     # But I find this more clear and is robuster against change
>     db close
>
> ​I am open for improvements.​
>
> --
> Cecil Westerhof
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Cecil Westerhof-5
2017-12-04 15:24 GMT+01:00 Gerry Snyder <[hidden email]>:

> It is always a good idea to put the arguments of [expr] in braces. That way
> they are byte-compiled.
>

​You mean like:
    exec {swapon} (--noheadings} {--show}

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Peter da Silva
Like
  expr {sqrt($foo) < 3.7 && $bazflag > 0}

Instead of
  expr sqrt($foo) < 3.7 && $bazflag > 0

Same for the first argument to “if”, second argument to “for”, etc.

On 12/4/17, 9:27 AM, "sqlite-users on behalf of Cecil Westerhof" <[hidden email] on behalf of [hidden email]> wrote:

    2017-12-04 15:24 GMT+01:00 Gerry Snyder <[hidden email]>:
   
    > It is always a good idea to put the arguments of [expr] in braces. That way
    > they are byte-compiled.
    >
   
    ​You mean like:
        exec {swapon} (--noheadings} {--show}



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

python-9
In reply to this post by Cecil Westerhof-5
Python has some good bindings for TLC/TK and SQLite. These bindings are
built into the Python standard library and work cross-platform with no
additional dependencies other than the core Python install.

Malcolm
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Gerry Snyder-4
In reply to this post by Cecil Westerhof-5
No. One set of braces around the whole list of arguments.

Gerry

On Dec 4, 2017 8:27 AM, "Cecil Westerhof" <[hidden email]> wrote:

> 2017-12-04 15:24 GMT+01:00 Gerry Snyder <[hidden email]>:
>
> > It is always a good idea to put the arguments of [expr] in braces. That
> way
> > they are byte-compiled.
> >
>
> ​You mean like:
>     exec {swapon} (--noheadings} {--show}
>
> --
> Cecil Westerhof
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Cecil Westerhof-5
2017-12-04 16:40 GMT+01:00 Gerry Snyder <[hidden email]>:

> No. One set of braces around the whole list of arguments.
>

​That does not work:
exec {swapon --noheadings --show}
couldn't execute "swapon --noheadings --show": no such file or directory
while evaluating {exec {swapon --noheadings --show}}

or:
exec swapon {--noheadings --show}
swapon: unrecognized option '--noheadings --show'



On Dec 4, 2017 8:27 AM, "Cecil Westerhof" <[hidden email]> wrote:

>
> > 2017-12-04 15:24 GMT+01:00 Gerry Snyder <[hidden email]>:
> >
> > > It is always a good idea to put the arguments of [expr] in braces. That
> > way
> > > they are byte-compiled.
> > >
> >
> > ​You mean like:
> >     exec {swapon} (--noheadings} {--show}
>

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

J Decker
In reply to this post by Cecil Westerhof-5
On Sat, Nov 18, 2017 at 6:35 AM, Cecil Westerhof <[hidden email]>
wrote:

> 2017-11-18 15:14 GMT+01:00 Eric <[hidden email]>:
>
> > On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
> > [hidden email]> wrote:
> > > I found the benefits for TCL/TK. But this is a SQLite mailing list, so
> > not
> > > the right place to ask questions if it is not connected to SQLite also.
> > > What would be good resources for TCL/TK?
> > >
> >
> > There is the Usenet group comp.lang.tcl , also accessible through Google
> > Groups at https://groups.google.com/forum/#!forum/comp.lang.tcl .
> >
> > There is also the Tclers' Wiki at http://wiki.tcl.tk/ which is full
> > of information. You can ask questions by editing them into the "Ask,
> > and it shall be given" page http://wiki.tcl.tk/37862 .
> >
>
> ​Thanks, I will look into those.
>
>
> By the way TCL can calculate factorial 995 in less as 4 seconds. Not to
> bad.
>

https://gist.github.com/d3x0r/924b618d4cdb81c0cc813987090395b5
node can calculate factorial 32000 in less than 4 seconds :)

>
> --
> Cecil Westerhof
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Gerry Snyder-4
In reply to this post by Gerry Snyder-4
Sorry, I did not notice that your question was about exec rather than expr.

Gerry

On Dec 4, 2017 8:40 AM, "Gerry Snyder" <[hidden email]> wrote:

> No. One set of braces around the whole list of arguments.
>
> Gerry
>
> On Dec 4, 2017 8:27 AM, "Cecil Westerhof" <[hidden email]> wrote:
>
>> 2017-12-04 15:24 GMT+01:00 Gerry Snyder <[hidden email]>:
>>
>> > It is always a good idea to put the arguments of [expr] in braces. That
>> way
>> > they are byte-compiled.
>> >
>>
>> ​You mean like:
>>     exec {swapon} (--noheadings} {--show}
>>
>> --
>> Cecil Westerhof
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Keith Medcalf
In reply to this post by J Decker

CPython can calculate the factorial of 108000 in less than 4 seconds :)

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of J Decker
>Sent: Monday, 4 December, 2017 09:06
>To: SQLite mailing list
>Subject: Re: [sqlite] Good resources for TCL/TK
>
>On Sat, Nov 18, 2017 at 6:35 AM, Cecil Westerhof
><[hidden email]>
>wrote:
>
>> 2017-11-18 15:14 GMT+01:00 Eric <[hidden email]>:
>>
>> > On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
>> > [hidden email]> wrote:
>> > > I found the benefits for TCL/TK. But this is a SQLite mailing
>list, so
>> > not
>> > > the right place to ask questions if it is not connected to
>SQLite also.
>> > > What would be good resources for TCL/TK?
>> > >
>> >
>> > There is the Usenet group comp.lang.tcl , also accessible through
>Google
>> > Groups at https://groups.google.com/forum/#!forum/comp.lang.tcl .
>> >
>> > There is also the Tclers' Wiki at http://wiki.tcl.tk/ which is
>full
>> > of information. You can ask questions by editing them into the
>"Ask,
>> > and it shall be given" page http://wiki.tcl.tk/37862 .
>> >
>>
>> ​Thanks, I will look into those.
>>
>>
>> By the way TCL can calculate factorial 995 in less as 4 seconds.
>Not to
>> bad.
>>
>
>https://gist.github.com/d3x0r/924b618d4cdb81c0cc813987090395b5
>node can calculate factorial 32000 in less than 4 seconds :)
>
>>
>> --
>> Cecil Westerhof
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Good resources for TCL/TK

Cecil Westerhof-5
In reply to this post by Cecil Westerhof-5
2017-12-04 14:33 GMT+01:00 Cecil Westerhof <[hidden email]>:

>
>
> 2017-11-19 23:00 GMT+01:00 jungle boogie <[hidden email]>:
>
>> Thus said Cecil Westerhof on Sat, 18 Nov 2017 14:43:23 +0100
>>
>>> I found the benefits for TCL/TK. But this is a SQLite mailing list, so
>>> not
>>> the right place to ask questions if it is not connected to SQLite also.
>>> What would be good resources for TCL/TK?
>>>
>>>
>> There's also a pretty active IRC room on freenode, it's #tcl.
>>
>> Let us know how your experiences go with tcl.
>
>
​I also made a script to store the values from vmstat:

#!/usr/bin/env tclsh

### Improvements
# Get database from conf-file


package require sqlite3


if {$argc != 1} {
    error "Error: ${argv0} DATABASE"
}
sqlite db [lindex $argv 0]
db     timeout 10000
set    insertVmstat "
    INSERT INTO vmstat (
        runlength,
        -- procs
        runable,         uninteruptable,
        -- memory
        swap,            free,                  buffers,  cache,
        -- swap
        swapIn,          swapOut,
        -- io
        blockIn,         blockOut,
        -- system
        interuptsPerSec, contextSwitchesPerSec,
        -- cpu
        userTime,        systemTime,            idleTime, waitTime,
stolenTime
    ) VALUES (
        :runLength,
        :runable, :uninteruptable,
        :swap, :free, :buffers, :cache,
        :swapIn, :swapOut,
        :blockIn, :blockOut,
        :interuptsPerSec, :contextSwitchesPerSec,
        :userTime, :systemTime, :idleTime, :waitTime, :stolenTime
    );
"
set   runLength 60
puts  "Using an interval of ${runLength} seconds"
after [expr {1000 * (60 - [clock seconds] % 60)}]
set   vmstat [open "|vmstat -n ${runLength}"]
# The first three lines need to be skipped
for {set i 0} {${i} < 3} {incr i} {
    gets ${vmstat}
}
while {true} {
    lassign [gets ${vmstat}]                                 \
        runable         uninteruptable                       \
        swap            free                  buffers  cache \
        swapIn          swapOut                              \
        blockIn         blockOut                             \
        interuptsPerSec contextSwitchesPerSec                \
        userTime        systemTime            idleTime waitTime stolenTime
    db eval ${insertVmstat}
}
# Not really necessary because the above loop never ends
# But I find this more clear and is robuster against change
close vmstat
db    close

--
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users