google-sheet2Html

/*! * * Google Sheets To HTML v0.9a * * To use, simply replace the "tq?key=" value in the * URL below with your own unique Google document ID * * The Google document's sharing must be set to public * */ google.load('visualization', '1', { packages: ['table'] }); var visualization; function drawVisualization() { var query = new google.visualization.Query('https://spreadsheets.google.com/tq?key=https://docs.google.com/spreadsheets/d/1-vUEZ9tae5C_OXzSi0dQPWwUrO3H5S-gImB5afFgqDg/edit?usp=sharing'); query.setQuery('SELECT A, B, C, D label A "Duration", B "Song", C "Requested By", D "URL"'); query.send(handleQueryResponse); } function handleQueryResponse(response) { if (response.isError()) { alert('There was a problem with your query: ' + response.getMessage() + ' ' + response.getDetailedMessage()); return; } var data = response.getDataTable(); visualization = new google.visualization.Table(document.getElementById('table')); visualization.draw(data, { legend: 'bottom' }); } google.setOnLoadCallback(drawVisualization);

Friday, September 6, 2019

วิธี ติดตั้ง GUI Tk บน Ruby


วิธี ติดตั้ง GUI tk บน Ruby


 

ผมใช้ Linux ต้องการให้ Ruby มี GUI ซึ่งมีหลาย ตัว แต่เลือก ใช้ Tk ต้องทำการติดตั้งเพิ่มเติม

เริ่มจากติดตัง libraries ที่ต้องการก่อน
$ sudo apt-get install tcl8.5-dev tk8.5-dev

เมื่อเริิ่มติดตัง จะเกิด ข้อผิดพลาด 
 
$ sudo gem install tk
Fetching: tk-0.2.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing tk:
ERROR: Failed to build gem native extension.

สาเหตุจากต้องทำการ config parameters ให้ทำการแก้ไขด้วยคำสั่ง
$ sudo ln -s /usr/lib/x86_64-linux-gnu/tcl8.5/tclConfig.sh /usr/lib/tclConfig.sh

$ sudo ln -s /usr/lib/x86_64-linux-gnu/tk8.5/tkConfig.sh /usr/lib/tkConfig.sh

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libtcl8.5.so.0 /usr/lib/libtcl8.5.so.0

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libtk8.5.so.0 /usr/lib/libtk8.5.so.0

แล้่วทำการติดตั้งอีกครั้ง ด้วยคำสั่ง

$ sudo gem install tk

Building native extensions. This could take a while...
Successfully installed tk-0.2.0
Parsing documentation for tk-0.2.0
Installing ri documentation for tk-0.2.0
Done installing documentation for tk after 9 seconds
1 gem installed

ลอง ทำการ ทดสอบ ใน irb

$ irb
irb(main):001:0> require 'tk'
=> true

ผลที่ได้ true แสดงว่า ติดตั้งเสร็จแล้ว 


ลองสร้าง GUI Tk

ชื่อไฟล์ TkGooTts.rb
ดังนี้



จากนั้นทำการแก้ค่า permission เพื่อให้ทำงาน
$ sudo chmod 777 TkGooTts.rb

สังให้ทำงาน ด้วย
$ ./TkGooTts.rb

จะได้ ผลดังนี้



บทความจาก
The bindings for the standard Ruby GUI toolkit, Tk, need some trickery in order to be installed on Ubuntu