2013年12月9日 星期一

[HowTo] Mac add a static route

1.在Linux 上
 route add -net 172.16.0.0/16 gw 10.201.174.249
2.在Mac 上
@新增static route
 route -n add -net 172.16.0.0/16 10.201.174.249
@查看static route
 netstat -nr
@刪除static route 
 route -n delete -net 172.16.0.0/16 10.201.174.253

2013年11月26日 星期二

好用的滲透測試軟體 OWASP zaproxy

OWASP zaproxy 是一套好用的proxy軟體,甚至軟體本身也支援ssl 封包的加解密,技巧上當然不是什麼神祕技術,主要就是使用man in middle,所以如果你有需求要觀察https 的封包,就可以透過此套軟體,然後到設定頁面dynamic SSL certificate去產生一個憑證,然後把這個憑證安裝在你要觀察的那一台電腦上面,這樣就可以騙過browser 的sercurity check,簡單的步驟如下

1.  產生 Root CA certificate

1.NewImage

2.加憑證安裝到要觀察的client 端上面:

加憑證內容文字拷貝到一個文字檔,更改附檔名為.cer,然後直接點選,就會跳出安裝憑證選項,安裝玩後,就可以使用https proxy

NewImage

--

---BEGIN CERTIFICATE-----

MIID7DCCAtSgAwIBAgIEfaNZWzANBgkqhkiG9w0BAQUFADCBhDEnMCUGA1UEAwweT1dBU1AgWmVkIEF0dGFjayBQcm94eSBSb290IENBMRgwFgYDVQQHDA9hODliMTIxNWM5NDI4MmIxFjAUBgNVBAoMDU9XQVNQIFJvb3QgQ0ExGjAYBgNVBAsMEU9XQVNQIFpBUCBSb290IENBMQswCQYDVQQGEwJ4eDAeFw0xMzExMjYwNjIzMjRaFw0xNDExMjYwNjIzMjRaMIGEMScwJQYDVQQDDB5PV0FTUCBaZWQgQXR0YWNrIFByb3h5IFJvb3QgQ0ExGDAWBgNVBAcMD2E4OWIxMjE1Yzk0MjgyYjEWMBQGA1UECgwNT1dBU1AgUm9vdCBDQTEaMBgGA1UECwwRT1dBU1AgWkFQIFJvb3QgQ0ExCzAJBgNVBAYTAnh4MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt2vbj6Ze+IRS53SyGE3ofxkXbsAFeZwUbHK9lHg3JhkqEM2cEzn8g0RMTKYRCR3GckN3fXsn9MjFlvUVomtyHIaTQguRCWhyVI2eKnHfyNox3M1KSl7btbyGE72zri0zXgLg4z1bJQh9oqkaO9n9BoNyyeHi2PuVrNC3C5CAoAqOvINoEc5WiasBD+sPbFGjeNHn169GAmA4OfSaAAZVr9MzD1cX5FCJtirUBjCq5Trqe060Bonyf1VVUv2w0NW87M6G2VanqYnq71CXaVfN2k8En/BXC+Clv4VuP+v4+QVWdgQIwssDoxtjQS+Pk3qLQaL6B7qIQkLgaanOgFpBBQIDAQABo2QwYjAdBgNVHQ4EFgQULJd+TVzhXivuoQcWC4jw3Z/D3ygwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAbYwIwYDVR0lBBwwGgYIKwYBBQUHAwEGCCsGAQUFBwMCBgRVHSUAMA0GCSqGSIb3DQEBBQUAA4IBAQAdfK5RBrShdKcmIVqOB4iXVAG1YgknTcAQrVRmKl5sclrYNd1AFo6onbNx/Ef3ufooxidwu76ZJOyaFjTSIo/X1NJtDlhfdSyVIcE5FxStS37IMZkNTAhjWAUFesS4tYrLYUzM6JBxYtpg+k+oVW/4jcpVwfwBGpjZ4jQB1F6FrhisOJVl15F2gtcCpC0tBqH3s8T1G65jjPeGjCgBOYv0yuk363ocoinY6BVDN+0PI6b20MIJXw5RvKdDnHzr6c5vHLXfOAb5UoJhtm0PrFK1pD7dBsAuXjdybVMFiVklx81RSYTyaxQUxLuhw0HbUElU9LUwvAMaUePdzFZ9Tt/A-----END CERTIFICATE-----

 

2013年11月25日 星期一

How to disable windows strong password enhancement

問題:

Microsoft 為了加強security,所以預設會開啟強制使用者使用比較複雜的密碼規則,雖然說這是對的,但有時候我單純只是想要測試軟體,不需要這樣複雜的密碼強度,因此會了把它關閉,讓使用者可以隨意設定容易記憶的密碼,你需要的就是去找到並修改Password Policy

 

HowTo:

在網路上看到兩個方法

方法一:

很簡單就是找到你的管理者工具(administrative tool),找到Local Security Policy -> Account Policies—> Password Policy

然後修改Password must meet complexity requirement to “Disable” 即可,不過我的經驗是在我的2012 Essentials 卻只能看到設定,但卻無法修改,所幸還有第二個方法可以修改

 

方法二:

1.叫出group policy console

# “gpmc.msc”

2.@Group Policy Management -> Forest: YourServerName.local -> Domains -> YourServerName.local
Select “Default Domain Policy” then right-click and select “Edit…” to open the Group Policy Management Editor.

3. @Group Policy Management Editor
Computer Configuration -> Windows Settings -> Security Settings -> Account Policies -> Password Policy

2013年11月23日 星期六

How to enable muliple RDP logon

因為工作需要,同時間用同一個帳號遠端登入同一台機器,發現只要登入,另一台登入的機器都會被踢出去,看了一下,原來是安全性上的設定,將他取消即可,詳情請參考下列的文章

http://www.petenetlive.com/KB/Article/0000471.htm

2013年11月22日 星期五

How to know the correct encode

 
#!/usr/bin/python
# -*- coding: utf-8 -*-
str_encodings='utf_8 utf_16 iso2022_jp_1 iso2022_jp_2 iso2022_jp_ext gbk gb18030 big5 big5hkscs euc_jp euc_jis_2004 euc_jisx0213 cp950 ascii latin_1 iso8859_2 iso8859_3 iso8859_4 iso8859_5 iso8859_6 iso8859_7 iso8859_8 iso8859_9 iso8859_10 iso8859_13 iso8859_14 iso8859_15 iso2022_jp iso2022_jp_2004 iso2022_jp_3 iso2022_kr gb2312 euc_kr hz johab koi8_r koi8_u mac_cyrillic mac_greek mac_iceland mac_latin2 mac_roman mac_turkish ptcp154 shift_jis shift_jis_2004 shift_jisx0213 cp037 cp424 cp437 cp500 cp737 cp775 cp850 cp852 cp855 cp856 cp857 cp860 cp861 cp862 cp863 cp864 cp865 cp866 cp869 cp874 cp875 cp932 cp949 cp1006 cp1026 cp1140 cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258'
encodings = str_encodings.split(" ")
for code in encodings:
name=row[0].decode(code,’ignore’)
print code,"===",repr(name)

[MAC] Mac OS 升級後,遇到 MySQL_python import error

這問題,幾乎我只要升級MacOS就會遇到一次

 

Error Message

Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.9-intel.egg/_mysql.so

Reason: image not found

 

Troubleshooting steps:

1.找出你安裝的Mysql_python 版本

