2012年6月21日 星期四

LD_LIBRARY_PATH

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/yan/xxxx/lib/

2012年6月20日 星期三

vim open multiple file into tabs

open :
$ vi *.py

:tab all



exit :
:qa




Reference :
How to get vim to open multiple files into tabs at once - Super User

vim auto remove whitespace

~/.vimrc
"auto remove whitespace when open the file
autocmd FileType c,cpp,python,php autocmd BufWritePre :%s/\s\+$//e




Reference :
How can you automatically remove trailing whitespace in vim - Stack Overflow 
Remove unwanted spaces - Vim Tips Wiki

python get file work directory

import os
print os.path.dirname(__file__)

Windows 開機 / 關機執行指令稿

 可以使用 群組管理原則 (gpedit.msc) 或 登錄檔編輯器 (regedit)


gpedit.msc

使用者設定 -> Windows 設定 -> 指令碼 - (登入/登出)


regedit
在底下位置下新增 Script 類型

登入
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logon\0\0
登出
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0

使用指令
Reg Add HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0 /v Script /t REG_SZ /d C:\class_auth\logoff.exe /f

2012年6月18日 星期一

vim + pylint

Drop pylint.vim in ~/.vim/compiler directory. Ensure that your PATH environment variable includes the path to 'pylint' executable.


"   Above is realized with :Pylint command. To disable calling Pylint every
"   time a buffer is saved put into .vimrc file
"
"       let g:pylint_onwrite = 0
"
"   Displaying code rate calculated by Pylint can be avoided by setting
"
"       let g:pylint_show_rate = 0
"
"   Openning of QuickFix window can be disabled with
"
"       let g:pylint_cwindow = 0
"
"   Of course, standard :make command can be used as in case of every
"   other compiler.




Reference :
pylint.vim - compiler plugin for python style checking tool : vim online

2012年6月17日 星期日

Python 打包 EXE - py2exe

py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. 


1. 在專案資料夾建立 setup.py
from distutils.core import setup 
import py2exe 
     
setup(console=['main.py'])  # main.py 為你的主程式名稱

2. 執行  C:\Python27\python.exe setup.py py2exe

有可能會出錯, 官網說

You must make py2exe copy the three dlls and the manifest file into your project's dist directory, in a subdirectory called 'Microsoft.VC90.CRT'. To achieve this, add a data_files option to your project's setup.py: 

  dist
  |
  +-Microsoft.VC90.CRT
  | |
  | +-Microsoft.VC90.CRT.manifest
  | +-msvcm90.dll
  | +-msvcp90.dll
  | +-msvcr90.dll
  |
  |-etc

我下載 msvcp90.dll 放入專案資料夾也可以


3. 建立完的執行檔包會在專案資料夾的 dist, 發佈時要整個 dist 一起打包



Reference :

2012年6月16日 星期六

Interprocess Communications (IPC)

> messages (msgget msgctl msgop)
    communication is in the form of data stored in a buffer. The buffer can be either sent or reveived.


> semaphores (semget semctl semop)
    communication is in the form of positive integers with a value between 0 and 32,767. Semaphores may be contained in an array the size of which is determined by the system administrator. The default maximun size for the array is 25.

    semid : used to identify or reference a particular data structure and semaphore set(array)

    int semget(key_t key, int nsems, int semflg)
        * create a new semaphore
        * get an existing semaphore
        key is equal to IPC_PRIVATE; key is passed a unique hexadecimal integer
        semflg ANDed with IPC_CREATE is TRUE; accesss permissions, execution, control fields(commands)

        semid = semget(key, nsems, (IPC_CREATE | 0400));
        semid = semget(key, nsems, (IPC_CREATE | IPC_EXCL | 0400));
        semid = semget(IPC_PRIVATE, nsems, semflg);
        semid = semget(0, nsems, semflg);

    semaphore internal values
        sem_perm.cuid
        sem_perm.uid
        sem_perm.cgid
        sem_perm.gid
        sem_perm.mode
        sem_nsems
        sem_otime
        sem_ctime

    int semop(int semid, struct sembuf *sops, unsigned nsops);
        * acquiring or release a semaphore

        struct sembuf {
            unsigned short sem_num;
            short sem_op;
            short sem_flg;
        }

        semaphore flag options (sembuf.sem_flg)
            SEM_UNDO // Undo the semaphore operation if the process exits.
            IPC_NOWAIT // Return immediately if the ssemaphore operation cannot be performed.

    int semctl(int semid, int semnum, int cmd, ...);
        * get info about a semaphore
        * set info about a semaphore
        * remove a semaphore

        operations that can be performed using semctl
            GETVAL
            SETVAL        int
            GETPID
            GETNCNTL    int
            GETZCNTL    int
            GETAL        u_short*
            SETALL        u_short*
            IPC_STAT    struct semid_ds*
            IPC_SET        struct semid_ds*
            IPC_RMID
    User utilities
        // provide information on the ipc faclities
        $ ipcs
        // provide semaphore informations
        $ ipcs -s
        $ ipcs -s -i semid
        // remove semaphore of the semid
        $ ipcrm -s semid

    $ starce -o strace_output excutable_file

