發表文章

網頁快照 CutyCapt

前陣子一時興起,用php寫了一個快照的站台(網頁抓成影像檔 ) 但是因為server掛了,所以停了一段時間....還好今天終於想起來了,我用的 程式是  CutyCapt http://cutycapt.sourceforge.net/ 他是用 QT開發的程式可以讓你在命令列下直接上網抓整個頁面快照 也就是說只要有 Linux + QT 就可以工作了 安裝請參考:官網的他應該試用 debian 測試的 % sudo apt-get install subversion libqt4-webkit libqt4-dev g++ % svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt % cd cutycapt/CutyCapt % qmake % make % ./CutyCapt --url=http://www.example.org --out=example.png Using CutyCapt without X server 如果你只是用純文字介面的話,需要透過 xvfb-run 程式,執行畫面抓取的程式          % sudo apt-get install xvfb-run  (安裝)          % xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=... --out=... (執行) 如果要 Windows 版的請到這裡抓,CutyCapt也有提供, http://sourceforge.net/projects/cutycapt/ 但如果遇到 IE only 的網站就只好用這一套了 http://code.google.com/p/minemine/wiki/WebPageGrabber 程式碼待續....

氣象報告 ?? API ??

這實在太銷魂了,難怪現在一堆程式開發者越來越有創意....一堆現成的應用讓你用 剛剛本來在查詢看 clock 用 jquery 如何製作 http://jquery.jclock.js.googlepages.com/jclock.html 找到這篇 但有順便看到一篇 http://mypaaji.com/index.php/2009/07/06/jquery-weather-widget/ jquery 抓天氣資訊來顯示的效果 通常在國內我都直接抓氣象局的 RSS ,台灣的氣象水準可說是一流的 預報及精準度也值得推薦. 後來看了一下 source code 發現 試用 google 的 ig api 勒!! http://www.google.com/ig/api?weather=taipei 直接就可以用了 然後 jquery 再把他包裝一下,就變成這樣 http://mypaaji.com/tut/weather/ 看起來 yahoo 也有提供,但沒那麼多時間玩啦! http://developer.yahoo.com/weather/ 先忙其他的,晚點再來玩更多....

DDOS攻擊-use apache command ab

* ab 為 apache 用來做apache效能測試的一個指令 $ ab --help Usage: ab [options] [http[s]://]hostname[:port]/path Options are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make -t timelimit Seconds to max. wait for responses -p postfile File containing data to POST -T content-type Content-type header for POSTing -v verbosity How much troubleshooting info to print -w Print out results in HTML tables -i Use HEAD instead of GET -x attributes String to insert as table attributes -y attributes String to insert as tr attributes -z attributes String to insert as td or th attributes -C attribute Add cookie, eg. 'Apache=1234. (repeatable) -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' Inserted after all normal header lines. (repeatable) -A attribute Add Basic WWW Authentication, the attributes are a colon separated username and password. -P attribute Add Bas...

mysql 資料庫自動備份shell script與還原

* 自動備份資料庫 shell script #/bin/bash # backup databas to ftp site # you need wput and mysql client/admin tools # use yum or apt-get or get manually # wput http://wput.sourceforge.net/ # write by mtchang.tw@gmail.com # your ftp address and folder address ftp_addr='240.112.69.29/sql' # ftp account and password account='cccccc' acc_pw='cc' # to backup mysql dbase ,account and password db='mtchang' dbuser='mtchang' dbpassword='cccccccccc' # get year,month,day,hour da=$(date +%Y%m%d%H%k%M) h=$(hostname) # generate filename like linue.jangmt.com_200910101010_mtchang.sql filename="$h"_"$da"_"$db".sql # use mysqldump dump $db data to sql file echo "mysqldump $db -u$dbuser -p$dbpassword --opt > $filename" | sh # use bzip2 compress sql file echo "bzip2 $filename" | sh # upload file to ftp server echo "wput ftp://$account:$acc_pw@$ftp_addr/$filename.bz2" |sh ...

卡馬代練計畫

圖片
卡馬代練計畫 這個梗真的不錯,看起來像是 M$7的舔秘點..... http://funp.com/t762093 但是我好像以前就幹過這檔事是了,因為有人發出了需求... 當個專業的 MIS 就是要滿足需求 於是就在網路上找了 卡馬機器人 , 的 lib http://code.google.com/p/rlplurkapi/ 請下載,裡面有 php 及 python 的程式 http://code.google.com/p/rlplurkapi/downloads/list 解開發會發現有個 example.php 但是不太會用,算以亂改一通.... 基本上就改成大概這樣,分成 1.定時 post 氣象預報(氣象局即時 rss) 2.及定時 post 正妹圖(flickr的rss) #!/usr/bin/php <?php // plurk 帳號資訊 $nick_name = 'mtchang.xx@xxxx.com'; $password = 'xxxxxxxx'; require 'RLPlurkAPI.php'; $plurk = new RLPlurkAPI(); $plurk->login($nick_name, $password); // ------------------------------------- function getCWB($string){ if($string=='kaohsiung') { // 高雄氣象報告 $file_xml="cwbdata_36_02.xml"; $xml = simplexml_load_file($file_xml, 'SimpleXMLElement',LIBXML_NOCDATA); // 由氣象局的 RSS 顯示天器相關資訊 ...

Msnlib 及 msn text 介面

簡介 * 這是一個Python的程式主要是為 MSN Messenger 8的通訊協定 。 * 這個其實是一個函示庫(msnlib) ,which uses a non-blocking callback scheme. 包含在這個函示庫中有一支文字模式的客戶端程式 msn ,其中類似於 mirc 的介面。 安裝 * 請參考 http://blitiri.com.ar/p/msnlib/ wget http://blitiri.com.ar/p/msnlib/files/3.6/msnlib-3.6.tar.gz * 切換成 root 權限解開套件,並執行 install 安裝 [root@mt msnlib-3.6]# ./install * 先設定你的 msn帳號,他會問你的帳號及密碼並將他存放在下列兩個地方 Creating the directory hierachy (/home/mtchang/.msn) Creating the configuration file (/home/mtchang/.msn/msnrc) * 執行 msn setup msnsetup * 啟動 msn [mtchang@mt msnlib-3.6]$ msn * MSN Client (3.6) * Loading config... done Logging in... done Sending user list request... done Status set to online 07:41:18PM *9milHIKIKOMORI is idle 07:41:18PM 天威 is busy 07:41:18PM *help<蟲*red+u is away 07:41:18PM *sierra ♬ Ebom 。 坐看雲起時。 ♡〞 .....略 使用 * 提示符號為 [msn] * ? 可以顯示目前的指令說明 [msn] ? Command list: status [mode] Shows the current status, or changes it to "mode", which can be one o...

PHP與PERL的比較

作者 Robert Kline 將 perl 與 php 兩各的比較,及相關的函式用法 做了一個很棒的列表!! 讓不會 perl 的我,也可以很快的就進入狀況. (當然,前提是你要會php...) http://www.antigreen.org/vadim/ProgLanguageComparison/perl2php.html 另外有個網站寫了個 perl 轉換到 php 的轉換器,看來也很好玩...XD,至於轉換完後能不能跑,你可以試試看.. http://www.sixbynine.net/perl2php/translate.php * 這裡有差異比較 http://tnx.nl/php.html perl 及 php 的比較 * code 在 blogger 內貼上,用 http://formatmysourcecode.blogspot.com/ 這個轉換.