利用兩張網卡讓ubuntu做簡易router
知道A,B,D點
A:10.200.14.94  (學校WAN IP)
D:10.200.14.89

igogo 發表在 痞客邦 留言(0) 人氣()

backup config files by tftp




#!/usr/bin/expect -f
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




igogo 發表在 痞客邦 留言(0) 人氣()

wscript 中inputbox 並不能隱藏密碼,必須使用ScriptPW,但是 windows home edition版本並沒有相關的dll檔。除了copy scriptpw.dll 再執行註冊的方法外。參考
另一簡單方法就是跑html+vbscript or javascript

igogo 發表在 痞客邦 留言(0) 人氣()

cron stops in the middle of the script
http://www.linuxquestions.org/questions/linux-newbie-8/cron-stops-in-the-middle-of-the-script-325487/
 

igogo 發表在 痞客邦 留言(0) 人氣()

與指令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











igogo 發表在 痞客邦 留言(0) 人氣()





以輸入參數的方式帶入


Set args = WScript.Arguments
WScript.Echo (args.Item(0) & args.Item(1)) 


 檢查是否有輸入參數


if WScript.Arguments.Count = 0 then 
    WScript.Echo "Missing parameters" 
end if 






igogo 發表在 痞客邦 留言(0) 人氣()

get mms file -> mp3






#!/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





igogo 發表在 痞客邦 留言(0) 人氣()

DSC_0568

 



igogo 發表在 痞客邦 留言(0) 人氣()

這個問題實在很有趣,以前很少把自己的硬盤塞到滿過
想不到現在為了我的數據,竟然可以塞到20G,只好向另一顆500G求救 Orz
原來ftpd在使用chroot後,就不允許symbolic links
詳解

igogo 發表在 痞客邦 留言(0) 人氣()

 
我真是手賤,
在這時刻還隨便按了個emerge --udate ruby,
結果真是靠北了....gem19就不能用,

igogo 發表在 痞客邦 留言(0) 人氣()

  • May 30 Sun 2010 11:02
  • 收涎


四個月大,收涎

 

igogo 發表在 痞客邦 留言(0) 人氣()

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







igogo 發表在 痞客邦 留言(0) 人氣()

Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。