> shared memory (shmget shmctl shmop)
    communication takes place through a common area of main memory. One or more processes can attach a segment of memory and as a consequence can share whatever data is placed there.

更改 Wikidot Themes

Appearance -> Themes


Free Wikidot Themes - Wikidot Themes

VMware 網路

如何善用 VMware 的四種網路環境 - Mobile01

FLEAPHP

Core部分
FLEA_Controller_Action 实现了一个其它控制器的超类, 为开发者自己的控制器提供了一些方便
的成员变量和方法
FLEA_Dispatcher_Auth 分析 HTTP 请求,并转发到合适的 Controller 对象处理
ErrorMessage.php 定义 FleaPHP 中所有错误信息的代码及对应的错误信息
FLEA_Dispatcher_Simple 分析 HTTP 请求,并转发到合适的 Controller 对象处理
FLEA_View_Simple 实现了一个简单的、使用 PHP 自身作为模版语言, 带有缓存功能的模版引擎
FLEA_View_Smarty 提供了对 Smarty 模板引擎的支持
StdLibs.php 基本函数库

Config部分
Default_APP_INF.php FleaPHP 应用程序的默认设置

DB部分
FLEA_Db_Driver_Mysql 用于 mysql 扩展的数据库驱动程序
FLEA_Db_Driver_Pgsql 用于 pgsql 扩展的数据库驱动程序
FLEA_Db_Driver_Sqlite 用于 sqlite 扩展的数据库驱动程序
FLEA_Db_TableDataGateway 封装了数据表的 CRUD 操作
FLEA_Db_TableLink 封装数据表之间的关联关系(注:该文件里有几个类,应该为处理数据表相关内>容)

Helper部分
Array.php 定义了一系列用于简化数组操作的函数
FileUploader.php 实现了一个简单的、可扩展的文件上传助手
Html.php 定义一组便于生成表单元控件的方法
Image.php 封装了针对图像的操作
ImgCode.php 实现了一个简单的图像验证码生成器,并带有检查验证方法
Iterator.php 实现了一个简单的迭代子
Pager.php 提供数据查询分页功能
SendFile.php 用于向浏览器发送文件
Validation.php 根据一系列验证规则对指定的数据进行验证

I18N部分
FLEA_Com_Language 提供了语言转换功能

Log部分
FLEA_Com_Log 提供基本的日志服务

RBAC部分
FLEA_Com_RBAC 提供基于角色的权限检查服务
FLEA_Com_RBAC_RolesManager 用于访问保存角色信息的数据表
FLEA_Com_RBAC_UsersManager 用于访问保存用户信息的数据表

MAC Address 查詢

MAC_Find: Vendor/Ethernet/Bluetooth MAC Address Lookup and Search

tftpd-hpa

super-server => inetd or xinetd

debina lenny

/etc/default/tftpd-hpa

RUN_DAEMON="yes"
OPTIONS="-l -s -c /var/lib/tftpboot"

put上传的时候显示File not found的解决办法 : -c 指定了可以创建文件

OpenLDAP

做目錄服務前, 先把架構(tree)畫出來!!

1988 X.500-Client <-> X.500-Server
1993 LDAP-Client <-> LDAP-Gateway <-> LDAP-Server
1995 LDAP-CLient <-> LDAP-Server

LDAP back end databases : BerkeleyDB, MySQL, Oracle, etc...

LDAP optimized for query

Schema
Database
Table
Data
Replication between db servers

nscd - GNU C Library: Name Service Cache Daemon

Client
    Pam LDAP
    PHP LDAP

Management Tool
    PhpLDAPadmin
    LDAP Explorer Tool

Implementation
    LDAP address book
    Authentication center
    LDAP relay
    DNS and LDAP
    Switch LDAP DB to mysql or others

Kerberos 5

Windows Boot Process with AD
    Client boot into windows
    Client get IP address
    Client query IP address for DC
    Client log on with computer account
    Client download and execute GPO rules
    Client running startup services
    User interactive login