pip freeze local|grep MySQL

2.

find out what library paths the MySQLdb C extension _mysql.so is looking for

otool -L /Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.9-intel.egg/_mysql.so

 

2. Install  or   Just copy missing libmysqlclient.xx.dylib to the lib folder

 otool -DX /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib

2013年11月20日 星期三

Can't join AD server : "DNS 名稱不存在。"( Error code 0x0000232B RCODE_NAME_ERROR)

原因:無法找到對應的兩筆DNS record,

 

解決方法:

最簡單的解決方法就是開啟 錯誤訊息中的Detail,找著裡面的說明加上這兩筆record

1._ldap._tcp.dc._msdcs.[yourdomain.com]

2. [yourpcname].[yourdomain.com]

2013年11月15日 星期五

How to dump freetds log (use tsql) and use unixodbc to access MSSQL 2008 on Mac Maverick

1.How to enable freetds dump
 $TDSDUMP=/tmp/freetds.log tsql -H mysql_sqlserver -p 1433 -U sa
2.這一版的unixodbc可能有問題,在網路上看到有人提到,一定等手動把odbcinist.ini存放在/etc下面才有作用,
所以我用了sybolic link去幾絕這個問題,也成功的建立連線
 $create sybolic to /etc from /usr/local/etc/odbcinst.ini
3.sample code
##/usr/bin/python
import sqlalchemy as sa import urllib URI='DRIVER={FreeTDS};Server=%s;Database=db_ControlManager;UID=%s;PWD=%s;TDS_Version=8.0;Port=1433;' % (server,user,password) connection_string='mssql+pyodbc:///?odbc_connect='+urllib.quote_plus(URI) engine = sa.create_engine(connection_string) conn=engine.connect() conn=db_connect() sql="select * from tb_userinfo" result=conn.execute(sql).fetchall() for row in result: for col in row: print col

2013年11月13日 星期三

What is Restful API

REST stands for Representational State Transfer. It relies on a stateless, client-server, cacheable communication protocol

stateless:  無狀態,(相反詞為stateful),亦即每一個連線都是獨立的,不會記住前一個連線狀態,用一個簡單的方式去取代

原本複雜的network application

 

RESTFUL application 使用HTTP request 去取代所有的 CRUD (Create/Read/Update/Delete) operations

2013年11月12日 星期二

[Mac] 利用Maverick tag [標記] 做軟體分類

轉到Mac 已經快滿兩年,這中間的使用經驗大體上來說都是好的,除了一點,我始終找不到好的方法做軟體分類,當電腦軟體中充滿滿慢的軟體,雖說可以透過spotlight來尋找,但事實上我現在記憶力已經大幅衰退,常常連要用什麼關鍵字搜尋都記不起來,還好現在Maverick有了檔案標記這個功能,我可以幫我常用的類似軟體,標上一個我記得的tag這樣大大的方便我搜尋使用

如何叫出 iOS 7.0 spotlight

在每一個頁面的中間以下位置,手指往下滑,即可叫出spotlight ,如果再上面一半的頁面就會叫出通知訊息頁面

[Mac] locate command 使用

在Mac 中要啟用locate 指令時,要縣建立一個locate database

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

  也可以透過下列手動更新資料庫的方式建立

sudo /usr/libexec/locate.updatedb

2013年11月10日 星期日

python module check command "pip"

install pip

easy_install pip

 

Use pip check what you have

pip freeze | grep -i repoze.who=

Install specific version

pip install repoze.who==1.0.19

2013年11月9日 星期六

Use fabric to send icinga plug-in

Because I don’t have access permissions on production servers. It caused me to think how 
to use agnetless icinga  plugin to monitor server.  This is a cause of this concept.
First, I write a fabric command to a local function naming _icinga_cmd. It will retire a exit code after executing.
 
def  _icinga_cmd(cmd):
 with settings(hide('warnings','running', 'stderr'),warn_only=True):
  try:
   result=sudo(cmd)
   if result.return_code==0:
    print "OK -"
    sys.exit(0)
   elif result.return_cod==1:
    print "WARNING-"
    sys.exit(1)
   elif result.return_code==2:
    print "CRITICAL-"
    sys.exit(2)
   elif result.return_code==3:
    print "UNKNOW-"
    sys.exit(3)
   else:
    print "Waring - Can't get response"
    sys.exit(1)
   return result.return_code
  except:
#           print "Warning- Can't get response"
   sys.exit(0)
   return
def check_unix_memory():
   cmd='/home/pmp-check-unix-memory -d' _icinga_cmd(cmd)
   _icinga_cmd(cmd)

2013年11月7日 星期四

[Mac] 2011 MBP 升級Maverick (10.9)後休眠模式失效

至從升級到Marverick後,發現休眠模式似乎失效了,原本只是發現燈號怎麼是恆亮,本來以為是燈號有問題而已,

後來就寫個小程式,發現我闔上螢幕後,在啟動,其實程式一直在跑,只是螢幕關閉而已,查看了是什麼造成休眠失效,

雖然有兩個可疑的程式在跑,不過我把他們都關掉後,還是一樣,然後再Apple的討論區發現,這很可能是Marverick的bug

最後解決方法是重新設定hibernatemode 

pmset -a hibernatemode 0
1.BackgroudTask 1 :這個很可能是因為你enable Time Machine造成的,你會看到一個backupd-helper的process

   2.ApplepushServiceTask 1:  可能會看到 AppleBluethoothHIDKeyboard 之類的,但事實上通常不是真的藍芽造成的,而是起他的

程式造成的,以我的例子是logmein造成的

#pmset -g assertions

NewImage

時事評析:從大統橄欖油延伸到頂新味全之食品安全

從今年九月以來,從所謂的九月政爭到大統用假的橄欖油事件,到最近連大的食品公司,頂新都牽扯近來,台灣被搞的人心惶惶,幾個月前,從網路上看到一個笑話,寫說這一切都是馬英九的陰謀,因為為了早日讓台灣人習慣中國大陸的黑心食品,說來實在悲哀,看到一些高官出來喊人手不夠等等,無法檢驗等等,立法委員也出來喊要修法等等,其實我覺得都不是正解,因為如果今天是一家廠商這樣做,這樣加強檢驗還可行,但我強烈懷疑這是一個共犯結構,對於這種犯罪,或者說商人的黑心,我腦中只想到一句成語”殺雞敬猴”,這時候應該找一家大的廠商,然後一次重罰重逞,甚至讓一家公司倒閉也好,讓其他公司警惕,而不是弄到不做不行,但真的要做又可能下不了台,回顧過去歷史一個朝代的沒落幾乎都來至於兩件事情,一個是土地居住問題,另一個就是食物問題,土地改革幾乎都是中國歷代國家興起的的第一要項,當一個朝代到末代,幾乎財富都會過度集中在少數人手上,所以會造成起義改革,而叛亂則大多來至於食物問題,因為都是一群為了求溫飽而起義的人,通常沒太大權力目的,所以常常最後被平亂,相對於因為土地改革造成的起義都來至於權力的變更,說來一般人民實在很可憐

Fabirc (2): @Task and @roles

Decorators:

We can use decorators to use a specific environment.

-use @task to separate task from general functions.  

For example. It you use command fab list to  list all command in below fabfile.  It will only display 

the functions with @task decorators .

##fabfile.py
from fabric.api import *
@task
def cmd(cmd):
        run(cmd)

def cmd2(cmd):
        run(cmd)
