วันศุกร์, กรกฎาคม 04, 2551

On a different stand point.

วันศุกร์, มิถุนายน 20, 2551



วันอาทิตย์, มิถุนายน 01, 2551




From: www.zdnet.com.au

วันศุกร์, พฤษภาคม 30, 2551

someone notices that binary of Google I/O t-shirts spell GOOGLEKO which should be GOOGLEIO.

Let test with my Ruby.

#googleio.rb
#!/usr/bin/env ruby
module TextToBinary
def TextToBinary.encode(text)
text.scan(/./m) do |char|
(@bin ||= []) << char.unpack('B8').first.scan(/./m).map { |bit| bit = bit.eql?('1') ? '0' : 'o' }
end
return @bin
end
end

name = 'GOOGLEIO'
on_tshirt = 'GOOGLEKO'

outputs = TextToBinary.encode(name)
puts "-----#{name}-----"
outputs.each { |out| p out }

puts "BUT!"

puts "-----#{on_tshirt}----"
result = TextToBinary.encode(on_tshirt)
result.each { |res| p res }

Funny.

วันเสาร์, พฤษภาคม 24, 2551

incredible guitar player



"Human knows that he can play guitar with their finger and he thinks it's such a 'make sense' way to make sweet-sounding song.
Yes,we agree.
Above all, god knows that human doesn't know everything. God says that it just works for you but man says it's awesome solution ever in my age.
...Even in fundamental particle, we don't know what the Quarks is.", ZDK said.

วันเสาร์, พฤษภาคม 17, 2551

ได้สติกเกอร์จาก Creative Hacker มา

สำหรับใครไป BarCamp Chiangmai เดี๋ยวคงจะได้กัน :)

วันศุกร์, พฤษภาคม 16, 2551

เอามาแบ่งปัน เผื่อ tweetple ท่านไหนอยากเอาไปเล่น
เขียนเล่นๆได้ออกมาแบบนี้
อย่าหวังผลว่าจะถูกต้องมาก เขียนเอามันส์ :)

#! /usr/bin/env ruby
################################################
# pre-installed
# 1. sudo gem install activesupport
# 2. sudo gem install hpricot
# 3. sudo gem install gchart
# How to run?

# username = 'whoyouare'
# city = 'whereareyou'
# tweets = Tweet.new(username, :local => city) #
# tweets.stats(:of => :last_24hrs)

# just for fun script, dont' trust the result :P
#################################################
require 'rubygems'
require 'activesupport'
require 'hpricot'
require 'open-uri'
require 'gchart'

class Tweet
def initialize(username, options={})
@username = username
@twittr_url = "http://twitter.com/#{@username}"
@page = 1
@doc = Hpricot(twittr_page)
@tweets = [current_tweet]
@tweets.concat(page_tweets)
local = options[:local]
locality(local) unless local.nil?
end

def locality(city)
# where else you could add.. i'm lazy...
case city
when 'bangkok'
@zone_offset = 7
when 'london', 'paris'
@zone_offset = 1
when 'boston'
@zone_offset = -4
else
@zone_offset = 0
end
end

def twittr_page
page = ""
open("#{@twittr_url}?page=#{@page}",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "zdk",
"Referer" => "http://ziddik.blogspot.com/") {|f|
f.each_line { |line| page << line }
}
page
end

def current_tweet
tweet,time = @doc/'div.desc'/'p'
tweet = tweet.inner_html
time = DateTime.parse(time.at('abbr')['title'])
[tweet, time]
end

def page_tweets
(@doc/'div.tab'/'tr.hentry').map do |tweet|
tweet,time = tweet/'span'
tweet = tweet.inner_html.gsub(/^\s*(.*)\s*$/, '\1')
time = DateTime.parse(time.at('abbr')['title'])
[tweet, time]
end
end

def has_older?
(@doc/'div.tab'/'div.pagination'/'a').last.inner_text =~ /Older/
end

def each_tweet
if @tweets.empty?
return nil unless has_older?
@page += 1
@doc = Hpricot(twittr_page)
@tweets = page_tweets
end
@tweets.shift
end

def break_when(options = {})
current_time = options[:current]
tweet_time = options[:tweet]
case options[:stat]
when :last_24hrs
ressult = current_time.yesterday >= tweet_time and tweet_time.year == current_time.year
when :per_hour
result = current_time.months_ago(1) >= tweet_time # get 1 month stats
end
return result
end

def parse_date(time)
return DateTime.parse(time)
end

