Cài scim-unikey trên Backtrack 5

Sau một tối loay hoay thì cuối cùng mình cũng đã cài được unikey lên Backtrack5, viết một cái blog để share với mọi người, cũng là tư liệu sau còn dùng :D  Để cài các bạn thực hiện các bước như sau: 

Bước 1: cài scim
sudo apt-get install scim scim-bridge* scim-unikey

Bước 2: Vào thư mục /etc/X11/Xsession.d và tạo một file 95xinput có nội dung như sau

export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE="scim"

Bước 3: Chmod 755 cho file vừa tạo
chmod 755 /etc/X11/Xsession.d/95xinput

Bước 4: Reboot máy
(trong trường hợp không được thì cài thêm các gói scim-gtk2-immodule scim-modules-socket scim-modules-table scim-pinyin scim-tables-zh scim-input-pad)

p1

MongoDB logrotate script

Cắt log trong Mongodb

Mongod có tính năng tự động cắt log sử dụng command logRotate (db.runCommand("logRotate")), ở bản mongo 10gen đã loại bỏ cái scipt tự động cắt log, ta phải làm thuần bằng tay, vì vậy tôi sử dụng logrotate có sẵn trong Linux để cắt, gzip lại, cơ chế cắt log như nginx, apache...

- Tạo file /etc/logrotate.d/mongod với nội dung sau
/var/log/mongo/mongod.log {
        daily
        rotate 30
        compress
        dateext
 
    missingok
    notifempty
    sharedscripts
    postrotate
        /bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
    endscript
}
 Mặc định logrotate daily làm việc lúc 4h sáng (xem tại /etc/cron.daily/logrotate)

p1

Fix lỗi khi cài đặt VMWare trên Ubuntu 12.04

VMware Workstation 8.0.2 và VMware Player 4.0.3 trên Ubuntu 12.04 khi cài đặt xong khởi động bị lỗi trong quá trình cài driver, ta thực hiện fix như sau

p1

Grep 2 strings in a line

Do you want to test whether both of two test strings are present at once, or whether either string is present? I'll show you how.

p1

Bind A Range Of IP's in Debian / Ubuntu Linux

This will show you how to bind more IP into a server

p1

Đàn ông nếu đã 20, nếu chưa 25

Tác giả: Lý Khai Phục từng là Phó tổng giám đốc Microsoft toàn cầu trong thập kỷ 90, rồi đảm nhận Phó tổng giám đốc Google châu Á năm 2005. Ông sinh năm 1961 tại Đài Bắc, thường gây sóng gió bởi những phát ngôn sáng suốt nhưng ngôn từ trần trụi khó nghe.

p1

Converting rewrite rules Apache to Nginx

A redirect to a main site

People who during their shared hosting life used to configure everything using only Apache’s .htaccess files, usually translate the following rules:
RewriteCond  %{HTTP_HOST}  nginx.org
RewriteRule  (.*)          http://www.nginx.org$1
to something like this:
server {
    listen       80;
    server_name  www.nginx.org  nginx.org;
    if ($http_host = nginx.org) {
        rewrite  (.*)  http://www.nginx.org$1;
    }
    ...
}

This is a wrong, cumbersome, and ineffective way. The right way is to define a separate server for nginx.org:
server {
    listen       80;
    server_name  nginx.org;
    return       301 http://www.nginx.org$request_uri;
}

server {
    listen       80;
    server_name  www.nginx.org;
    ...
}

On versions prior to 0.9.1, redirects can be made with:
rewrite      ^ http://www.nginx.org$request_uri?;

Another example. Instead of the “upside-down” logic “all that is not nginx.com and is not www.nginx.com”:
RewriteCond  %{HTTP_HOST}  !nginx.com
RewriteCond  %{HTTP_HOST}  !www.nginx.com
RewriteRule  (.*)          http://www.nginx.com$1
one should simply define nginx.com, www.nginx.com, and “everything else”:
server {
    listen       80;
    server_name  nginx.com www.nginx.com;
    ...
}

server {
    listen       80 default_server;
    server_name  _;
    return       301 http://nginx.com$request_uri;
}

On versions prior to 0.9.1, redirects can be made with:
rewrite      ^ http://nginx.com$request_uri?;

Converting Mongrel rules

Typical Mongrel rules:
DocumentRoot /var/www/myapp.com/current/public

RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 [QSA,L]

RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]

RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
should be converted to
location / {
    root       /var/www/myapp.com/current/public;

    try_files  /system/maintenance.html
               $uri  $uri/index.html $uri.html
               @mongrel;
}

location @mongrel {
    proxy_pass  http://mongrel;
}

p1