@task
def cmd3(cmd):
        run(cmd)
-use @roles to specify a task only can ran on which roles
#fabfile.py
env.hosts=[“192.168.1.1”,”aal.yourdomain.com"]
env.roledefs={“web":[“aal.yourdomain.com"],”ap":[“1.1.1.1"]}

And you can use decorators to specify which tasks are ran on which roles.

@roles(“web")
def apache():
    sudo("apt-get update")
    sudo("apt-get install -y apache2")

 

How to mount a NFS folder on win xp

1. Install windows service for unix3.5

http://www.microsoft.com/en-us/download/confirmation.aspx?id=274

 

2.mount a NFS folder

*Launch dos prompt

#!mount  user@yourdomain:/your/share/folder   f: [driver letter for mount point]

How to scp a all directory, not only file

#! scp  -r  user@yourdomain.com:/your/folder   /remote/folder

How to resolve install python broken yum current version of Python, which is:

If you encounter the below message when executing “yum” on your linux system,

It is because you broke the system default python version. The simplest way 

is force indicated yum to use python 2.4 version.  Modify your yum (/usr/bin/yum)

to call python at first line

#!/usr/bin/python2.4

 

##Error

It's possible that the above module doesn't match the

current version of Python, which is:

 

 

2013年11月5日 星期二

Mysql Error: 1205 :Lock wait timeout exceeded; try restarting transaction

mysql > show engine innodb status\G;

mysql > show variables like 'innodb_lock_wait_timeout';

 

 

##enlarge innodb_lock_wait_timeout

mysql>set @@GLOBAL.innodb_lock_wait_timeout=500;

## Enable general log

mysql> show variables like 'general_log';

mysql>set @@GLOBAL.general_log=ON;

2013年11月3日 星期日

重置設定 解決Ipad 1 經常當機問題

最近iPad Air上市了,看者手邊經常當機的iPad 1 ,不經讓我想起難不成我也要對Apple折服嘛?難不能iPad 1 被Apple有計劃的放棄後,就沒救了嗎? 雖然也很想借者這樣的說法來說服自己更換新的iPAd,不過想當年也是發了我不少錢才買的iPad,到現在也沒用幾年,但經常性的當機,的確讓我使用他的頻率越來越少,稍微一搜尋了一下,大部分的討論都是說是因為iPad 1 記憶體太少,屬於先天不足,所以都是因為軟體太肥大的關係,但後來看到國外論壇有人說只要把iPad 1 重置救可以解決這樣的問題,我一般都把iPad 1拿來做行事曆管理以及一些書籍文章的閱讀,應該也不算太肥大的軟體,就想說不然來測試一下,發現還真的改善了,目前第一天使用還沒遇到當機,,不過請確定自己做完備份後再執行這個Reset All Settings,因為會將你的資料全部清空,你得靠者restore才能把資料回覆

 

NewImage

Weinberg tirangle problem

 

問題:

1.http://www.testing-challenges.org/Weinberg-Myers+Triangle+Problem

答案:

2.http://euler.tn.edu.tw/think17.htm

2013年11月2日 星期六

[Mac] 正確的MBP 電池使用方式

上個星期在偶然的狀況下看到一邊有關如何延長macbook電池壽命的文章,發現原來電池的續電量是可以挽救的,就照裡面寫的使用方式,

用了幾天,發現電池續電量真的有回升,在10/29電池續電量只剩下83%,今天已經回升到89%了,雖然不知道到底是真的有用還是沒有,

 

原始文章:http://appleuser.com/2013/08/22/how-to-extend-macbook-battery-life/

蓄電量掉落是可以挽救的,

  1. 只要你重新開始充,充到滿後讓他維持一、兩個小時再放
  2. 等電量差不多降到 95% 時再充到滿,再重複第一個步驟

NewImage

 

 

備註:為了不久的將來可能得更換MBP電池,順便把另一篇自行更換電池的文章,附在後面

http://blog.lyhdev.com/2013/02/macbook-pro-2000.html

[Mac] Mac 10.9 maverick hang (當機問題)

自從升級上Mac 10.9之後,發現系統經常當機,大概一天會死當一到兩次,狀況跟kernal panic不太一樣,當機時,會發現
滑鼠有時候還可以移動,按caps lock時燈號也會變換,但系統就是hang住了,只能強制按電源鍵重新開機,檢查系統的log 發現
是死在google chrome helper,後來在google 論壇上發現,這狀況不是特例,很多人遇到了,有人回覆只要安裝新的beta以上版本32.以上問題就解決了

##系統log
2013/11/2 下午8:14:51.209 imagent[350]: [Warning] 12 CoreFoundation 0x00007fff9905b8f1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 2013/11/2 下午8:14:51.209 imagent[350]: [Warning] 13 CoreFoundation 0x00007fff9904d129 __CFRunLoopDoSources0 + 441 2013/11/2 下午8:14:51.210 imagent[350]: [Warning] 14 CoreFoundation 0x00007fff9904c7ef __CFRunLoopRun + 831 2013/11/2 下午8:14:51.210 imagent[350]: [Warning] 15 CoreFoundation 0x00007fff9904c275 CFRunLoopRunSpecific + 309 2013/11/2 下午8:14:51.210 imagent[350]: [Warning] 16 Foundation 0x00007fff9283aa7c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 253 2013/11/2 下午8:14:51.210 imagent[350]: [Warning] 17 Foundation 0x00007fff9292370a -[NSRunLoop(NSRunLoop) run] + 74 2013/11/2 下午8:14:51.210 imagent[350]: [Warning] 18 imagent 0x0000000108f272a9 imagent + 33449 2013/11/2 下午8:14:51.210 imagent[350]: [Warning] 19 libdyld.dylib 0x00007fff907c85fd start + 1 2013/11/2 下午8:15:02.277 WindowServer[133]: disable_update_timeout: UI updates were forcibly disabled by application "Google Chrome" for over 1.00 seconds. Server has re-enabled them. 2013/11/2 下午8:15:10.989 WindowServer[133]: common_reenable_update: UI updates were finally reenabled by application "Google Chrome" after 18.73 seconds (server forcibly re-enabled them after 10.02 seconds) 

 

##Google 論壇討論串

http://productforums.google.com/forum/#!msg/chrome/VYoL6Xs-DUQ/9KXCtUB8C3QJ

 

 

##Google chrome dev build

http://www.chromium.org/getting-involved/dev-channel

知識分類與電腦資料夾的管理

今天在整理我多年儲存的資料時,發現資料夾已經又亂到幾乎無法管理的地步了,也影響到知識的學習,美國著名的教育學家John Dewey

曾說過,all knowledge is classification,所以做好分類就是知識,不過要如何做好知識分類就不是一門簡單的學問。

 

 

之前我的命名一般都是以數字開頭命名做一點簡單的排序,然後再中間,因為google desktop search 的出現,就改成需要時,直接搜索,現在隨者Mac Maverick 支援資料夾與檔案標記tag的功能,就讓我想是否可以趁機整理整理我的資料,事實上我的數字命名規格是參考GTD (get

things done)的作者 David Allen所提倡的AZ  alpha filing system (AZ資料夾整理數),目前是希望建立一個合用的AZ 命名資料夾

然後透過程式自動搜尋相關的tag達到自動分類資料的夾的方式,嚴格來講,透過實體檔案分類跟透過標籤事後在分類,兩種是不同的概念,不過我想如果可以結合兩個優點,且不會增加自己檔案管理的負擔,是可以嘗試看看的

 

 ##知識的分類l:

1.http://jlis.lis.ntu.edu.tw/article/o17-7.pdf

##AZ alpha filing system

參考網站:

1.http://www.casfaa.org/assets/documents/GettingThingsDone_filing.pdf

2..http://timeimprint.blogspot.tw/2009/03/1quizlet.html

3.http://blog.xuite.net/twhsi/Blog/64334069-%E7%B4%99%E5%BC%B5GTD%EF%BC%8C%E6%96%87%E4%BB%B6%E5%A4%A7%E4%BD%9C%E6%88%B0+%E8%AB%87%E8%AB%87David+Allen%E5%A6%82%E4%BD%95%E7%AE%A1%E7%90%86%E5%A5%BD%E6%96%87%E4%BB%B6

4.http://timeimprint.blogspot.tw/2009/09/az.html

##Mac Filder in 10.9

http://chris959.blogspot.tw/2013/06/osx-finder.html

2013年11月1日 星期五

[How to]如何解目錄下所有的rpm 檔案

 $find . -name "*.rpm" | xargs -t -I file sh -c "rpm2cpio file |cpio -idm"

 

xargs:

*-I :  replace argument,代表 -I 後面的string,在這邊是使用file 需要被變數取代

sh: 執行command

*-c 代表command 會從stirng輸入

rpm2cpio:會將指定的一個.rpm文件轉換為一個cpio文檔,輸出到標準輸出

cpio:
*-i 表示提取文件
* -v 表示顯示執行過程
* -d 表示根據數據包中原來的路徑建立目錄 

AlertGrid

web site:http://alert-grid.com

Alert grid is an instant notifications for events received from your systems.  I used it to enhance our system’s monitoring system.

I use Icinga as our monitoring system and build up an admin console to do some advance operations.

 

2013年10月31日 星期四

How to use tcpdump to sniffer http header

 

1.tcpdump -s 1024 -l -A dst www.cnn.com
2.

Type the following command at shell prompt:

# tcpdump -n -i eth0 -s 0 -w output.txt src or dst port 80

 

Where,

  • -n : Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.
  • -i eth0 : Specify interface to capture data.
  • -s 0 : Snarf snaplen[snapshot length] bytes of data from each packet rather than the default of 68. Setting to 0 means use the required length to catch whole packets.
  • -w output.txt : Save data to output.txt file
  • src or dst port 80 : Capture port 80.

@Result

11:04:31.674686 IP 10.1.246.215.61709 > 157.166.248.11.http: Flags [.], ack 1478957458, win 65535, length 0

.....C...(....E..(k.@.@.9/

.P/.2.X'..P...TU..

11:04:31.674907 IP 10.1.246.215.61709 > 157.166.248.11.http: Flags [P.], seq 0:369, ack 1, win 65535, length 369

.....C...(....E.....@.@...

.P/.2.X'..P...u\..GET / HTTP/1.1

Host: www.cnn.com

Connection: keep-alive

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36

Accept-Encoding: gzip,deflate,sdch

Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4

 

 

11:04:31.675385 IP 10.1.246.215.61710 > 157.166.248.11.http: Flags [.], ack 3228182788, win 65535, length 0

.....C...(....E..(2P@.@.q.

..........P..[?.j).P.......

11:04:32.087077 IP 10.1.246.215.61709 > 157.166.248.11.http: Flags [.], ack 426, win 65535, length 0

2013年10月30日 星期三

使用手邊的macbook pro直接連接Apple TV 進行文字輸入

需要的軟體:iKeyboard

由於Apple TV新的OS 已經支援藍芽鍵盤,所以就想說應該一樣可以透過ikeyboard這個軟體,去模擬連接Apple TV做設定,剛測試了一下,真的可行,這樣就不用為了Apple TV 多準備一個無線藍芽鍵盤了

Apple TV 6.0.2 無法收看預告片問題

 

由於在apple TV 新的OS 中,已經將DNS傳輸強制走https,所以需要相對應的憑證設定檔,所以為了要繼續使用,你需要有方法去安裝描述檔,

方法一:

   第一個方法是需要透過Apple configurator直接連接apple TV去安裝設定,或者也可以透過謝列的方法,比較簡單

方法二:

@Apple TV

     *設定--->一般--->在"將資料傳送給Apple"這格 遙控器按下Play/Pause鍵,就會出現新增描述檔設定

     *輸入" http://class9.ml/fix”

     *重新回到設定 網路 把DNS改回210.129.145.150 (6.0.2版本請更換成 182.16.230.98 )

 

如果沒有需要破解的話,可以嘗試把DNS改成seednet DNS

139.175.55.244

據說可以解決收看影片lag的問題

為什麼有的國家會是小國家立國,有的卻是大國家?

腦海中偶然浮現出的一個想法,為什麼有得時代或區域會小國家林立,有的卻是只存在大國家呢?初步的想法是

如果一個國家一開始成立是就是富裕國家,或者說很容易生存討生活,那麼這個國家應該成為小國家的機率比較大,

反之如果國家一開始窮困,那麼這區域的小國家會因為要求更好的生活,所以會攻打其他國家,所以最後可能就會

統一成為一個大國家,反之容易討生活的區域,除非出現那種大野心的霸主,不然應該都很容易安逸於現在的生活

而不會繼續併購成為一個大土地的國家

How to find a big files in linux

Reference:  http://www.cyberciti.biz/faq/find-large-files-linux/

上面的部落格有寫完整的使用介紹,這邊單純最為自己使用記錄

 

find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $9 “:” $8 ": " $5 }'

2013年10月26日 星期六

[Mac] Aperture 試用版

由於Apple這次10.9的更新,對於軟體認證,只有有安裝過測試版本的都可以免費升級,下列網路上找到之前可以使用的

Aperture試用版連結與資訊

http://pan.baidu.com/share/link?shareid=1230152010&uk=3204541662

Serial number:E-321-JAQ-387-KKC-187-GZN-111-NPT-1LB-5S7X

2013年10月25日 星期五

[Mac] 休眠檔案刪除問題

Mac的休眠模式有三種模式

* Suspend to RAM: 直接把休眠檔案寫入記憶體中,速度快,但是需要消耗電力,hibernatemode =0

* Suspend to Disk :直接把休眠檔案寫入硬碟,速度慢還不需要靠任何電力,hibernatemode=5

* Supend to RAM+DISK: 結合上述兩者的優缺點,hibernatemode=3

 

查詢指令如下:

$sudo pmset -g|grep hibernatemode

 

設定指令如下:

$sudo pmset -a hibernatemode 0
$sudo rm -rf /private/var/vm/sleepimage

為了避免系統在自己產生sleepimage,可以自己設定一個同樣的檔案名稱,然後更改檔案權限讓他變成不能變更
$ sudo pmset -a hibernatemode 0 
$ sudo rm -rf /private/var/vm/sleepimage 
$ sudo touch /private/var/vm/sleepimage 
$ chflags uchg /private/var/vm/sleepimage

##如果要看現在系統的休眠設定狀況,可以用下列指令,看是否有人停止休眠模式
$ pmset -g assertions

2013年10月22日 星期二

[Camlistore]: reference for backing up your data to camlistore

http://thomassileo.com/blog/2013/08/20/backing-up-your-tweets-to-camlistore-with-python-and-camlipy/

[Mac] Mac下看漫畫的神兵利器

1.Jcomicdownloader: 一個跨平台的java 小程式,可以幫你解析大部分漫畫網站的網址,並下載裡面的圖片,片,https://sites.google.com/site/jcomicdownloader/

 

2.http://www.geocities.jp/coo_ona/viewer_en.html  一個免費的圖片瀏覽器,專門用來看漫畫的,基本上之直接讀取圖片檔或壓縮檔,在設定裡面也可以指定當讀取到最後一頁時,是要在當前folder或直接改換到下一個目錄(或壓縮檔),基本上要注意如果你裡面兩個都有的話,他會兩個都開啟,所以你可能會誤以為設定沒有用

 

3.目前我是追蹤下列三部漫畫,每個星期從新執行一次,如果未下載過的新漫畫,會用比較顯眼的標示出

1).王者天下:http://comic.sfacg.com/HTML/WZTX/

2).近擊的巨人:http://comic.sfacg.com/HTML/JJDJR

3)黒子的籃球:http://comic.sfacg.com/HTML/HZDLQ

[Raspberry pi] camera

http://dreamcolor.net/2013/05/raspicam-documentation/

http://yehnan.blogspot.tw/2013/05/raspberry-pi.html

2013年10月18日 星期五

Windows 8.1 開放更新

這幾天看到新聞一直再寫windows 8.1已經開放更新,不過我按了好幾次更新後都沒發現新的更新,後來才發現原來要從

windows 市集,點進去就可以看到更新選項了

[How to] Found invalid password for user : 'root@localhost'; Igonring user

Today I encounter a Mysql accessing problem.  When I tried to access mysql database with local root server, it claims

the password is invalid, so it will igonor user.   After googling, I found it was caused by using 'plaintext password' for 

this user.  To resolve this problem, we can update with correct one.


1. Access Mysql, please use anyone method you can to access the mysql database;

  1)use the other valid mysql account 

  2)stop mysql and start it with skip grant table

   #/etc/init.d/mysql stop

   #mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