def get_stats(stat)
hour_data = Array.new(24, 0)
current_update_time = current_tweet.last
while t = each_tweet
tweet,time = t
hour_data[(time.hour+(@zone_offset))%24] += 1
current_year = DateTime.now.year
current_time = parse_date(current_update_time.to_s)
tweet_time = parse_date(time.to_s)
break if break_when(:stat => stat, :current => current_time, :tweet => tweet_time)
end
chart_url = GChart.line(
:title => "#{@username} Tweets #{stat.to_s.humanize}",
:data => hour_data,
:width => 400,
:height => 300,
:extras => { 'chxt' => 'x,y', 'chxl' => "0:|#{(0..23).to_a.join('|')}|1:|#{hour_data.min}|#{hour_data.max}" }
).to_url
puts chart_url
end

def last_24hrs_stats
get_stats(:last_24hrs)
end

def per_hour_stats
get_stats(:per_hour)
end

def stats(options = {})
case options[:of].to_sym
when :last_24hrs
last_24hrs_stats
when :per_hour
per_hour_stats
end
end
end

username = 'zdk'
city = 'bangkok'
tweets = Tweet.new(username, :local => city) #
tweets.stats(:of => :last_24hrs)

วันเสาร์, พฤษภาคม 03, 2551


From toybox to toolshed

วันอาทิตย์, เมษายน 20, 2551

เห็นเล่นกันพักใหญ่แล้ว...
ขอแป๊ะไว้บ้าง เดี๋ยวตกเทรนด์


ว่างจัดเป็น chart สวยงาม


เขียนด้วย Ruby เผื่อใครอยากเล่น

1 #history.rb
2
def run(command)
3 IO.popen(command, 'r+') do |io|
4 io.close_write
5 return io.read
6 end
7 end
8
9 commands = {}
10 history = run("cut -f1 -d' ' /Users/zdk/.bash_history | sort | uniq -c | sort -nr | head -n 10")
11 history.each do |line|
12 tmp = line.strip.split
13 key = tmp[1]
14 value = tmp[0]
15 commands[key] = value unless key.nil? or value.nil?
16 end
17
18 base_url = "http://chart.apis.google.com/chart?cht=p3&chd=t:"
19 names = commands.keys * "|"
20 freqs = commands.values * ","
21 chart_size = "&chs=250x100&chl="
22
23 url = base_url
24 url << freqs + chart_size + names
25
26 puts url

วันพุธ, กุมภาพันธ์ 06, 2551


วันอังคาร, กุมภาพันธ์ 05, 2551

test syntax highlighting:

class Hello
attr_reader :name
def initialize(name)
@name = name
end

def good?
true
end
end

hello = Hello.new("Jack")
hello.name
hello.good?

วันพุธ, กันยายน 26, 2550



ไม่ได้มาเขียนอะไรในบล็อกนานแล้วแฮะ เหมือนจะตกข่าวหน่อยๆ เผลอแว้บเดียว GNOME ก็ครบรอบ 10 ปีแล้ว แรกๆใช้ GNOME ด้วยเหตุผลเดียวคือเพราะมันดู "clean" ดี แต่อะไรๆใน GNOME ตอนนี้ก็ดีขึ้นมากกว่าเดิม โดยเฉพาะสองสุดยอดโปรเจ็ค GStreamer และ Pango ตอนนี้แข็งขึ้นมาก ทำให้ Ubuntu และ Firefox ดังระเบิดเถิดเทิง

วันอังคาร, กรกฎาคม 03, 2550

how cells decide what to be when they grow up.

วันพฤหัสบดี, มิถุนายน 07, 2550

ลองทำขำๆ
You are C++. You are very popular and open to suggestions.Many have tried to be like you, but haven't been successful
C++ ซะงั้น

You are OS2-Warp. You're plagued by feelings of abandonment and disgust for your backstabbing step-brother.  Oh, what might have been.
OS ยิ่งไปกันใหญ่ T_T OS2 อืมมนะ..

สงสัยจะเกิดผิดยุค - -'

วันอังคาร, พฤษภาคม 22, 2550

วันศุกร์, พฤษภาคม 18, 2550

The community is vastly more innovative and powerful than a single company.

Open standards and open source software are literally changing the face of the planet - creating opportunity wherever the network can reach.

--Jonathan Schwartz

วันอาทิตย์, พฤษภาคม 06, 2550

the website of the world's first-ever web server
http://info.cern.ch/

วันศุกร์, พฤษภาคม 04, 2550

วันศุกร์, เมษายน 27, 2550

The Japanese Fishing Story

“Man thrives, oddly enough,
only in the presence of a challenging environment."
- L. Ron Hubbard
“มนุษย์เราจะใฝ่หาความสำเร็จในสภาพแวดล้อมที่ท้าทายเท่านั้น”

วันพฤหัสบดี, เมษายน 19, 2550

Why?
because we end up with what has been described as "irreconcilable differences"