DNS <-> AD+GPO <-> Exchange

email.pandalog.com
panda tpe

get partition start

# parted -s /dev/sda unit s print | grep -iE -A 100000 "[[:space:]]*Start[[:space:]]*End[[:space:]]*" | sed -e "s/^.*[[:space:]]*Start[[:space:]]*End[[:space:]]*.*$//g" | sed "/^$/d" | awk -F" " '{print $2}' | sed -e "s/s$//g" | sort -n | head -n 1

Git 忽略某些檔案 .gitignore

$ cd ~/Notebooks
$ vi .gitignore
.zim.cache
.zim.history.cache
Notes/.zim/index.db
Notes/.zim/state.conf
$ git add .gitignore
$ git commit -m 'add .gitignore'
$ git push origin master




Reference :
Git .gitignore 設定 與 注意事項 - 以 Zim 操作為範例

Python Clone Digger 檢查重複代碼

 
 
安裝法一:
# easy_install -U clonedigger 
 
安裝法二:
$ svn co https://clonedigger.svn.sourceforge.net/svnroot/clonedigger/trunk clonedigger 
$ cd clonedigger
# python setup.py install


使用法:
$ cd MyProj
$ clonedigger .
Parsing  ./wx_tools.py ... done
Parsing  ./main.py ... done
Parsing  ./nt_api.py ... done
19 sequences
average sequence length: 4.842105
maximum sequence length: 14
Number of statements:  92
Calculating size for each statement... done
Building statement hash... done
Number of different hash values:  49
Building patterns... 58 patterns were discovered
Choosing pattern for each statement... done
Finding similar sequences of statements... 3  sequences were found
Refining candidates... 2 clones were found
Removing dominated clones... -1 clones were removed
$ firefox output.html  # 觀看報表


可與 eclipse 和 Jenkins 整合, 待續 ..





您裝置的註冊國家/地區不允許安裝這個項目

Market Enabler

MarketAccess




Reference :
[問題]您裝置的註冊國家/地區不允許安裝這個項目 - Mobile01
如何下載Android Market國家地區限定的App? - 天馬行空飛行城

Android 安裝 APK 檔

1. 允許安裝非 Market 的應用程式

Android 2.3 設定 -> 應用程式 -> 未知的來源 打勾

Android 4.0 設定 -> 安全性 -> 未知的來源 打勾


2. 從電腦下載 apk 檔並放入 sdcard


3. 於 Market 安裝 Appsinstaller , 執行後會搜尋 /mnt/sdcard 裡的 apk 檔

Android SSH Server (Dropbear)

取得 Root 權限後

於 Market 安裝 DropBear

連上無線網路, 以及開啟 DropBear Server

帳號 : root
密碼 : 42

Android Root

安機網一鍵ROOT


成功機型:

盈方微 superpad P752 (Android 2.3.3) (2.6.35.7-indoTM) (ARMv6-compatible processor rev 5 (v6l) 1.0 GHz、791.34 MIPS)

Infotmic m799ca 2.3.3


未成功:

讯洋 MiniPad X501R (Android 2.1) (2.6.28) (ARM926EJ-Srev 5 (v51) 700 MHz)


未測試:

FreeRunner (ARM920T rev 0 (v4l) 400.000 MHz、199.47 MIPS)






Reference :
一鍵讓你取得Android手機ROOT權限的方便工具,支援超過200隻手機! | ㊣軟體玩家
[Android] 五分鐘 ROOT 掉 Android 手機!(支援 Android 2.1 或以上)


2012年6月14日 星期四

office 2007 frontpage


SharePoint Designer
Microsoft Expression Web


更改 Windows 檔案預設開啟程式

exe 使用 notepad 開啟
Start -> Run -> ftype exefile=notepad.exe %1




Referenece :
进程关不掉的木马处理技巧_安全防护_中国网管联盟bitsCN.com

Windows kill process 刪除進程

> tskill PID or tskill TASKNAME (不用加副檔名 no .exe)

> taskkill /PID PID

> drwtsn32 -p PID

> ntsd -c q -p PID

ntsd > drwtsn32 > taskkill > tskill


結束處理程序

這項操作無法完成。
存取被拒。

This operation could not be completed.
Access is denied.

3rd Solution :
Process Hacker > Advanced Process Termination (APT) > Process Explorer




Reference :
Window某些程序關不掉的解決方案
強制關閉程式 @ 全力以赴每一天 :: 痞客邦 PIXNET ::
命令行杀毒工具tskill,taskkill,ntsd - 神琦老爸的日志 - 网易博客

Python wxwidgets bind key 'Ctrl + C'