2.update user password;

 [mysql]>use mysql;

[mysql]> select  * from user;

[mysql]> update user set PASSWORD=PASSWORD('your password') where USER='root' and Host='xxxx';

[mysql]>FLUSH PRIVILEGES;

** get your hash password from mysql

----[mysql]> select password('your password')

** safe update mode

----[mysql]> SET SQL_SAFE_UPDATES=0;

How to do Debugging on Postfix

Fail to start mysql

2013年10月15日 星期二

MarsEdit with asciidoc post

<p>== ascii doc test</p> <p>test</p> <p> </p> <p>== subject</p> <p>sadfsate   </p> <p>* a</p> <p>* b</p> <p>*c</p>

How to Set Up an Easy to Use Online monitoring system

To meet my expectation, the monitoring system needs have the below components 

1.Alarms and reporting

2.Flexiable customized monitoring probes.

3.actioniable notification

* can define escalation flow to auto recovery system when incidents occurs

 

In reply to how to set up ad easy to use online monitoring system.

The import thing is to start with the basics.

1.Start with the Basics:

2.Become a regular part of your daily work.

2013年10月14日 星期一

2374(佳能)

2015/04/28 隔了快兩年,又遇到新台幣升值的問題了,在數位相機整體產業這麼差的狀態下,應該不用再對業績期待的吧,只是不知道對於佳能到底哪一種幣值對他影響比較大


