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 08, 2011

Erlang 筆記

pwd().

cd("dir").

如果檔名是math1.erl,compile的指令
c(math1).

檔案裡的module要跟檔名相同
-module(math1).

執行
math1:function(args).

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 07, 2011

Website to Kindle

Change Kindle Locale

[Home] - [Del]

;debugOn
~changeLocale zh-TW.utf8
;debugOff

[Home] - [Menu] - Settings - [Menu] - Restart

June 03, 2011

Git 筆記 II

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