處理原生 EVT_KEY_DOWN 事件
    self.Bind(wx.EVT_KEY_DOWN, self.on_key_down)

    def on_key_down(self, event):
        """Key down event handler."""
        key = event.KeyCode()
       
        controlDown = event.ControlDown()
        altDown = event.AltDown()
        shiftDown = event.ShiftDown()

        # Cut to the clipboard.
        if (controlDown and key in (ord('C'), ord('c'))):
            copy()
        # Insert the next command from the history buffer.
        else:
            event.Skip()

Reference :
CharacterCodesAndKeyboards - wxPyWiki


使用 wx_tools class
import wx_tools
class Frame(wx.Frame):
    def __init__(self, *args, **keywords):
       self.__init_key_handlers()

    def __init_key_handlers(self):
        '''Initialize key shortcuts.'''
  
        self.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
 
        def copy():
            print 'copy'

        self.key_handlers = {
            Key(ord('C'), cmd=True): copy,
         }

    def on_key_down(self, event):
        '''wx.EVT_KEY_DOWN handler.'''
        key = Key.get_from_key_event(event)
        handler = self.key_handlers.get(key, None)
        if handler:
            handler()
        else:
            event.Skip()

Reference :
Nullege: A Search Engine for Python source code
garlicsim_wx.widgets.workspace_widgets.crunching_controls.step_profiles_controls.step_profiles_list.step_profiles_list :: garlicsim_wx 0.6.3 : PyDoc.net

2012年6月13日 星期三

fatal error: generated/autoconf.h: No such file or directory compilation terminated.

以我的 kernel 為例

或許該安裝
linux-headers-3.2.0-2-486

而非
linux-headers-3.2.0-2-common

python wxwidgets 捕捉 Alt+F4

1. 捕捉 wxwidgets 窗口關閉事件
    self.frame.Bind(wx.EVT_CLOSE, self.OnClose)

    def OnClose(self, evt):
        print 'cannot close'

#        dlg = wx.MessageDialog(None, "Is this explanation OK?",
#                'A Message Box',
#                wx.YES_NO | wx.ICON_QUESTION)
#        retCode = dlg.ShowModal()
#        if (retCode == wx.ID_YES):
#            self.frame.Destroy()
#            print "yes"
#        else:
#            print "no"

2. 捕捉 wx 快捷鍵 (wx.EVT_HOTKEY) (不能使用 wx.EVT_KEY_DOWN 事件捕捉快捷鍵)
 import win32con  #for the VK keycodes
 
    def regHotKey(self):
        self.hotKeyId = 100
        self.frame.RegisterHotKey(
            self.hotKeyId, #a unique ID for this hotkey
            win32con.MOD_CONTROL + win32con.MOD_SHIFT , #the modifier key
            win32con.VK_DELETE) #the key to watch for

        self.regHotKey()
        self.Bind(wx.EVT_HOTKEY, self.OnClose, id=self.hotKeyId)

3. 捕捉系統快捷鍵
Tim Golden's Python Stuff: Catch system-wide hotkeys




Reference :
关于wxWidgets中的RegisterHotKey不得不说的故事 - 程序、程序及其他 - 博客频道 - CSDN.NET
RegisterHotKey - wxPyWiki
使用热键控制python程序 - Stonelee's Blog
Python - Dictionary full of windows keys


Python wxwidgets bind key 做法 class 版

wx_tools.py
class Key(object):
    '''A key combination.'''

    def __init__(self, key_code, cmd=False, alt=False, shift=False):

        self.key_code = key_code
        '''The numerical code of the pressed key.'''

        self.cmd = cmd
        '''Flag saying whether the ctrl/cmd key was pressed.'''

        self.alt = alt
        '''Flag saying whether the alt key was pressed.'''

        self.shift = shift
        '''Flag saying whether the shift key was pressed.'''

    @staticmethod
    def get_from_key_event(event):
        '''Construct a Key from a wx.EVT_KEY_DOWN event.'''
        return Key(event.GetKeyCode(), event.CmdDown(),
                   event.AltDown(), event.ShiftDown())

    def __hash__(self):
        return hash(tuple(sorted(tuple(vars(self)))))

    def __eq__(self, other):
        if not isinstance(other, Key):
            return NotImplemented
        return self.key_code == other.key_code and \
            self.cmd == other.cmd and \
            self.shift == other.shift and \
            self.alt == other.alt


 main.py
from wx_tools import Key

