Posted by Revolution
Wed, 21 Nov 2007 12:34:00 GMT
วิธีการก็เอา syntax ที่มีอยู่ใน typo มา hack ซะ ซึ่งมันเป็น macro อยู่แล้ว
จาก plugin ชื่อ typo_textfilter_code ก็ copy ทั้ง folder มาเป็นชื่อ typo_textfilter_uvcode จากนั้นก็แก้ทุกอย่างที่เดิมเป็น code ให้เป็น uvcode แล้วก็แก้ไฟล์ typo_textfilter_uvcode/lib/typo_textfilter_uvcode.rb
ดังนี้
def self.macrofilter(blog,content,attrib,params,text="")
lang = attrib['lang'] || "plain_text"
title = attrib['title']
cssclass = attrib['class'] || 'iplastic'
linenumber = attrib['linenumber'] || false
text = text.to_s.gsub(/\r/,'').gsub(/\A\n/,'').chomp
convertor = Uv
text = convertor.parse(text, "xhtml", lang, linenumber, cssclass)
"<div class=\"typocode\">#{text}</div>"
end
จากนั้นก็เอา css จะใช้ไปใส่ที่ public/stylesheets/user-style.css
ในนี้เพิ่ม
overflow: auto;
เข้าไปใน class pre
Posted in ruby | Tags hack, highlight, rails, syntax | no comments | no trackbacks
Posted by Revolution
Wed, 21 Nov 2007 07:31:00 GMT
<?php
require 'DB.php';
$dsn = 'mysql://root:bank24@localhost/vhcs2';
$dbh = DB::connect($dsn);
if(DB::isError($dbh)){
die ($dbh->getMessage());
}
$result = $dbh->query("select * from admin");
if(DB::isError($result)) { die($result->getMessage());}
while($row = $result->fetchRow()){
print $row[0]."\n";
}
$row = $dbh->getAll("select * from admin");
print_r($row);
?>
ใช้กับ textile ไม่ได้แหะ ลองอีก code
def self.macrofilter(blog,content,attrib,params,text="")
lang = attrib['lang'] || "plain_text"
title = attrib['title']
cssclass = attrib['class'] || 'iplastic'
linenumber = attrib['linenumber'] || false
text = text.to_s.gsub(/\r/,'').gsub(/\A\n/,'').chomp
convertor = Uv
text = convertor.parse(text, "xhtml", lang, linenumber, cssclass)
"<div class=\"typocode\">#{text}</div>"
end
Posted in ruby | Tags highlight, typo, uv | no comments | no trackbacks
Posted by Revolution
Wed, 21 Nov 2007 05:10:00 GMT
Piers Cawley หนึ่งใน main developer ของ typo ออกมาพูดใน blog ตัวเอง
ถึงการหยุดนิ่งของ typo และยังมีการชมเชย Mephisto ที่มีการทำงานที่ดีกว่า typo ทำให้ developer ทำงานได้ง่ายด้วยการเขียน code ที่สะอาด
แต่ไม่นานมานี้ดูท่าจะมีการเปลี่ยนแปลงครั้งใหญ่กัน typo (และคงอีกหลายๆตัว) กับการมาของ rails 2.0 จะรอดีหรือจะ folk ดี หรือจะเขียนเองดีน้า….
อยากได้ plugin เหมือน jazzy ใน Mephisto ไปถาม punneng ดีกว่า
Posted in ruby | Tags cms, rails, ruby, typo | no comments | no trackbacks
Posted by Revolution
Tue, 20 Nov 2007 05:27:00 GMT
วันนี้จะเข้าไป update ข้อมูลใน rubyforge.org ต้อง login ผ่าน https ใส่ password ตั้งหลายครั้งแต่ก็ไม่ผ่าน สงสัยติด transparent proxy เลยลองผ่าน proxy ของมันดู proxy.asianet.co.th:80 กลับเข้าได้ T_T เอาไงกับมันดีจะหมดสัญญาแล้วด้วย เปลี่ยนเป็น TOT หรือ CAT ดีไหมเนี่ยแต่ TOT มันเหมือนคนร้องไห้อ้าปากเลย
Posted in Gerneral, linux | Tags net, rubyforge, true | no comments | no trackbacks
Posted by Revolution
Mon, 19 Nov 2007 11:07:00 GMT
I’m a ruby programming hobbyist and doing rails hosting in Thailand especially ruby (and rails). Because in Thailand, there is nobody doing rails hosting. In fact, I fall in love with ruby as much as i written. One factor that make ruby grow up, there is a product that can release ruby and rails powers. So I decide to do Control panel for Rails hosting in ruby programming.
This project is base on vhcs2 concept with additional features. I draw some concept of control panel with freemind software
I call this project name “REDGEM” and now I opening project to rubyforge.org and get approve alrady. It can be accessed to redgem project
For rough concept, I separate work into 2 path
- Web Control Panel – It is written by Ruby on Rails. This part is interacted with user.
- Engine – It is also written by Ruby. The engine has responsibility to edit file configuration and deployment
For Future design, UI it may not be a web, it can be other or other language
As you see this is not easy one to do, I need help. Anyone can help me please let me know.
Thank You
File: redgem concept
ภาษาไทยข้างใน
Read more...
Posted in ruby, linux | Tags control panel, hosting, linux, rails, ruby | no comments | no trackbacks
Posted by Revolution
Thu, 08 Nov 2007 16:41:00 GMT
พอดีมีทำ upload ทั้งรูปและไฟล์ pdf ด้วย file_column แต่มีการกำหนดไว้ว่าให้ resize รูปที่ขึ้นไป พอ upload pdf ก็เกิดปัญหานะสิเพราะมัน resize ทำ thumbnail ไม่ได้ (ที่จริงก็ได้แต่ยังไงไม่รู้) เพราะมันจะทำให้ WebBrick crash ไป และก็ขี้เกียจไปสร้างอันใหม่
code เดิม
validates_file_format_of :image, :in => ["gif", "jpg", "png","pdf"]
file_column :image, :magick => {
:versions => {
:thumb => {:crop => "1:1",
:size => "50x50!", :name => "thumb"},
}
}
ทุกไฟล์ที่ upload มันก็ทำ version ตามที่กำหนดไว้หมด แก้โดย
IMAGE_EXTENSIONS = {
"image/gif" => "gif",
"image/jpg" => "jpg",
"image/png" => "png"
}
OTHER_EXTENSIONS = {
"application/pdf" => "pdf",
"application/msword" => "doc",
"application/zip" => "zip",
"text/plain" => "txt",
"text/xml" => "xml",
"video/mpeg" => "mpeg",
"video/quicktime" => "mov",
}
file_column :image, :magick => {
:options => {:mime_extensions => IMAGE_EXTENSIONS},
:versions => {
:thumb => {:crop => "1:1",
:size => "50x50!", :name => "thumb"},
}
}
file_column( :image,
:options => {:mime_extensions => OTHER_EXTENSIONS})
ทำมันทั้งยังงี้ล่ะ เผื่อไฟล์อื่นจะได้ใช้ได้ด้วย ส่วน validates_file_format_of ก็เพื่มเอาเท่าที่ใช้
ไม่รู้ว่า act_as_attachment จะเป็นไงมั่ง แต่ตอนนี้สำหรับหผม file_column ยังโอเคอยู่
ที่มา
Posted in ruby | Tags rails, tips, upload | no comments | no trackbacks
Posted by Revolution
Mon, 05 Nov 2007 03:49:00 GMT
พอดีมีปัญหาเกี่ยวกับ log ใน rails ซึ่งมันก็กินเนื้อที่เยอะพอดูเลยพยามหาวิธีปิดมัน แต่สุดท้ายก็รู้ว่ามันปิดไม่ได้ เพราะ log มันเอาไว้ดูความเคลื่อนไหว ก็เลยได้แต่พยามหาวิธีให้มันเก็บน้อยลง ไปเจอที่ wiki ของ rails สรุปได้ว่า
ActiveRecord จะไปเรียกใช้ class Logger เพื่อจะทำการเก็บ log ลงไฟล์
ใน development จะใช้ :debug
ใน production จะใช้ :info
ซึ่งทั้งหมดก็มี :debug, :info, :warn, :error, :fatal ซึ่ง log class ของ ruby ยังมี :any แต่ไม่ทำงานบน rails ถ้าอยากให้ log น้อยลง เอาเฉพาะที่มี error ก็ใช้ :error
ให้เพิ่ม
config.log_level = :error
ลงในไฟล์
config/environment.rb
หรือถ้าจะปรับแต่งใดๆ ดูได้ที่ wiki ของ rails ครับ
Posted in ruby | Tags logger, rails, ruby | no comments | no trackbacks
Posted by Revolution
Fri, 02 Nov 2007 17:09:00 GMT
เนื่องจากวันนี้อยากไปเดินงานคอมมาร์ท ไปทั้งทีขอเสียเงินหน่อยได้ของกลับมา
- แบตเตอรี่ ซันโย eneloop หร้อมแท่นชารจ์เร็ว ราคา 999
- MP3 FM Modulator ไว้ใช้กับรถยนต์ เสียบได้ทั้ง USB, SD, และ Line-in ไม่ต้องมีเครื่องเล่นเลย ราคา 470
รีบๆๆเลย รีบกลับบ้านเพราะอยากลอง MP3 FM Modulator ขึ้นรถปุ๊ป เสียบๆๆ ใส่ๆๆ เปิดวิทยุ …..
^_^"
ไม่ดังหว่ะ แต่มันเล่นแล้วนะ กดไปกดมา ไม่ได้เปิดเสียงนี่หว่า ฮาๆ แล้วก็หาคลื่นที่มันไม่มีคนใช้มาจูนเข้าด้วยกัน จำได้พี่แสน เคยใช้ 107.2 ไม่มีใครใช้แน่ๆๆ เอาลอง …
ฉิบหาย วิทยุชุมชุน เพียบเลย เอาเป็นว่าไอ้พวกลูครึ่งทั้งหลายไม่มีที่ไหนว่างเลย เวลามัน ทod แล้วเสียงเหมือนทับๆๆกัน ฟังไม่ค่อยเพราะเลย พยามหาคลื่นที่ไม่ได้อยู่แถวนั้น แถวๆบางนา พระโขนง ใช้ 92.8 พอได้
หลังจากส่งจ๊ะกลับบ้านเลยนึกได้ว่ามันมีคลื่นนึงปกติไม่มีใครใช่ แต่เมืองไทยมีกฏหมายว่าไม่ให้ใช้เหมือนกันแต่เสือกมีคนใช้ได้ 87.5 ไง เอาว่ะนอกเวลาราชการไม่มีเสียงหรอก โป๊ะเชะ ใช้ได้เนียนๆเลย เอาเป็นว่าใช้ 87.6 แล้วกัน เพื่อใช้กลางวันด้วย หุหุ
เรื่องนี้นะถ้าจะหวัง ขอให้มีที่ว่างซักช่องให้ผมได้ใช้ด้วยเถอะๆ (470 เบียดวิทยุชุมชนหลักแสน)
ส่วนงานคอมมาร์ทปีนี้มี Microsoft Hardware มาหลายบูทเลย นึกในใจ เมื่อไหร่จะมี OpenHarware มาขาย ไม่ก็ Linux Competable Hardware มั่ง
ของในงานราคาบางอย่างก็ถูกว่า (หลักสิบ) ของบางอย่างให้เดินดูทั่วๆ งานก่อนค่อยตัดสินใจซื้อเพราะบางร้านขายถูกกว่าเป็นร้อยก็มี เช่น MP3 FM Modulator บางร้านขาย 550 นะ
พวกร้านคอมทั้งหลาย กำไรน้อยแต่ทำไมเปิดกันจัง เพราะมันชาย VAT ได้ไง ไว้จะอธิบายหลักการอีกที ไปนอนดีก่า
Posted in Gerneral, travel | Tags commart, fair, mp3 | no comments | no trackbacks