- Nov 23 Tue 2010 12:44
-
拿ubuntu當router(非NAT)
- Nov 09 Tue 2010 22:52
-
fortigate related articles
set timeout 60
spawn ssh admin@fgt-ipaddress
expect “password: $”
set send_slow {1 0.05}
send -s “password\r”
send_user “password\r”
send -s ” config global\n”
send -s “execute backup full-config tftp filename.txt tftp-ipaddress\n”
send -s “exit\n”
interact
- Oct 28 Thu 2010 21:19
-
javascript+wscript 掛載網路磁碟机
另一簡單方法就是跑html+vbscript or javascript
- Oct 12 Tue 2010 19:20
-
mplayer and cron
http://www.linuxquestions.org/questions/linux-newbie-8/cron-stops-in-the-middle-of-the-script-325487/
- Oct 07 Thu 2010 08:58
-
[ruby]paste
#!/usr/bin/ruby
files = Array.new
files = ["a.txt","b.txt","c.txt"]
tmp = Array.new
raw_data = Array.new
for i in 0..files.size-1
File.open(files[i]) do |txt|
while line=txt.gets
tmp << line.chomp
end
raw_data << tmp.join(',').split(',')
tmp.clear
end
end
raw_data.transpose
for i in 0..raw_data.transpose.size-1
puts raw_data.transpose[i].join("\t")
end
- Oct 06 Wed 2010 14:37
-
vbs 傳值進去
以輸入參數的方式帶入
Set args = WScript.Arguments
WScript.Echo (args.Item(0) & args.Item(1))
檢查是否有輸入參數
if WScript.Arguments.Count = 0 then
WScript.Echo "Missing parameters"
end if
- Sep 28 Tue 2010 16:47
-
[ruby] get mms file
#!/usr/bin/ruby -Kw
require 'fileutils'
#mms_stream = ARGV[0]
class Mms
def self.FetchMms(mms_stream)
wav_file=File.basename("#{mms_stream}").gsub(/.wma/,".wav")
#mms://url
#存成wav檔
system("/usr/bin/mplayer -ao pcm:file=#{wav_file} #{mms_stream}")
mp3_file=wav_file.gsub(/.wav/,".mp3")
#puts mp3_file
#將wav轉成mp3檔
system("/usr/bin/lame -b 42 #{wav_file} #{mp3_file}")
FileUtils.rm "#{wav_file}"
end
end
if ARGV[0].nil?
puts "usage: mms url or file"
else
Mms.FetchMms(ARGV[0])
end
- Jun 03 Thu 2010 00:41
-
pure-ftpd 與 symbolic links
想不到現在為了我的數據,竟然可以塞到20G,只好向另一顆500G求救 Orz
原來ftpd在使用chroot後,就不允許symbolic links
詳解
- Jun 02 Wed 2010 19:51
-
[ruby] gentoo上升級ruby19 及gem19
- May 28 Fri 2010 19:23
-
[ruby] with sqlite3
#!/usr/bin/ruby -Ku
# encoding: utf-8
require 'amalgalite'
require 'fileutils'
class String
@@tmp_db = "tmp_db.txt"
@@gsp_db = "gsp_corpus.db"
@@gsp_corpus = "gsp_corpus" #table name @@field_name = "word source"
def to_db #字串與資料庫查詢
FileUtils.rm(@@tmp_db) if File.exist?(@@tmp_db) # start with a clean slate
my_db=Amalgalite::Database.new(@@gsp_db)
stmt = my_db.execute("select * from gsp_corpus where word = ?", "#{self}")
my_db.close
if stmt.any?
File.open("./#{@@tmp_db}","a") do |txt|
txt.puts stmt.join(',')
end
res = File.open("./#{@@tmp_db}").read
return res
end
end #end to_db
def save_to_db
str = self.gsub(/,/,"\",\"").gsub(/^/,"\"").gsub(/$/,"\"")
my_db=Amalgalite::Database.new(@@gsp_db)
stmt = my_db.execute("select * from gsp_corpus where word = ?", "#{self.split(',')[0]}")
if !(stmt.any?)
insert_stmt = "insert into gsp_corpus (%s) values (%s)" % [@@field_name.split.join(','), str]
my_db.execute(insert_stmt)
puts "insert into sqlite3_db sucessfully"
end
my_db.close
end
end #end class