近期台幣升值,對於佳能這種外銷公司應該不會是好消息,這家公司其實嚴格說起來算是牛皮公司,股價跟公司營收正相關不是那麼大,公司雖然說看起來還是有炒作股價的跡象,但勉強算正派,講出來的業績預設基本上不會相差太遠,目前屬於盤跌整理,整個數位相機產業屬於很慘的狀態,但佳能這家公司整個經營狀況算是好的,所以我覺得似乎是值的我投資的一家公司

2013年9月30日 星期一

asciidoc reference

*http://awb.sourceforge.net/index.html

* http://kaczanowscy.pl/tomek/category/topic/self-publishing

* http://asciidoctor.org/docs/asciidoc-writers-guide/

2013年9月17日 星期二

中國好聲音第二季賽季規則之我見

選手的表現需要得到所有的關注,包括觀眾與其他導師,但偏偏只有導師是唯一一個對你有決定身殺大權的人,對應到現實的工作環境中,要是你,你覺得該如何做,才能吸引到其他導師的眼光,有機會被挖角,或者單純得到導師的親睞,繼續留在現在的戰隊中呢?

A personal storage system for live: camlistore

Reference: http://camlistore.org/

一套值的你關注的系統,目標是達成儲存你的個人資料,卻不用擔心雲端儲存保存的問題,作者是很有名的大師,從2008年就開始關注在這一塊

2013年9月16日 星期一

focus on business needs, instead of wasting time on false alerts.

http://realopinsight.com/en/

dot :用指令畫圖(或在plan text畫圖)

線上畫圖工具:http://graphviz-dev.appspot.com

Reference:http://www.openfoundry.org/tw/foss-programs/8820-graphviz-

Reference:http://icodeit.org/2012/01/使用graphviz绘制流程图/

dot

渲染的圖具有明確方向性。

neato

渲染的圖缺乏方向性。

twopi

渲染的圖採用放射性佈局。

circo

渲染的圖採用環型佈局。

fdp

渲染的圖缺乏方向性。

sfdp

渲染大型的圖,圖片缺乏方向性。

2013年9月11日 星期三

巴菲特的理財投資訣竅一書讀後心得

*價值投資 ==>成長導向的價值投資,而非『撿煙屁股法』

--成功的投資者必續具備良好公司的判斷

-- 好公司盈餘最終會回到股東身上,可能是股價,也可能來至於股息,如果都沒有,也許就不算好公司

*如何管理階層的好壞

-1.眼光:審查前幾年的財報,特別注意管理者對未來策略的說法

-2執行力:將當時的規劃與今天的結果做比較,看有多大程度的實現

-3.應變能力:比對前幾年的策略與今天的策略,看有哪些改變

-4.相比對象:將你感興趣的公司業績與同行業的公司報告比較一樣

*安全邊際的重要性:margin of safety

--合理預期下的適當報酬率

--評估公司的的現在與未來

--複利累積與個人課稅

--應該建立自己的公式(簡單公式)而非屏感覺,這樣才科學

*股東權益報酬>稅率+通彭(需看懂財報)

*提高股東權益報酬率的五種方法

-1.提高資本週轉綠:base on 硬收帳款,存貨,固定資產

-2增加營業毛利

-3.設法節稅

-4.提高負債比例

-5便宜的舉債方式

*巴菲特熱衷於投資具有消費者寡占的公司原因在於,這些公司可以因為通貨膨脹的效果而獲利,其他公司一般會受害

*Net Tangible assets (靜有形資產)

*套力的 年度報酬=[CG-L(100%-C) ]/ YP

--收集消息->計算年度報酬 資金分配很重要,通常在空頭市場股票購併會比較多 

2013年9月4日 星期三

2013年8月26日 星期一

【限時免費】立即裝Mailbox 可獲Dropbox 1GB免費空間

Dropbox 又推出新的免費空間活動,只要iOS [iOS6.0以上限定]用戶安裝新的軟體"mailbox"就可以獲得

額外免費的1GB空間.如果還沒安裝dropbox的人,可以透過下列的連結去安裝dropbox

http://db.tt/u4rQph2 

NewImage

2013年8月23日 星期五

