sudo gem update --system 1.5.3
*** แนะนำ ***
Ruby 1.9.x แนะนำ rubygems 1.7.2 or 1.6.2
Ruby 1.8.x แนะนำ rubygems 1.5.3
*** ใช้เมื่อไร ***
- start server ไม่ได้
sudo gem update --system 1.5.3
*** แนะนำ ***
Ruby 1.9.x แนะนำ rubygems 1.7.2 or 1.6.2
Ruby 1.8.x แนะนำ rubygems 1.5.3
*** ใช้เมื่อไร ***
- start server ไม่ได้
เอ่อออ!!!!!!!! ต้องทำ Datadict จาก database ที่ใช้งานมาแล้ว 5 ปี (ไม่เคยมี comment หรือ description อะไรมาก่อนด้วย T T )
ใจสู้รึป่าว ไหวมั๊ยบอกมา ... ไม่ไหวก็เลิกซะนะ
ลองค้นๆ ดู ได้ความว่า comment หรือ description ใน postgresql เนี่ย มันจะเก็บอยู่ใน pg_description.description
แต่ว่าตัวที่จะบอกว่า table, view, column ชื่ออะไรนั้นมันเก็บไว้ที่ pg_class.relname
หาไปหามาได้ query ออกมาเป็นแบบนี้
สำหรับ table
SELECT c.relname As tname, c.relkind AS type, pg_get_userbyid(c.relowner) AS towner,
t.spcname AS tspace, n.nspname AS sname, d.description
FROM pg_class As c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
LEFT JOIN pg_description As d ON (d.objoid = c.oid AND d.objsubid = 0)
WHERE c.relkind IN('r') AND pg_get_userbyid(c.relowner) = 'owner_name'
ORDER BY n.nspname, c.relname ;
สำหรับ column
SELECT c.relname As tname, a.attname As column_name, c.relkind AS type,
pg_get_userbyid(c.relowner) AS towner, t.spcname AS tspace,
n.nspname AS sname, d.description
FROM pg_class As c
INNER JOIN pg_attribute As a ON c.oid = a.attrelid
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
LEFT JOIN pg_description As d ON (d.objoid = c.oid AND d.objsubid = a.attnum)
WHERE c.relkind IN('r') AND pg_get_userbyid(c.relowner) = 'owner_name'
AND a.attname NOT IN ('tableoid', 'cmax', 'xmax', 'cmin', 'xmin', 'oid', 'ctid')
ORDER BY n.nspname, c.relname ;
เวลาเราอยากเปิดโปรแกรมอะไร ตั้งแต่เปิดเครื่อง เราก็แค่สร้าง Short Cut ไปวางไว้ที่ Folder Startup
เรามาพลิกแพลงทำกับ Oracle VM VirtualBox กัน
เริ่มสร้าง Short Cut ตามรูป

กำหนดโปรแกรมที่ต้องการจะเปิดนั่นคือ Oracle VM VirtualBox
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" -nologo startvm "ibatt.in.th" --type headless

กำหนดชื่อให้ Short Cut