class MyApp(wx.App):

    def __init_key_handlers(self):
        '''Initialize key shortcuts.'''

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

        # Now you define handlers for various keys:

        def bypass_key():
            print 'key bypassed'

        # This is the big dict that maps keys to their handlers:

        self.key_handlers = {
            Key(wx.WXK_ESCAPE): bypass_key,
            Key(wx.WXK_DELETE): bypass_key,
        }

    def init_frame(self):
        self.res = xrc.XmlResource('login.xrc')

        self.frame = self.res.LoadFrame(None, 'mainFrame')

        # bind key event
        self.__init_key_handlers()

        self.frame.Show()

    def OnKeyDown(self, event):
        '''wx.EVT_KEY_DOWN handler.'''
        key = Key.get_from_key_event(event)
        handler = self.key_handlers.get(key, None)
        if handler:
            handler()
        else:
            event.Skip()




Reference :
Processing key events in a strategy pattern - wxPyWiki

Python wxwidgets bind key 做法

class MyApp(wx.App):
    def init_frame(self):
        self.res = xrc.XmlResource('login.xrc')

        self.frame = self.res.LoadFrame(None, 'mainFrame')

        # 在此 frame 下監聽所有按鍵反應
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

        # 或綁定單一原件
        wx.EVT_KEY_DOWN(xrc.XRCCTRL(self.frame, 'userTxt'), self.OnKeyDown)

        self.frame.Show()

    def OnKeyDown(self, e):
        key = e.GetKeyCode()

        if key == wx.WXK_ESCAPE:
            print 'Event!'
        else:
            e.Skip()


用陣列綁定多個 key
python - In wxPython how do you bind a EVT_KEY_DOWN event to the whole window? - Stack Overflow




Reference :
python - wxpython capture keyboard events in a wx.Frame - Stack Overflow
Events in wxPython

self.Bind vs. self.button.Bind - wxPyWiki

Keycode Table

CharacterCodesAndKeyboards - wxPyWiki

wxPython: Catching Key and Char Events « The Mouse Vs. The Python

從工作管理員裡隱藏

1. 監視工作管理員視窗開啟

2. 獲取 tasklist

3. 將本身行程從 tasklist 移除後寫回 SysListView32

Python 使用 _winreg 修改註冊表

from _winreg import *
keyVal = r'SOFTWARE\Microsoft\Windows\CurrentVersion\policies\System'
try:
    key = OpenKey(HKEY_CURRENT_USER, keyVal, 0, KEY_ALL_ACCESS)
except:
    key = CreateKey(HKEY_CURRENT_USER, keyVal)
SetValueEx(key, "DisableTaskMgr", 0, REG_DWORD, 1)
CloseKey(key)




停用工作管理員
34.3. _winreg – Windows registry access — Python v2.7.3
Python’s _winreg: Editing the Windows Registry « The Mouse Vs. The Python

Python GUI 隱藏命令列視窗

1. 使用系統函式庫來隱藏
import ctypes  
whnd = ctypes.windll.kernel32.GetConsoleWindow()  
if whnd != 0:  
    ctypes.windll.user32.ShowWindow(whnd, 0)  
    ctypes.windll.kernel32.CloseHandle(whnd)
import ctypes
whnd = ctypes.windll.kernel32.GetConsoleWindow()
if whnd != 0:
    ctypes.windll.user32.ShowWindow(whnd, 0)
    ctypes.windll.kernel32.CloseHandle(whnd)


2. 將擴展名改成 .pyw, 即使用 pythonw.exe 來運行




Reference :
[转]python中隐藏Console窗口_枫之叶舞_百度空间
windows下python程序控制台隐藏小技巧 - 老爸的蒸面条 - 51CTO技术博客

2012年6月12日 星期二

打造 vim 成為 Python IDE

indent :


autocomplete :
Pydiction : Tab-complete your Python code


unittest :


checker :
pyflakes
    +                =>        Flake8
pep8

pylint




Reference :
Turning Vim into a modern Python IDE
VIM as Python IDE | Alain M. Lafon
Python VIM 开发环境配置 [Python俱乐部]

pep8 + pyflakes = Flake8


安裝 flake8

下載後解壓

接著進行安裝

# python setup.py install


安裝 vim 插件 vim-flake8
$ git clone git://github.com/nvie/vim-flake8.git

將 python_flake8.vim 擺入 ~.vim/ftplugin/python/


用 vim 開啟 python 文件, 按 F7 試試




Reference :
配置基於Vim的Python編程環境

Android Apps

Hacker's keyboard

wxWidgets layout 工具

DialogBlocks

wxDesigner (nonfree)

wxFormBuilder (64-bit)








VisualWx