PARL法則

Problem:抱持的問題

Action:採取的行動

Rsult:行動的結果

Learning:從中的學習

2013年8月22日 星期四

zmodem download/upload files

#!apt-get install lrzsz

linux 手動對時

#!ntpdate -u time.stdtime.gov.tw

[ubuntu] 使用apt-get 遇到錯誤 "E: Unable to correct problems, you have held broken packages."

今天使用apt-get install puppet,結果遇到了錯誤訊息 "E: Unable to correct problems, you have held broken packages."

本來以為是package dependence的關係,後來才發現我真的想太多了,只要簡單的下一個clean即可

#!sudo apt-get clean | sudo apt-get update
 

[Ubuntu] apt-get 的source.list中有關main, restricted等的差別

在使用ubunut 更新或安裝檔案時,常看到後面會寫 main , restricted, universe等等,但一直不知道他的差別,一直到今天才在wiki中看到ubunut 的說明我才知道,原來是有關軟體授權的差異
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted
 自由軟體非自由軟體
官方支援MainRestricted
非官方支援UniverseMultiverse

2013年8月20日 星期二

[SSH] Permission denied (password)

今天透過puppet自動安裝server後,發現[SSH] Permission denied (password),但不確定如何處理,只好開啟sshd debug model

處理方式如下

1)stop ssh 

#!/usr/sbin/sshd stop
#!/usr/sbin/sshd -d  (debug model)

2)debug log

  /var/log/auth.log

Management thinking[管理思維] vs entrepreneurship thinking[創業思維]

管理思維:先有目標,在靠能力去達成

NewImage

創業思維:先有能力,在去思考下一步做什麼

 

NewImage

2013年8月19日 星期一

優秀的領導人

轉至:能力雜誌

 

1.適當的肯定員工

2.支持員工而不是取而代之

3.在制定決策時詢問員工的意見

4.聆聽員工說想說的話

5.花時間解釋作出決定的原因

6留意與維護員工的自尊

 

@領導三和弦

聆聽->定調->行動

領導者的定義

Peter F.Drucker:

-有效的領導者不一定要很聰明,而是要言行一致

-領導者唯一的定義就是:一個有追隨者的人

Joseph Boyett:

-成為真正的領導者之前不可或缺的一項經驗就是失敗

Warren Bennis

-經理人會把事情做對,而領導人則是做對的事情

 

Lee Iacocca:

你可以做兩個人的工作,但你沒辦法成為兩個人

2013年8月14日 星期三

如何透過iTune刪除手機上面的共享文件

剛剛透過iTuen上傳更新地圖檔案到導航王,後來發現格式錯誤,想把檔案刪除,確不知道該怎麼刪除,後來找了一下,才發現原來真的是自己想太多了,其實只要選取檔案後,直接按delete即可,實在是簡單到讓人哭笑不得

NewImage

apt priority 使用與說明

   Pin-Priority表示:
# * 1001及以上:可降级优先级。
# Pin-Priority处于该范围的软件包允许降级操作。
# * 100到1000:标准优先级。
# 不允许降级。几个key Pin-Priority的值:
# * 990:由`--target-release'或apt-get(8)`-t'选项设置的优先级。
# * 500:所有默认软件包文件的优先级。
# * 100:当前安装软件包文件的优先级。
# * 0到99:非自动优先级。(仅用于软件包没有安装或没有别的可用版本时。)
# * 小于0:决不选择该版本。
#-----------------------------
# 例如我要保持puppet 的3.02版本 只需加上:
# Package: puppet
# Pin: version 3.02*
# wildcard * 指锁定以3.02開頭的所有版本
# Priority(优先级)是可选项 默认 989
# <0 此软件永不会被安装
# 0~100 软件不被安装,不是有效的版本
# >100 此软件会被安装 即 如果有更新版本,软件会被升级
# 100~1000 软件不会被降级安装,例如:我安装的puppet 3.02 , 锁定puppet 0.58 ,优先级为999
# 那么3.02就不会被安装 ,如果要降级安装 则优先级许大于 1000,
例如系統已經自己安裝或升級到3.23,遇到這個repo server則會自動降級到3.02

2013年8月8日 星期四

[Ubunut] How to change keyboard layout

#!dpkg-reconfigure keyboard-configuration
 
#!dpkg-reconfigure console-setup.

王宗立 梁凱恩

看似兩個沒關係的人,卻原來也是有關係,對於王宗立,我沒印象,只是剛好看到今天的新聞,寫說他是台灣辣妹直銷詐騙的始祖,然後他最近轉換到科技業,又騙了好幾億,在百度百科,上面些他是一個亞洲成功學教父,至於梁凱恩則原至於去年在一個偶然的下午看到他投資的電影,下一個成功的奇蹟,寫的很聳動,但對於這個人我完全沒聽過,所以有稍微搜潯一下,知道他是從事直銷業,由於我對於直銷業一直沒太好的印象,所以就沒繼續關注,但今天不小心看到下列文章,才發現原來兩個人都是有關係的,原來梁凱恩曾經任職的公司,宣稱幫企業營業額衝到幾十億的公司,就是王宗立的詐騙公司,只能說人生啊,新聞阿! 真的看看就好了

連結:http://blog.udn.com/tuankochin/1064139

2013年8月6日 星期二

致孟楠(中國好聲音第二季第四期)

其實這篇是看到同事寫的部落格而產生的回應,一個有實力的女唱作者,也曾經寫出成功的歌曲,卻來到一個更大的舞台想要尋夢,不禁讓我想到

1)人才是需要舞台的,一個人曾經做過成功的產品,也有很好的實力,卻偏偏時運不振

2)人才是需要伯樂的,從四位講師中,阿妹沒有回頭,就看得出,因為不是創作者,所以他不知道演唱者的厲害之處,或者說也可以說他只專注在演唱者的歌唱實力,所以對於演唱者的創作實力沒注意到

2013年8月1日 星期四

Troubleshooting steps on puppet certificate

Check that both the puppetmaster and the client machine can resolve the FQDN of the puppetmaster. For this to work, you need to add the puppetmaster IP to your /etc/hosts in both machines, then check it using:

$ ping puppetmaster or $ getent hosts puppetmaster

Check that you can reach the puppetmaster from the client machine

$ telnet puppetmaster 8140

If you get connection refused by the server, check that the port is opened in the puppetmaster

# iptables -L -n -v

Or add a rule to allow incoming traffic to that port (this is dependent on how is iptables already configured)

# iptables -A INPUT -p tcp --dport 8140 -m state --state NEW -j ACCEPT

And run from the client

# puppet agent --test --waitforcert 5

Afterwards, from the puppetmaster

# puppet cert list

will show you the cert ready to be sign, you can check it belongs to the client machine comparing the fingerprint. Sign it:

# puppet cert sign $client

Puppetmaster will compile a catalog for the client and you can follow how it is applied in the client console.

To regenerate the certificates on the puppetmaster, stop the ppuppetmaster and

# find $(puppet master --configprint ssldir) -name "$(puppet master --configprint certname).pem" -delete

When you start the puppetmaster again, it will regenerate the certificate for you.

On the client side, it is enough to remove the conttents of the ssldir, usually /var/lib/puppet/ssl, but check as above, the next time you invoke

# puppet agent --test --waitforcert 5

it will be recreated.

Eventually, check the CN of the certificate of the puppetmaster with

# puppet cert list --all

