Posted by Revolution
Wed, 06 Aug 2008 10:03:00 GMT
หลังจากที่ได้ D80 มาสมใจอยาก เห็นหลายๆคนเวลาแสดงรูปจะมีการแสดงความเป็นเจ้าของโดยใส่ลายน้ำหรือใส่ข้อมูล exif หรือลายเซ็นไว้ ก็เลยอยากจะทำมั่ง ใน Photoshop ก็สามารถเขียน script(java script) ให้ทำทีละหลายๆรูปได้ หรือจะใช้ ACDSee ก็ทำได้ ส่วนสำหรับบน Linux ไม่ค่อยมีข้อมูลเท่าไหร่ แต่ Tools และ Libs เพียบ เลยตกงว่าจะออกกำลังเขียน ไหนๆก็ไหนๆ แล้วเขียนด้วย ruby ซะเลย นี่เป็น version ใช้เอง แต่ก็สามารถเขียนให้ดีกว่านี้เพื่อเอาไปใช้กับงานอื่นๆได้ code License GPL2
After I got D80, I saw many people show up their photos with a water mark, signature, exif data. I think that I have to do same way. Photoshop can do with a script, ACDSee can do also but Linux have no idea about that ( I may not know). By the way ,Linux come wiht many tools and Libs so I make a decision to write a ruby script for do that. This code is under GPL2 License. This version is for my own purpose, it may not be well design.
Requirement: Ruby 1.8.6, RMagick
Usage: run script at same Photo Directory, script will generate a directory "stamped" and file name is "stamped-
.jpg"
Read more...
Posted in ruby, linux | Tags linux, photo, ruby | no comments | no trackbacks
Posted by Revolution
Tue, 06 May 2008 15:37:00 GMT
I have a problem that I install passenger 1.0.3 that work fine with low transeaction web but for some web need high transaction , it need fcgi.
The question that how can I use fcgi for some web and other run by passenger
<VirtualHost xxx>
RailsAllowModRewrite on
RailsAutoDetect off
</VirtualHost>
Posted in ruby | Tags apache, fcgi, passenger, ruby, virtualhost | no comments | no trackbacks
Posted by Revolution
Tue, 29 Apr 2008 07:04:00 GMT
I monitor this application typo 5.0.2 consume too much memory about 50 – 80 MB which full feature. So i will try to make lite version for typo because I still like it. By the way, If my try is not successful, I will make my own blog system
มันกิน mem มากเหลือเกินไม่ไหว ถ้ามีโอกาศ จะลองทำแบบ lite ดู แต่ถ้าไม่ได้ลองเขียนใช้เองแล้ว ไม่ไหวเปลือง
Posted in ruby | Tags rails, ruby, typo | no comments | no trackbacks
Posted by Revolution
Fri, 18 Apr 2008 07:35:00 GMT
Now Speedthai Rails hosting in Thailand switch from Fcgid to Passenger (mod_rails) which consume less memory and better performance
ตอนนี้ Speedthai Rails Hosting ในประเทศไทยได้เปลี่ยนจาการใช้ fcgid ไปเป็น Passenger (mod_rails) ที่มีประสิทธิภาพดีกว่าและยังบริโภคแรมน้อยกว่า
อยู่ในขั้นทดสอบ
Posted in ruby, linux | Tags debian, linux, mod_rails, passenger, ruby | no comments | no trackbacks
Posted by Revolution
Wed, 20 Feb 2008 09:40:00 GMT
อยู่ในภาคทดสอบ แบ่งเป็น 2 แบบคืออ่านธรรมดากับแบบค่าเงิน
ทดสอบได้ที่ num2word
class Number
def initialize
@unit = %w[ศูนย์ หนึ่ง สอง สาม สี่ ห้า หก เจ็ด แปด เก้า]
@qtys = ["แสน", "หมื่น", "พัน", "ร้อย", "สิบ", "หน่วย"]
@mils = "ล้าน"
@zero = "ศูนย์"
@twenty = "ยี่"
@unitone = "เอ็ด"
end
def self.th_word(number)
Number.new.to_s(number)
end
def self.th_currency(number)
Number.new.to_s_currency(number)
end
def self.commify(number)
(s=number.to_s;x=s.length;s).rjust(x+(3-(x%3))).gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,')
end
def to_s(value)
if (number = value.to_s.split(".");number.length) >2 then return ("'.' more than 1") end
re = []
f = to_s_float(number[1]) if !number[1].nil?
out = to_s_decimal(number[0])
re[0] = f if !f.nil?
re[1] = out
if !f.nil? then re[2] = re[1] + "จุด" + re[0] else re[2] = re[1] end
return re.reverse
end
def to_s_currency(value)
w = to_s(value).reverse
f = value.to_s.gsub(/(\w*)+\./,"0.").to_f if !w[0].nil?
w[0] = to_s_decimal((f * 100.0).round.to_s) if !f.nil?
if !f.nil? then w[2] = w[1] + "จุด" + w[0] else w[2] = w[1] end
return w.reverse
end
def to_s_float(value)
return float_wordify(value).flatten.compact.join(' ').gsub(/ ,/,',')
end
def to_s_decimal(value)
return quantify(value).flatten.compact.join(' ').gsub(/ ,/,',')
end
private
def padded_groups(v)
out = []
padded = (s=v.to_s.gsub(/\D/i,"");x=s.length;s).rjust(x+(6-(x%6))).gsub(/ /,'0')
padded.scan(/.{6}/)
end
def wordify(v)
out = []
@unitone = "หนึ่ง" if v.to_i == 1
for cur in 0 .. v.length - 1
if cur ==4 and v[cur] == '2'[0]
out << @twenty
elsif cur ==4 and v[cur] == '1'[0]
out << ""
elsif cur ==5 and v[cur] == '1'[0]
out << @unitone
else
out << @unit[v[cur]-'0'[0]]
end
end
return out
end
def float_wordify(v)
out = []
for cur in 0 .. v.length - 1
out << @unit[v[cur]-'0'[0]]
end
out.pop while out.last == @zero
return out
end
def quantify(v)
v = padded_groups(v).reverse
pos = v.length - 1
out = []
while pos >= 0
if v[pos] == ','
out << ','
next
end
word = wordify(v[pos])
for po in 0 .. word.length - 1
if word[po] == @zero then next end
if @qtys[po] != "หน่วย" then out << word[po] + @qtys[po] else out << word[po] end
end
out <<@mils if pos > 0
pos -= 1
end
out.shift while out.first == @mils
out << @zero if out.length.zero?
return out
end
end
Posted in ruby | Tags class, number, ruby, word | no comments | no trackbacks
Posted by Revolution
Tue, 12 Feb 2008 10:35:00 GMT
Source จาก http://sohne.net/articles/2006/04/30/convert-numbers-to-words/ เท่าที่แกะดูก็ไม่ยากแต่ไม่เข้าใจว่า หลายที่เงื่อนไขไม่ลงเลย สงสัยทำเผื่อไว้
Source from http://sohne.net/articles/2006/04/30/convert-numbers-to-words/ I have some confuse with this code, some condition will not may happen but i still be.
มีที่ดีกว่านี้ที่ http://www.deveiate.org/projects/Linguistics/wiki/English
class Number
def self.to_words(number)
Number.new.to_s(number)
end
def self.commify(number)
(s=number.to_s;x=s.length;s).rjust(x+(3-(x%3))).gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,')
end
def initialize
@unit = %w[zero one two three four five six seven eight nine]
@teen = %w[ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen]
@tens = %w[zero ten twenty thirty fourty fifty sixty seventy eighty ninety]
@qtys = %w[hundred thousand million billion trillion quadrillion quintillion]
@zero = ["zero"]
@hundred = "hundred"
@sepr = "and"
end
def to_s(number)
out = quantify(number).flatten
for x in 0 .. out.length - 1
out[x] = nil if out[x] == @sepr && out[x+1] == @sepr
out[x] = nil if out[x] == "," && out[x+1] == ","
end
out.compact!
out = @zero if out.length == 1 && out[0] == @sepr
out.pop while out.last == @sepr
out.shift while out.first == @sepr
out.join(' ').gsub(/ ,/,',')
end
private
def padded_groups(v)
out = []
padded = (s=v.to_s;x=s.length;s).rjust(x+(3-(x%3))).gsub(/ /,'0')
padded.scan(/.{3}/)
end
def wordify(v)
out = []
zero = '0'[0]
h, t, u = v[0] - zero, v[1] - zero, v[2] - zero
if h != 0
out << @unit[h]
out << @hundred
end
out << @sepr if h != 0 && (t != 0 || u != 0)
out << @sepr if h == 0 && t == 0 && u != 0
if t == 1
out << @teen[u]
else
out << @tens[t] if t != 0
out << @unit[u] if u != 0
end
return out
end
def quantify(v)
v = padded_groups(v).reverse
cur = pos = v.length - 1
out = []
while pos >= 0
if v[pos] == ','
out << ','
next
end
word = wordify(v[pos])
if word[0] != nil
out << word
out << @qtys[cur] if cur != 0
else
out << @sepr
end
cur -= 1
pos -= 1
end
return out
end
end
puts Number.to_words(1234567890)
puts Number.commify(1234567890)
ถ้าอยากรู้ว่า code ทำงานอย่างไรอ่านต่อข้างใน
Read more...
Posted in ruby | Tags ruby | 1 comment | no trackbacks
Posted by Revolution
Tue, 05 Feb 2008 12:20:00 GMT
เขียนลง Blognone
Ruby เป็นภาษาที่ได้รับความสนใจไม่น้อย จนกระทั่งมีคนอยากให้ใช้งานกับ .NET ได้ด้วย ทางด๊อกเตอร์เคลลี่ ผู้พัฒนา Ruby.NET ได้ประกาศผ่านทางกูเกิ้ลกรุ๊ปแล้วว่าเขาจะเลิกพัฒนา Ruby.NET โดยเหตุผลว่า IronRuby นั่นประสพความสำเร็จและไปได้ไกลกว่า
เนื่องจาก Ruby.NET เองแรกเริ่มก็เป็นโครงงานที่แตกตัวออกมาจาก IronRuby ซึ่งถ้าจะทำ Ruby.NET ให้เข้าได้กับ DLR (Dynamic Language Runtime) ต้องทำการเปลี่ยนแปลงหลายอย่าง และด๊อกเตอร์เคลลี่มั่นใจว่ามันจะดีกว่า CLR (Common Language Runtime) ที่ใช้อยู่ในปัจจุบัน
ทางผู้พัฒนา Ruby.NET ก็มีทีท่าจะไปช่วยพัฒนา IronRuby อยู่ด้วย
ที่มา: Google Group
Posted in ruby | Tags ruby, .net | no comments | no trackbacks
Posted by Revolution
Thu, 17 Jan 2008 07:20:00 GMT
ไหนๆก็ update เป็น typo 5.0.2 แล้วก็เลยลองเปลี่ยน theme เพราะ theme เห่ามีปัญหาไม่ยอมเว้น space กับภาษาไทย ก็เลยลองหาดูจาก typo theme
เลยได้ theme eggdrop สีส้มเขียวอ่อนๆ ดูสบายตาดี ลูเล่นน่ารัก
แต่ใจอยากได้ origami แต่ค่อนข้างมี Bug หลาย feature ใม่ได้ ขี้เกียจแก้ด้วย เลยตกลงปลงใจที่ Theme eggdrop
ถ้าจะแก้ก็ไปแก้ที่ css ไม่รู้ว่าใช้รูปเยอะแค่ไหน
Posted in ruby | Tags art, css, theme, typo | no comments | no trackbacks
Posted by Revolution
Wed, 16 Jan 2008 16:18:00 GMT
เปลี่ยนไปเยอะมาก ทั้ง front end และ back end มีการจัดวางเมนูได้ดีขึ้น ใช้ง่ายขึ้น สามารถ edit theme ได้บางส่วน ที่สำคัญยังเพิ่มระบบ multi user ด้วย
ป.ล. ถ้าจะให้ดีทำ ระบบ plugin ให้ง่ายกว่านี้ก็ดีนะ อยากได้ revision เหมือน drupal จะได้เป็น Wiki ได้ด้วย
Posted in ruby | Tags cms, rails, ruby, typo | 5 comments | no trackbacks
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