Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-12-04 14:33 GMT+01:00 Cecil Westerhof :

>
>
> 2017-11-19 23:00 GMT+01:00 jungle boogie :
>
>> 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 1
setinsertVmstat "
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   \
swapfree  buffers  cache \
swapIn  swapOut  \
blockIn blockOut \
interuptsPerSec contextSwitchesPerSec\
userTimesystemTimeidleTime 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
dbclose

-- 
Cecil Westerhof
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Keith Medcalf

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-
>boun...@mailinglists.sqlite.org] 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
>
>wrote:
>
>> 2017-11-18 15:14 GMT+01:00 Eric :
>>
>> > On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
>> > cldwester...@gmail.com> 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
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Gerry Snyder
Sorry, I did not notice that your question was about exec rather than expr.

Gerry

On Dec 4, 2017 8:40 AM, "Gerry Snyder"  wrote:

> No. One set of braces around the whole list of arguments.
>
> Gerry
>
> On Dec 4, 2017 8:27 AM, "Cecil Westerhof"  wrote:
>
>> 2017-12-04 15:24 GMT+01:00 Gerry Snyder :
>>
>> > 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
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread J Decker
On Sat, Nov 18, 2017 at 6:35 AM, Cecil Westerhof 
wrote:

> 2017-11-18 15:14 GMT+01:00 Eric :
>
> > On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
> > cldwester...@gmail.com> 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
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-12-04 16:40 GMT+01:00 Gerry Snyder :

> 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"  wrote:
>
> > 2017-12-04 15:24 GMT+01:00 Gerry Snyder :
> >
> > > 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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Gerry Snyder
No. One set of braces around the whole list of arguments.

Gerry

On Dec 4, 2017 8:27 AM, "Cecil Westerhof"  wrote:

> 2017-12-04 15:24 GMT+01:00 Gerry Snyder :
>
> > 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
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Malcolm Greene
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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread 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" 
 wrote:

2017-12-04 15:24 GMT+01:00 Gerry Snyder :

> 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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-12-04 15:24 GMT+01:00 Gerry Snyder :

> 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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Gerry Snyder
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"  wrote:

> 2017-11-19 23:00 GMT+01:00 jungle boogie :
>
> > 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
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-12-04 Thread Cecil Westerhof
2017-11-19 23:00 GMT+01:00 jungle boogie :

> 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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-11-19 Thread jungle boogie

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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-11-18 Thread Cecil Westerhof
2017-11-18 15:14 GMT+01:00 Eric :

> On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof <
> cldwester...@gmail.com> 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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Good resources for TCL/TK

2017-11-18 Thread Eric
On Sat, 18 Nov 2017 14:43:23 +0100, Cecil Westerhof  
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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Good resources for TCL/TK

2017-11-18 Thread Cecil Westerhof
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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users