หลังจากได้ Short Cut ตามต้องการแล้ว เราก็นำไปใส่ที่ Folder Startup
:)
Control Panel -> Region and Language -> Administrative -> Change system locale
require ‘RMagick’
include Magick
…
result = Magick::Image.new(1000, 725){ self.background_color = ‘#FFFFFF’ }
watermark = Magick::Image.read(“#{RAILS_ROOT}/public/logo/watermark.png”).first
logo = Magick::Image.read(“#{RAILS_ROOT}/public/logo/logo_xxx.png”).first
signature1 = Magick::Image.read(“#{RAILS_ROOT}/public/logo/sig1.png”).first
signature2 = Magick::Image.read(“#{RAILS_ROOT}/public/logo/sig2.png”).first
student_img = Magick::Image.read(“#{RAILS_ROOT}/public/images/gui/user_90x90.png”).first
result = result.composite(watermark, Magick::CenterGravity, 0, 0, Magick::OverCompositeOp)
result = result.composite(logo, Magick::NorthGravity, 0, 20, Magick::OverCompositeOp)
result = result.composite(signature1, Magick::NorthGravity, -250, 600, Magick::OverCompositeOp)
result = result.composite(signature2, Magick::NorthGravity, 250, 600, Magick::OverCompositeOp)
result = result.composite(student_img, Magick::NorthGravity, 345, 50, Magick::OverCompositeOp)
line1 = Draw.new
result.annotate(line1, 1000,30, 0, 200, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”){
line1.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
line1.gravity = Magick::NorthGravity
line1.pointsize = 18
line1.fill = “#000000″
line1.font_weight = Magick::BoldWeight
}
line2 = Draw.new
result.annotate(line2, 1000,30, 0, 240, “วุฒิบัตรฉบับนี้ให้ไว้เพื่อแสดงว่า”){
line2.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
line2.gravity = Magick::NorthGravity
line2.pointsize = 18
line2.fill = “#000000″
line2.font_weight = Magick::BoldWeight
}
student_name = Draw.new
result.annotate(student_name, 1000,30, 0, 280, “#{courses_student.prefix} #{courses_student.firstname} #{courses_student.lastname}”){
student_name.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
student_name.gravity = Magick::NorthGravity
student_name.pointsize = 18
student_name.fill = “#000000″
student_name.font_weight = Magick::BoldWeight
}
detail = Draw.new
result.annotate(detail, 1000,30, 0, 340, “ได้เข้าฝึกอบรม #{certificate_template.detail}”){
detail.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
detail.gravity = Magick::NorthGravity
detail.pointsize = 18
detail.fill = “#000000″
detail.font_weight = Magick::BoldWeight
}
if courses_student.is_certified
detail2 = Draw.new
result.annotate(detail, 1000,30, 0, 370, “และผ่านเกณฑ์การประเมินผลสัมฤทธิ์การอบรม”){
detail2.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
detail2.gravity = Magick::NorthGravity
detail2.pointsize = 18
detail2.fill = “#000000″
detail2.font_weight = Magick::BoldWeight
}
end
line3 = Draw.new
result.annotate(line3, 1000,30, 0, 4100, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”){
line3.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
line3.gravity = Magick::NorthGravity
line3.pointsize = 18
line3.fill = “#000000″
line3.font_weight = Magick::BoldWeight
}
line4 = Draw.new
result.annotate(line4, 1000,30, 0, 440, “xxxxxxxxxxxxxxxxxxxxx”){
line4.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
line4.gravity = Magick::NorthGravity
line4.pointsize = 18
line4.fill = “#000000″
line4.font_weight = Magick::BoldWeight
}
line5 = Draw.new
result.annotate(line5, 1000,30, 0, 470, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx “){
line5.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
line5.gravity = Magick::NorthGravity
line5.pointsize = 18
line5.fill = “#000000″
line5.font_weight = Magick::BoldWeight
}
line6 = Draw.new
result.annotate(line6, 1000,30, 0, 500, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”){
line6.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
line6.gravity = Magick::NorthGravity
line6.pointsize = 18
line6.fill = “#000000″
line6.font_weight = Magick::BoldWeight
}
thai_mon = ["", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม" "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"]
date = Draw.new
result.annotate(date, 1000,30, 0, 540, “ให้ไว้ ณ วันที่ #{Date.today.day} เดือน #{thai_mon[Date.today.mon]} พ.ศ. #{Date.today.year + 543}”){
date.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
date.gravity = Magick::NorthGravity
date.pointsize = 18
date.fill = “#000000″
date.font_weight = Magick::BoldWeight
}
sig2_name = Draw.new
result.annotate(line6, 1000,30, 250, 668, “(xxxxxxxxxxxxxxxxxxxxxxxxxxxxx)”){
sig2_name.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
sig2_name.gravity = Magick::NorthGravity
sig2_name.pointsize = 18
sig2_name.fill = “#000000″
sig2_name.font_weight = Magick::BoldWeight
}
sig2_desc = Draw.new
result.annotate(line6, 1000,30, 250, 688, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”){
sig2_desc.font = “#{RAILS_ROOT}/public/fonts/TH_Niramit_AS_Bold.ttf”
sig2_desc.gravity = Magick::NorthGravity
sig2_desc.pointsize = 18
sig2_desc.fill = “#000000″
sig2_desc.font_weight = Magick::BoldWeight
}
filename = “#{directory}/cert_#{@course.id}_#{courses_student.student_id}_#{courses_student.student_id}.jpg”
result.write(filename)