2011年4月2日 星期六

android 使用proxy連接至網路

http://forum.xda-developers.com/showthread.php?t=766569
http://darkk.net.ru/redsocks/


in nexus one(cyanogenmod 7):
  eth0/wl0.1
    wifi/softap(BCM4329)
  lo
    loopback
  rmnet0
    3G

in rooted and installed superuser phone, if run "su root", the superuser program will ask user to confirm root access via UI.

transproxy.apk
  This program use redsock internal
     This tool allows you to redirect any TCP connection to SOCKS or HTTPS proxy using your firewall, so redirection is system-wide.

  after install this program, some file will be placed in data/data/com.hasbox.tproxy/, I found there are some scripts in "files" directory
    enable transproxy
      sh data/data/com.hasbox.tproxy/files/proxy.sh start /data/data/com.hasbox.tproxy/files type=http host= port= auth=false user= pass=
      sh data/data/com.hasbox.tproxy/files/redirect.sh start http
    disable transproxy
      sh data/data/com.hasbox.tproxy/files/proxy.sh stop /data/data/com.hasbox.tproxy/files
      sh data/data/com.hasbox.tproxy/files/redirect.sh stop

  when execution /data/data/com.hasbox.tproxy/files/redirect.sh,because android bionic libc not implement getprotobyname(), so there some warning messabe
    in my environment, 3G need use proxy but wifi can direct access , so modify redirect.sh, add " -o rmnet0" in each rule, only 3G access use proxy

  bugs
    android's netd will reset ipatbles when disable tethering(ether wifi or usb), so the setting by transproxy will gone.
      must set transproxy.apk after disable tethering
 

2011年3月29日 星期二

使用批次檔修改proxy與ip

http://www.robvanderwoude.com/regedit.php

登錄編輯程式: regedit

想要做一個修改某機碼的.reg檔案
可以先開啟登錄編輯程式找到要改的資料夾,匯出後再修改匯出的內容會比較快


============================
判斷目前proxy是否有開啟並反向設定



@ECHO OFF

FOR /F %%A IN ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable ^| grep ProxyEnable ^| awk "{print $3}"' ) DO IF "%%A"=="0x1" (call:on) ELSE (call:off)
GOTO:EOF

:on
ECHO =================
ECHO proxy狀態: 開啟
ECHO 關閉proxy中...
regedit /s proxy_off.reg
ECHO 完成
ECHO =================
pause
GOTO:EOF

:off
ECHO =================
ECHO proxy狀態: 關閉
ECHO 開啟proxy中...
regedit /s proxy_on.reg
ECHO 完成
ECHO =================
pause
GOTO:EOF

2011年3月2日 星期三

避免編譯時產生錯誤 - error: void value not ignored as it ought to be

假設...
int aaa(){
...
}

void bbb(){
...
}



若遇到下面這種寫法
ret=flag? aaa(): bbb();
編譯時會發生錯誤:
error: void value not ignored as it ought to be

因為此時若flag為0,則ret=bbb();
但是bbb()沒有回傳東西(void),
此時可以使用下面這種寫法:
ret=flag? aaa(): (bbb(),NULL);

其中(bbb(),NULL)永遠回傳0(NULL)

http://en.wikipedia.org/wiki/Comma_operator

2011年2月25日 星期五

script內判斷cpu數量

CPUs=$(echo `cat /proc/cpuinfo | grep processor | tail -1 | awk'{print $3}'` +1 | bc)

2011年2月23日 星期三

TCXO

TCXO (Temperature Compensate X'tal (crystal) Oscillator)
具有溫度補償的石英震盪器, 提供高精準度的頻率輸出(因為通常震盪頻率會因為溫度而改變)
http://baike.baidu.com/view/1010371.htm

2011年2月15日 星期二

windows: 不允許使用多於一個使用者名稱的相同使用者有多個連線到一個伺服器或共用資源

架了一台samba server
不過在windows上面要登入時卻出現這個訊息
"不允許使用多於一個使用者名稱的相同使用者有多個連線到一個伺服器或共用資源"

可以使用net use指令看是否有連線存在
再使用net use \\XXX.XXX.XXX.XXX\YYY /del 刪除此連線


參考
http://freetoad.pixnet.net/blog/post/23509679

2011年2月14日 星期一

製作win7 usb 安裝隨身碟

在eeepc 901上面,
使用微軟的工具製作的隨身碟無法開機(http://store.microsoft.com/help/iso-tool)

後來發現使用HPUSBFW就可以使用

參考
http://www.umpcfever.com/viewthread.php?tid=4409

1.使用HPUSBFW格式化隨身碟, 並建立開機磁區
2.掛載win7 iso
3.複製cdrom內容至隨身碟
4.把Windows 7 開機檔灌入USB當中(ex:H:\boot\bootsect /nt60 F: )