spe (Python IDE, 整合 pychecker & xrced)



wxGlade(free)
boa-constructor(free),只支持wxPython 2.4.3
xrced(in wxPython docs, demos and tools),只能编辑xrc文件
DialogBlocks(commercial),不支持python代码生成,只能生成xrc文件
wxDesigner(commercial)














Reference :

[python-chinese] 有没有wxPython的对话框设计器?

2012年6月11日 星期一

Windows XP 掃描器與數位相機 掃描很慢

從純淨的系統 %systemroot%\system32 複製如下動態函式庫並擺入此機 %systemroot%\system32
regsvr32  wiadefui.dll
regsvr32  wiadss.dll
regsvr32  wiavusd.dll
regsvr32  wiascr.dll
regsvr32  wiaservc.dll
regsvr32  wiashext.dll
regsvr32   wiavideo.dll
regsvr32   camocx.dll


接著重新註冊函式庫

Start -> Run -> cmd
regsvr32  wiadefui.dll
regsvr32  wiadss.dll
regsvr32  wiavusd.dll
regsvr32  wiascr.dll
regsvr32  wiaservc.dll
regsvr32  wiashext.dll
regsvr32   wiavideo.dll
regsvr32   camocx.dll


或是直接整個系統修復

Start -> Run -> sfc /scannow




Reference :
小示維谷的類別: [雜症]掃描器與數位相機精靈 異常

Assigning the return value of new by reference is deprecated in

解决办法:php5.3开始后,废除了php中的”=&”符号,所以要想复制,直接用 = 引用即可




Reference :
Assigning the return value of new by reference is deprecated in xxxx的解决办法 at 刘华栋的博客

2012年6月10日 星期日

系統無法執行指定的程式

需安裝 VC9 Runtime (Microsoft Visual C++ 2008 可轉散發套件 (x86))



影響軟件:
php.exe (php-5.4.3)
wampmanager.exe (Wampserver (32 bits & PHP 5.3) 2.2E)

Windows XP 自動進入桌面

無密碼但不會自動進入桌面的解決方式
 
在開始 -> 執行 輸入
control userpasswords2
rundll32 netplwiz.dll,UsersRunDll 

將 "必須輸入使用者名稱和密碼,才能使用這台電腦" 取消選取
 




Reference :
怎样让xp自动进入桌面

停用 LinkedIn 帳號





Reference :
how do i disable my linkedin account? | LinkedIn Answers | LinkedIn

mplayer 全螢幕播放

$ mplayer xxx.avi

按下快捷鍵 f


若不行 zoom in

$ vi ~/.mplayer/config
zoom=yes




Reference :
愛風神: mplayer全螢幕播放與DVD橫向波紋問題

2012年6月8日 星期五

Google 谷歌拼音輸入法 兩岸用詞 對照 查詢

女 nuu -> nv
綠 luu -> lv
垃圾 lese -> laji
暫時 zhanshi -> zanshi
攜帶 xidai -> xiedai
和 han -> he




Reference :
中文拼音查詢

Apache 2 安全性設定

# vi /etc/apache2/conf.d/security
ServerSignature Off
ServerTokens Prod

2012年6月7日 星期四

moodle 安裝

安裝 LAMP


安裝 moodle 需要的
# apt-get install php5-curl php5-xmlrpc php5-gd php5-intl


下載 moodle
# wget http://download.moodle.org/download.php/stable22/moodle-latest-22.tgz
# tar zxf moodle-latest-22.tgz
# mv moodle /var/www/
# chown -R www-data:www-data /var/www/moodle/


http://localhost/moodle/install.php
Parent directory (/var) is not writeable. Data directory (/var/moodledata) cannot be created by the installer.
# mkdir /var/moodledata
# chown www-data:www-data /var/moodledata


在 Database settings 之前
mysql> CREATE DATABASE moodle;
mysql> ALTER DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES, DROP,INDEX,ALTER ON moodle.* TO moodle@localhost IDENTIFIED BY 'yourpassword';
mysql> QUIT
  


Reference :
安裝Moodle - MoodleDocs

SPSS 更改授權位址

C:\Program Files\IBM\SPSS\Statistics\19\spssprod.inf

DaemonHost=xxx.xxx.xx.xx

Python HTTP Server

$ cd /mnt/blahblah

$ python -m SimpleHTTPServer

http://IP:8000/

有 Indexes 的功能 ~~




Reference :
用 Python 快速建立一個 Web server | Tsung's Blog

Linux mount NTFS

# vi /etc/fstab

/dev/hda6 /media/sda6/ ntfs-3g rw,defaults,umask=00002,locale=zh_TW.utf8  0 0


