Showing posts with label Notes. Show all posts
Showing posts with label Notes. Show all posts

January 12, 2016

Change the installation directory of npm -g

To prevent to pollute the environment, create a local_dir then

npm config set prefix local_dir
or just edit the .npmrc
prefix=local_dir
and set $PATH to include local_dir/bin
export PATH=local_dir/bin:$PATH

October 19, 2015

List all of the libraries in jar

Source

find . -name "*.jar" | xargs -n 1 jar tf

June 25, 2015

Gradle command line


From here

gradlew help
gradlew tasks
 

Convert newline format on Mac

perl -pe 's/\r\n|\n|\r/\r\n/g' inputfile > outputfile  # Convert to DOS
perl -pe 's/\r\n|\n|\r/\n/g'   inputfile > outputfile  # Convert to UNIX
From this post

June 04, 2015

Fail to mount Guest Additions in VirtualBox

Just met this problem today and found solution here

sudo apt-get install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

August 28, 2014

一些 ssh 的設定


參考這篇,有很多把 key 的話,可以設定 .ssh/config 如下

Host github.com
        User git
        Hostname github.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/github/id_rsa
Host bitbucket.org
        User git
        Hostname bitbucket.org
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/bitbucket/id_rsa
使用 ssh-agent 可以在 .bashrc 加入以下設定
# ssh_agent
function check_ssh_agent {
    if [ ! -e "$SSH_AUTH_SOCK" ]; then
        eval `ssh-agent -s`
        ssh-add
    fi
}

check_ssh_agent;

如果有多把 key 而且在不同目錄就要在 ssh-add 後面指定要加入哪些 key

October 13, 2011

用 cat 寫檔

cat > file << EOF

檔案內容
EOF

September 30, 2011

chmod 644 for files and 755 for directories

  • find path -type f | xargs chmod 644
  • find path -type d | xargs chmod 755

August 18, 2011

ubuntu 檢視 package 安裝資訊

dpkg-query -L package_name

August 04, 2011

gitolite + http mode + LDAP

gitolite 安裝
參考這邊,將 /var/www 改為想要放置 git repo 位置的目錄
cd /var/www/
mkdir gitolite-home
export GITOLITE_HTTP_HOME=/var/www/gitolite-home
PATH=$PATH:$GITOLITE_HTTP_HOME/bin
cd gitolite-home/
git clone git://github.com/sitaramc/gitolite gitolite-source
cd gitolite-source/
GHH=$GITOLITE_HTTP_HOME
mkdir -p $GHH/bin $GHH/share/gitolite/conf $GHH/share/gitolite/hooks
src/gl-system-install $GHH/bin $GHH/share/gitolite/conf $GHH/share/gitolite/hooks
vim /var/www/gitolite-home/share/gitolite/conf/example.gitolite.rc
gl-setup ADMIN的LDAP帳號
apache 設定
參考這邊,修改 auth 的部份為 LDAP
<LocationMatch "/git">
AuthType Basic
AuthName "Git"
Require valid-user

AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPURL "ldap://server:389/dc=company,dc=local?sAMAccountName?sub?(objectclass=*)" NONE
AuthLDAPBindDN "cn=user,ou=team,ou=department,dc=company,dc=local"
AuthLDAPBindPassword secret
</LocationMatch>
設定gitolite
選擇以後要放設定檔的位置
  • git clone http://server/git/gitolite-admin
gitolite.conf 的設定說明,要新增 repo 或是要加入使用者設定都是在這個檔案修改,修改完成以後將 gitolite.conf 更新回 server
  • git add
  • git commit
  • git push origin master

July 28, 2011

git-http-backend on CentOS 5.5

from CentOS, Git & http-push unavailable

  • install new version curl in local directory
  • configure git as ./configure --with-curl=curl dir
apache settings from
  • git init --bare git-repo-dir (beware of the directory permission - httpd user writable)
  • git update-server-info
  • in /etc/httpd/conf/httpd.conf or /etc/httpd/conf.d/git.conf
SetEnv GIT_PROJECT_ROOT git-repo-dir
SetEnv GIT_HTTP_EXPORT_ALL
AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /git-repo-dir/$1
AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /git-repo-dir/$1
ScriptAliasMatch \
"(?x)^/git/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/usr/local/libexec/git-core/git-http-backend/$1
ScriptAlias /git/ /usr/local/share/gitweb/gitweb.cgi

