2016-11-29

1-9位數不重複印出來 (練習問題)

使用者輸入1 印1-9
使用者輸入2 印1-98 (11, 22, 33等重複的不印)
使用者輸入3 印1-987 (121, 988, 667等有重複的不印)


#!/usr/bin/tclsh
#
# Test on Tcl 8.6
#

puts -nonewline "Please input a number: "
flush stdout
gets stdin number
if {$number <= 0 || $number >= 10} {
   puts "The range is 1 - 9."
   exit
}

set max [expr 10 ** $number]

puts "\nNow get the result:"
puts "==========="
puts "Start"
puts "==========="
puts -nonewline "1"
for {set i 2} {$i < $max} {incr i} {
    set var [regexp "1.*1|2.*2|3.*3|4.*4|5.*5|6.*6|7.*7|8.*8|9.*9|0.*0" $i]
    if {$var != 1} {
        puts -nonewline ", $i"
    }
}
puts "\n==========="
puts "End"
puts "==========="

2016-11-18

tcl.mqttc

Source code


tcl.mqttc

About


This Tcl extension is based on Paho MQTT C Client, but only support synchronous API and basic SSL/TLS support (server needs setup needClientAuth to false).

Test server: Apache ActiveMQ

我發現 Apache ActiveMQ 有支援 MQTT,所以使用 Paho MQTT C Client 的實作,包裝了一個 Tcl extension 來測試。

TLS/SSL 只支援 Server authentication/Anonymous connection,Mutual authentication 則有問題(應該說我不知道怎麼正確設定,稍微搜尋了一下網路上的解法,還是設不起來),所以只有放上去關於 Server authentication 的部份。


2016/11/19 更新
我重新檢視了一下 log,發現我好像沒有正確的加入資料到 server 端的 trueStore,重做一次以後就可以正常工作。所以我把 Mutual authentication 相關的部份也推送上去 github 了。

2016-11-14

tclcubrid v0.9.3

Source code

tclcubrid

About


CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.

Main changelog

  1. Free memory when connect fail

 這是一個小更新的版本。

2016-11-11

MonetDB ODBC (Linux/openSUSE) test

MonetDB ODBC driver 的部份,首先必須要先安裝 unixODBC,然後編譯的時候需要有編譯 ODBC driver。 unixODBC 需要設定二個檔案。/etc/unixODBC/odbc.ini 與 /etc/unixODBC/odbcinst.ini。


首先是 odbcinst.ini 的內容:
[MonetDB]
Description     = ODBC driver for MonetDB server
Driver          = /usr/local/lib64/libMonetODBC.so
Setup           = /usr/local/lib64/libMonetODBCs.so
FileUsage       = 1

再來是 odbc.ini,
[MonetDB]
Description     = MonetDB
Driver          = MonetDB
Trace           = No
TraceFile       =
Database        = demo
Host            = localhost
UserName        = monetdb
Password        = monetdb
Port            = 50000
ConfigFile      =

我們使用 TDBCODBC 進行驗證:
package require tdbc::odbc

set connStr "DSN=MonetDB; UID=monetdb; PWD=monetdb;"
tdbc::odbc::connection create db $connStr

set statement [db prepare {create table person (id integer, name varchar(40))}]
$statement execute
$statement close

set statement [db prepare {insert into person values(1, 'leo')}]
$statement execute
$statement close

set statement [db prepare {insert into person values(2, 'yui')}]
$statement execute
$statement close

set statement [db prepare {SELECT * FROM person}]

$statement foreach row {
    puts [dict get $row id]
    puts [dict get $row name]
}

$statement close

set statement [db prepare {drop table person}]
$statement execute
$statement close

2016-11-06

tclcubrid v0.9.2

Source code

tclcubrid

About


CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.

Main changelog

  1. Update Thread_Exit method

 這是一個小更新的版本。

2016-11-04

tclcubrid v0.9.1

Source code:
tclcubrid


About:

CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.


Main changelog:

  1. Update TDBC configure method

 這是一個小更新的版本,更新 TDBC configure method(加入 -readonly option)。