and match any of the names/ALT names to the entry in your /etc/hosts.

WYSIWYG==> What You See Is What You Get 所見即所得

How to troubleshoot kernel panic in Mac Paralles

Reference :  http://kb.parallels.com/en/10007

 

問題的描述:

今天在嘗試使用puppetlab 提共的vm到parallels使用時,遇到的kernel panic問題,但卻不知道該如何下手,後來就從paralles上面的論壇找到有關kernal panic的debug 方法,然後再從有問題的debug log中找到原來是找不到lvm 的virtual group,然後繼續找就看到原來他是開機的時候嘗試找尋ide硬碟,但轉換後他卻直接使用scsi,所以造成找不到硬碟,才會顯示kernal panic

 

重點:

1.安裝虛擬的serial port,並把開機資料導出文字檔案中

2.修改開機指令,讓開機資料導出到虛擬的serial port中

NewImage

NewImage

 

Debug.txt

…serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450 00:0b: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450 brd: module loaded Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx ICH2: IDE controller at PCI slot 0000:00:1f.1 ICH2: chipset revision 5 ICH2: not 100% native mode: will probe irqs later ide0: BM-DMA at 0xe200-0xe207, BIOS settings: hda:DMA, hdb:DMA ide1: BM-DMA at 0xe208-0xe20f, BIOS settings: hdc:DMA, hdd:DMA Probing IDE interface ide0... hda: Virtual DVD-ROM [0], ATAPI CD/DVD-ROM drive ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 Probing IDE interface ide1... Probing IDE interface ide1... ide-floppy driver 0.99.newide

--------

Activating logical volumes Volume group "vg00" not found Trying to resume from /dev/vg00/swapvol Unable to access resume device (/dev/vg00/swapvol) Creating root device. Mounting root filesystem. mount: could not find filesystem '/dev/root' Setting up other filesystems. Setting up new root fs setuproot: moving /dev failed: No such file or directory no fstab.sys, mounting internal defaults setuproot: error mounting /proc: No such file or directory setuproot: error mounting /sys: No such file or directory Switching to new root and running init. unmounting old /dev unmounting old /proc unmounting old /sys switchroot: mount failed: No such file or directory Kernel panic - not syncing: Attempted to kill init!

How to let your raspberry pi simulate iOS airplay

First off, we need to install a few things before we can get Shairport. Type this into the console:

sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl

Let this process run for a little while. When it's complete, we need to install an update so Shairport will work with iOS 6 (you can skip this step if you're not on or plan to upgrade iOS 6):

git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
cd perl-net-sdp
perl Build.PL
sudo ./Build
sudo ./Build test
sudo ./Build install
cd ..

Once the iOS 6 module is installed (give it a little while), it's finally time to get Shairport installed. from your home directory type:

git clone https://github.com/hendrikw82/shairport.git
cd shairport
make

Now, let's run Shairport:

./shairport.pl -a AirPi

This command starts Shairport with your Raspberry Pi named "AirPi" (you can change it to whatever you want). Grab your iOS device, pick the music app of your choice, and tap the AirPlay button. You should see "AirPi" listed as an output device. Tap that, and the music should start streaming out of your USB sound card within a couple seconds.

But we're not done yet. Shairport doesn't automatically load when you start your Raspberry Pi, and since we want to make our AirPlay device work without any peripherals we need to do one more step. From your home directory, type:

cd shairport
make install
cp shairport.init.sample /etc/init.d/shairport
cd /etc/init.d
chmod a+x shairport
update-rc.d shairport defaults

Finally, we need to add Shairport as a launch item. Type:

sudo nano shairport

This loads up Shairport file we need to edit. Look through the file for the "DAEMON_ARGS" line, and change it so it looks like this:

DAEMON_ARGS="-w $PIDFILE -a AirPi"

[Mac] How to install pycurl on mac 10.8.4