<Directory "git-repo-dir">
Allow from all
</Directory>

<LocationMatch "/git">
AuthType Basic
AuthName "Git"
#AuthUserFile AuthFile
#Require valid-user

AuthBasicProvider ldap
AuthLDAPURL "ldap://server:389/dc=company,dc=local?sAMAccountName?sub?(objectclass=*)" NONE
AuthLDAPBindDN "cn=user,ou=team,ou=department,dc=company,dc=local"
AuthLDAPBindPassword secret

AuthzLDAPAuthoritative on
require ldap-user user1 user2 user3
</LocationMatch>

auth
  • git clone http://server/git-repo-dir
  • git clone http://username@server/git-repo-dir
  • git clone http://username:password@server/git-repo-dir
  • unset SSH_ASKPASS

June 03, 2011

Git 筆記 II

  • git rm --cached file
    remove the file from stage area but keep the file in working area

May 24, 2011

SSH login without password

產生 key

  • ssh-keygen -t rsa
    將產生的 id_rsa.pub 放到 target machine 的 .ssh/authorized_keys
  • ssh-keygen -t dsa
    將產生的 id_dsa.pub 放到 target machine 的 .ssh/authorized_keys
權限設定
  • .ssh/ is 700
  • .ssh/authorized_keys is 600
  • home 目錄的 owner 要是自己 (...)

April 20, 2011

時區設定

在一個無法連上網路的機器上設定時區...

export TZ=UTC
date GMT+0 時間
/usr/bin/tzselect 選擇自己的時區

April 19, 2011

...

set @INC path of perl

  • export PERL5LIB=PATH
set perl module prefix directory
  • perl Makefile.PL PREFIX=DIR

April 15, 2011

QT I

  • close() 關閉視窗
  • 改變widget background
QPalette palette
paletta.setColor(QPalette::Normal, QPalette::Base, Qt::green);
widget->setPalette(palette);

March 28, 2011

UTF8 設定

.bash_profile

LC_CTYPE=zh_TW.UTF-8; export LC_CTYPE
LC_ALL=zh_TW.UTF-8; export LC_ALL
LANG=zh_TW.UTF-8; export LANG

irssi

/set term_charset UTF-8
/set recode_transliterate ON
/set recode_fallback UTF-8
/set recode_out_default_charset UTF-8
/recode add #channel Big5/UTF-8
/recode - can check channel setting

screen

Ctrl-a :encoding big5 utf8 - for big5 screen

October 27, 2010

vim 替換換行符號

:%s/ctrl-v ctrl-m/ctrl-v [enter]/g

September 07, 2010

Outlook 2000 設定

Outlook 2000的個人資料夾檔案(.pst)上限是2GB,不幸滿了的時候的處理方法。


  • 找出電腦裡的Scanpst.exe,我的在 C:\Program Files\Common Files\System\Mapi\1028\NT 目錄中
  • 找到過大的.pst檔,檔案位置可由Outlook的工具服務個人資料夾屬性中得知
  • 使用Scanpst修復.pst檔後,重新啟動Outlook,通常還是沒用,因為檔案真的太大了
  • 下載這個檔案,這個程式是把.pst刪掉一點,讓檔案小於2GB,這樣Outlook就可以讀,刪掉的資料當然就是不見了(註)
  • 再次使用Scanpst修復.pst檔,重新啟動Outlook應該就可以正常使用。如果還是不行,就重複上個步驟,讓他砍掉的大小再大一點
上面的方法只是治標,如果你需要留下來的信就是這麼多,.pst檔再次超過2GB是遲早的事。稍微查了一下,治本的方法是把信分成多個.pst檔來儲存(或者是用GMail?)。

把信分成多個.pst檔的方法
  • Outlook裡的工具服務新增個人資料夾-選擇.pst檔的位置-設定名稱跟壓縮設定
  • 可以把信件搬進新的個人資料夾,或者設定郵件規則讓某些信件進入特定資料夾
  • 搬動信件以後,使用工具服務屬性壓縮原本的.pst
  • 也可以使用檔案匯入把.pst匯入新的個人資料夾
註:公司MIS有示範不遺失任何信的處理方法,不過他動作太快了我記不起來