debian / ubuntu 安裝 LAMP

# apt-get install apache2 php5 libapache2-mod-php5 php5-mysql mysql-server-5.1 mysql-client-5.1 phpmyadmin





Reference :
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu | DigitalOcean
Installing LAMP On Ubuntu For Newbies | HowtoForge - Linux Howtos and Tutorials
[ubuntu] LAMP 基本架站 | 就是,蛋!

2012年6月6日 星期三

VBA KeyDown

輸入完按 Enter 跳至下一個輸入框
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = 13 Then
                TextBox2.SetFocus
        End If
End Sub




Reference :
Excel VBA textbox判斷是否有按Enter鍵-彰化一整天的Blog留言版
如何利用 Enter 鍵作為 Tab 鍵? / Visual Basic 6.0/VBA / 程式設計俱樂部

2012年6月5日 星期二

建立 Android 開發環境 (手動版)

1. 安裝 Java SDK
# apt-get install sun-java6-jdk sun-java6-jre

2. 安裝 Eclipse
下載 Eclipse IDE for Java Developers 版本

3. 安裝 Android Development Tools (ADT)
開啟 eclipse -> Help -> Install New Softare -> Add -> 輸入 Name 「ADT」 與 URL 「http://dl-ssl.google.com/android/eclipse/site.xml 」-> OK -> Eclipse 會搜尋一下 -> 選擇 Developer Tools 含底下項目後 -> 一直 Next 後 Install -> 完成後重新啟動 eclipse

4. 安裝 Android SDK
從 http://developer.android.com/sdk/index.html 下載 android-sdk_r18-linux.tgz 解壓至 ~/

開啟 eclipse -> Window -> Android SDK Manager

回報錯誤訊息
Fetching https://dl-ssl.google.com/android/repository/addons_list-1.xml
Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: peer not authenticated
Fetching URL: https://dl-ssl.google.com/android/repository/repository-6.xml
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.xml, reason: peer not authenticated

在 Android SDK Manager -> Tools -> Manage Add-on Sites, 新增
http://dl-ssl.google.com/android/repository/addons_list-1.xml
http://dl-ssl.google.com/android/repository/repository-6.xml

可以安裝 API 15、14、....

安裝 API 時出現
This package depends on 'Missing SDK Platform Android, API 15'.

要手動從 https://dl-ssl.google.com/android/repository/repository-6.xml 下載 Platform 檔案, 解壓至 ~/android-sdk-linux/platforms

https://dl-ssl.google.com/android/repository/android-15_r03.zip

5. 新增 AVD
開啟 eclipse -> Window -> AVD Manager

新增完後開啟 AVD 出現
Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder.

要手動從 https://dl-ssl.google.com/android/repository/repository-6.xml 下載 image 檔案, 解壓至 ~/android-sdk-linux/system-images

https://dl-ssl.google.com/android/repository/sysimg_armv7a-15_r02.zip




Reference :
android 4.0 sdk直接下载地址 - cmoaciopm的专栏 - 博客频道 - CSDN.NET

Missing android-sdk-linux/tools/lib/proguard-project.txt - 异读心寒 - ITeye技术网站
Android 4.0:Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder. - 懒人的技术笔记 - 博客频道 - CSDN.NET
报错“Unable to find a userdata.img file for ABIarmeabi to copy into the AVD folder.”_移动开发_电脑学网(Xue5.CoM)

2012年6月4日 星期一

no swt-pi-gtk-3740 in java.library.path

$ vi /home/yan/.eclipse/org.eclipse.platform_3.7.0_155965261/configuration/1338821859239.log

!SESSION 2012-06-04 22:57:33.880 -----------------------------------------------
eclipse.buildId=I20110613-1736
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=zh_TW
Command-line arguments:  -os linux -ws gtk -arch x86

!ENTRY org.eclipse.osgi 4 0 2012-06-04 22:57:45.020
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
        no swt-pi-gtk-3740 in java.library.path
        no swt-pi-gtk in java.library.path
        Can't load library: /home/yan/.swt/lib/linux/x86/libswt-pi-gtk-3740.so
        Can't load library: /home/yan/.swt/lib/linux/x86/libswt-pi-gtk.so


解:
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jni/
$ eclipse




Reference :
How do you set a library path in java ? (Java in General forum at JavaRanch)

2012年6月3日 星期日

Specified key was too long; max key length is 1000 bytes

建立索引时,数据库计算key的长度是累加所有Index用到的字段的char长度后再按下面比例乘起来不能超过限定的key长度1000