今天想要透过easy_install 直接安裝pycurl,卻一直遇到問題
/opt/local/include/curl/curlrules.h:143:6: error: '__curl_rule_01__' declared as an array with a negative size
[CurlchkszEQ(long, CURL_SIZEOF_LONG)];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/curl/curlrules.h:132:27: note: expanded from macro 'CurlchkszEQ'
#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
^~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/curl/curlrules.h:153:6: error: '__curl_rule_02__' declared as an array with a negative size
[CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/curl/curlrules.h:132:27: note: expanded from macro 'CurlchkszEQ'
#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
 
 
後來上google搜尋,建議直接加上環境變數archflags -arch x86_64即可
sudo env ARCHFLAGS="-arch x86_64" easy_install setuptools pycurl==7.19.0

2013年7月31日 星期三

[Mac] How to mount a smb share folder through terminal with AD account

之前剛轉換到Mac下時,嘗試直接使用Mac 去mount windows 下的share folder不過都沒成功過,後來才發現
原來是因為使用ad account的關係,原本以為就是一般用法 domain/username即可,不過後來發現其實應該在
domain後面接一個;(semi-colon),詳細的用法其實可以直接man mount_smbfs 即會提到,難怪都沒成功過
 
#!mount -t smbfs "//domain;username:password@host/share" /smbaudit

 

ps:如果密碼有含特殊字元,例如 ‘@‘ 請將他換成 ‘%40’    (URL encode)

可以使用類似的線上url encode/decode tool 去轉換   :http://meyerweb.com/eric/tools/dencoder/

2013年7月25日 星期四

How to mount an Mac AFP share on Raspberry Pi

1.Download a apt client from  http://sourceforge.net/projects/afpfs-ng

2.

sudo apt-get install libfuse-dev libreadline-dev
./configure --enable-gcrypt=/usr/lib
make
sudo make install
sudo ldcondig

3.檢查是否安裝成功

#!afp_client status

3.

#!mount command
 mount_afp 'afp://[username]:[password]@[ip address]/My Book Thunderbolt Duo'  '/mnt/mac/'

4.#!umount command

afp_client umount /mnt/mac

2013年7月24日 星期三

nc(net cat) as port forwardingg

1.nc

nc -k -l 192.168.1.21 45630 | nc 10.168.2.4 45631 -x

 

2.netcat

#將local port 45630 轉到遠端的45631 

#!netcat -p 45630 -L 10.168.2.4:45631 -vv

[Raspberry] emit server

1.libminiupnpc-dev

[Raspberry] How to install air video server on raspberry pi

1.安裝java: 請裝jdk8方可以在raspberry上沒問題的跑起來

https://jdk8.java.net/download.html

使用update-alternative替換系統java路徑

#!update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.8.0/bin/java" 2
#!update-alternatives --set java /opt/java/jdk1.8.0/bin/java

2.安裝linux 版air video server

http://www.inmethod.com/forum/posts/list/5276.page

#在安裝mpeg4ip-server可能會遇到編譯上的問題,可以參照下列的文章,把問題逐步排除

http://jieyeh.blog.163.com/blog/static/8774559201322905932237/

列出所有user's crontab job

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done

[deb] apt-get force resolved dependency issues

apt-get build-dep build-essential

[Raspberry Pi] sdl-config not found

sudo apt-get install gcc build-essential libsdl1.2-dev

[Raspberry pi] Install AirVideo server on Raspberry

http://www.inmethod.com/forum/posts/list/1856.page

http://wiki.birth-online.de/know-how/hardware/apple-iphone/airvideo-server-linux

2013年7月23日 星期二

[mac] Use disk to burn/restore image to sd card

##1.先從Mac Terminal 下面找出SD card的磁碟機代號,如果如下為/dev/disk1s1就先將他umount
sudo diskutil unmount /dev/disk1s1
##2.整個sd card的磁碟機代號應該為/dev/disk1 ,如果想要進行raw disk 直接燒錄,則把磁碟機代號前面+'r'變成
## /dev/rdisk1 ,這邊推薦直接使用rdisk燒錄,根據我的經驗,速度大概差了一倍
sudo dd if=2012-08-08-wheezy-armel.img of=/dev/disk1s bs=2m
##clone a partition
dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=notrunc,noerror
 
##clone entile disk
dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror

2013年7月22日 星期一

registrant vs registrar 差別

今天下載了一個陳年的dns-check script,發現有一些網站他都沒辦法正確解析,看了一下,他裡面是透過捉取registrar這個字眼當關鍵字,我就觀察了一下他沒辦法parse的檔案,裡頭幾乎都是屬於hosting 的domain name,裡面都沒registrar這個字眼,只有registrant,想說找看看他們差異到底是什麼,原來registrant屬於end user,就是實際的註冊者,registrar算是辦事員,幫忙申請管理的人,詳細的差異可以參考下列的pdf檔案

 

http://ws.edu.isoc.org/workshops/2004/ccTLD-bkk/day2/registration.pdf

2013年7月18日 星期四

非常好用的API 搜尋與管理文件 Dash

Dash 屬於一種API 文件搜尋管理與個人資料庫管理軟體,使用上個人覺得有下列幾項優點

1.豐富的API文件庫:c,c++,python,perl....

2.可以跟很多種軟體結合在一起,例如xcode, sublime都有相對應的套件,方便搜尋API 文件或你自己的個人程式碼資料庫

3.好用的snippet: 主要用法如下,可以把自己常用的(常常copy & paste)的程式,寫成一個snippet,取一個自己記得而且不重複的名稱,

當你在其他的editor中,打字時,就可以直接呼叫dash的快速鍵,他就會開啟dash search幫你找出對應的snippet,這時候按下use 他就會

根據snippet中程式碼你所設定的一些變數,當你需要使用時,可以動態的產生一些相對應的資料好讓你copy,目前dash snippet主要支援

  a.placeholder :顧名思義,就是讓你方便定位用的,在snippet中使用__xxxx__這樣,等轉換程式碼時,你就可以直接使用table當定位符號,加速修改工作

 b.@date:可以自行產生當時的時間

 

 

How to debug a Javascript proxy.pac

1.http://www.jslint.com/

2.http://code.google.com/p/pacparser/

3.http://www.proxypacfiles.com/proxypac/index.php?option=com_content&view=article&id=61&Itemid=102

2013年7月17日 星期三

segfault at ntop 3.3

原因為ntop 3.3的known issue,要解決這個方法就是升級安裝到3.4

1.apt-add-repository ppa:sylvain-garcia
2.apt-get update
3.apt-get install ntop
4.apt-get install rrdtool

   5.如果需要更改監聽的網卡,請修改init.cfg

vim /var/lib/ntop/init.cfg 

   6.啟動ntop -A 設定管理者密碼

  7. ntop 預設會綁訂再http://127.0.0.1:3000 port 如果像要使用https的話,請使用

  8.ntop -w 4223  (listen at https://127.0.0.1:4223)

  9.如果有遇到全縣問題(xx permission deny),請檢查檔案的owner 與權限 (/var/lib/ntop/xxxx)

How to enable syntaxhighter support with MarsEdit on google blogger

1.修改google blogger 上面,增加下列的線上syntaxhighter 再 </head>前找個地方貼上

a.請先參考附件中你所需要的highlight的程式碼,加入到google blogger中  ,例如要bash的支援,就找到"shBrushBash.js"

http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/

<!--SYNTAX HIGHLIGHTER BEGINS--> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>

<script language='javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf&#39;; SyntaxHighlighter.all(); </script> <!--SYNTAX HIGHLIGHTER ENDS-->

 

2.MarsEdit

1.New post-

 =>Format ->Customize

按照語法,增加自定的format,例如增加下列為python code hightligh

2.NewImage

Hamichi+vnc+autodiscovery讓你的Mac隨時可以連結存取 Raspberry Pi

@Raspberry Pi

1.sudo apt-get install netatalk

2.sudo apt-get install avahi-daemon

3.sudo update-rc.d avahi-daemon defaults

4.sudo vi /etc/avahi/services/afpd.service

寫入下列檔案 <?xmlversion="1.0"standalone='no'?><!--*-nxml-*-->

<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <namereplace-wildcards="yes">%h</name>
   <service>
      <type>_afpovertcp._tcp</type>
      <port>548</port>
   </service>
</service-group>
 
 
5.sudo /etc/init.d/avahi-daemon restart
6.sudo apt-get install tightvncserver
7.vim /etc/init.d/tightvncserver
寫入下列檔案 (如果直接拷貝下列檔案,請注意"是否被系統轉換)
#!/bin/bash
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $remotefs $syslog
# Required-Stop: $remotefs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC server at boot time
# Description: Start VNC Server at boot time
### END INIT INFO
 
# The Username:Group that will run VNC
export USER=”pi”
#${RUNAS}
 
# The display that VNC will use
DISPLAY=”1″
 
# Color depth (between 8 and 32)
DEPTH=”16″
 
# The Desktop geometry to use.
#GEOMETRY=”x”
#GEOMETRY=”800×600″
#GEOMETRY=”1440×900″
#GEOMETRY=”1280×1024″
GEOMETRY=”1920×1080″
 
# The name that the VNC Desktop will have.
NAME=”my-vnc-server”
 
OPTIONS=”-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}”
 
. /lib/lsb/init-functions
 
case “$1″ in
start)
log_action_begin_msg “Starting vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver ${OPTIONS}”
;;
 
stop)
log_action_begin_msg “Stoping vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver -kill :${DISPLAY}”
;;
 
restart)
$0 stop
$0 start
;;
esac
 
exit 0
8.sudo chmod +x /etc/init.d/tightvncserver

9.sudo pkill Xtightvnc

10.sudo /etc/init.d/tightvncserver start

11.cd /etc/init.d

12.sudo update-rc.d tightvncserver defaults

13.sudo vim /etc/avahi/services/rfb.service
編寫下列內容 <?xmlversion="1.0"standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <namereplace-wildcards="yes">%h</name>
  <service>
    <type>_rfb._tcp</type>
    <port>5901</port>
  </service>
</service-group>
 
14.sudo /etc/init.d/avahi-daemon restart
 
#設定hamichi 個人vpn
從下列網址取的最新版的hamichi連結
**[2014/04/29 update] 最新版的hamachi 會遇到編譯上的問題 Illegal instraction
可以從下列的連結下載好心的網友提供的舊版 https://www.dropbox.com/s/b3qmefk60n7ng7v/logmein-hamachi-2.1.0.101-armel.tgz
 
https://secure.logmein.com/labs/#HamachiforLinux
15.wget https://secure.logmein.com/labs/logmein-hamachi_2.1.0.86-1_armel.deb
dpkg -i
logmein-hamachi_2.1.0.86-1_armel.deb
apt-get update
apt-get install --fix-missing lsb lsb-core
 
16.sudo hamachi login
17 sudo hamachi attach "your logmein.com email address
18.搞定
NewImage

How to restore a deleted onenote page

復原不小心誤刪的onenote