如果表是UTF8字符集,那索引还是建立不了。




在安裝 Gerrit 時發生了這個問題, 或許創建資料庫時使用就不使用 utf8 改用 latin1 或其他




Reference :
YOYO’S BLOG » Blog Archive » MySQL错误“Specified key was too long; max key length is 1000 bytes”的解决办法

Gerrit 安裝

[Server]
# apt-get install mysql-server mysql-client postfix sun-java6-jre

mysql -u root -p
mysql> CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'gerrit';
mysql> CREATE DATABASE reviewdb;
mysql> ALTER DATABASE reviewdb charset=latin1;
mysql> GRANT ALL ON reviewdb.* TO 'gerrit'@'localhost';
mysql> FLUSH PRIVILEGES;

# useradd -m gerrit
# su - gerrit

$ wget http://gerrit.googlecode.com/files/gerrit-2.4.war
$ chmod 744 gerrit-2.2.1.war
$ java -jar gerrit-2.2.1.war init -d review_sites

*** Gerrit Code Review 2.4
***


*** Git Repositories
***

Location of Git repositories   [git]:

*** SQL Database
***

Database server type           [MYSQL/?]:
Server hostname                [localhost]:
Server port                    [(MYSQL default)]:
Database name                  [reviewdb]:
Database username              [root]: gerrit
Change gerrit's password       [y/N]? y
gerrit's password              :
              confirm password :

*** User Authentication
***

Authentication method          [OPENID/?]:

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [NONE/?]:
SMTP username                  :

*** Container Process
***

Run as                         [gerrit]:
Java runtime                   [/usr/lib/jvm/java-6-sun-1.6.0.24/jre]:
Upgrade /home/gerrit/review_sites/bin/gerrit.war [Y/n]?
Copying gerrit.war to /home/gerrit/review_sites/bin/gerrit.war


*** SSH Daemon
***

Listen on address              [*]: Listen on port                 [29418]:

*** HTTP Daemon
***

Behind reverse proxy           [y/N]?
Use SSL (https://)             [y/N]?
Listen on address              [*]:
Listen on port                 [8080]:
Canonical URL                  [http://localhost:8080/]:

Initialized /home/gerrit/review_sites

$ ~/review_sites/bin/gerrit.sh restart


 [Client]
進入 Gerrit 網頁 http://localhost:8080/
Registered the first user with openid. // 註冊的第一位使用者將自動成為主管理員
Add SSH Public Keys
 
$ ssh -p 29418 yan@your_domain
  ****    Welcome to Gerrit Code Review    ****

  Hi yan, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://yan@localhost:29418/REPOSITORY_NAME.git

Connection to localhost closed.


$ ssh -p 29418 yan@localhost gerrit create-project -n sandbox
$ git clone ssh://yan@localhost:29418/sandbox.git 
Cloning into 'sandbox'...
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ cd sandbox
$ touch README
$ git add *
$ git commit
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 202 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done   
To ssh://yan@localhost:29418/sandbox.git
 ! [remote rejected] master -> master (can not create new references)
error: failed to push some refs to 'ssh://yan@localhost:29418/sandbox.git'

原因:Gerrit不希望我们直接覆写Git代码库中的任何分支

$ git config remote.origin.push refs/heads/*:refs/for/*
or
$ git config remote.origin.push HEAD:refs/for/master

$ git push origin


* 專案管理可用 git-review 工具代替


進入網頁 http://localhost:8080/ 選單 My -> Changes 即可看到待審核的提交






Reference :
Cherry-picking Pearls in San Francisco: My take on installing gerrit (git code review tool) on ubuntu
Gerrit unter Ubuntu installieren | seeseekey.net
InfoQ: Git、Gerrit与Jenkins/Hudson CI服务器
John Hsing's Blog: 初试 Gerrit


Further :
隨手誌: git push到gerrit review server的方法與設定

Error: unrecognized/unsupported machine ID


u-boot 與 linux kernel 的 machine ID不一致所導致


方法一、把Uboot中board init中更改为MACH_TYPE_AT91RM9200DK

方法二、把MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK")更改为MACHINE_START(AT91RM9200, "Atmel AT91RM9200-DK")。



open http://blog.csdn.net/adigita/article/details/5588819

open http://blog.csdn.net/adigita/article/details/5588902

open http://blog.csdn.net/bailang326/article/details/6237293

open http://hi.baidu.com/zybuaa/blog/item/5ef9164c12fe8afcd72afc9c.html

open http://www.360doc.com/content/12/0114/16/8388102_179361051.shtml

open http://read.newbooks.com.cn/info/195648.html