2012年12月30日星期日

Useful command / sites

export LD_LIBRARY_PATH=/lib

ldd       #find dependencies

getlibs   #auto install missing libraries
https://launchpad.net/~jcollins/+archive/jaminppa/+build/1482994/+files/getlibs_2.06-0ubuntu1%7Eppa2_all.deb

du  #Size of a directory & Free disk space
source

ps -eO user -H

will show the process tree along with the process status (to determine if it is a zombie -Z- or an uninterruptable sleep -D-)

strace -p pid

pstree

xkill

要強制手動釋放或清除Linux中的Cache Memory可以使用下面的指令
echo 3 > /proc/sys/vm/drop_caches

https://code.google.com/p/nekodrive/    (Mount NFS on windows)

http://tldp.org/LDP/tlk/ipc/ipc.html    IPC

http://tw.myblog.yahoo.com/hughes-blog/article?mid=105   IPC - fork and shared memory

http://developer.android.com/tools/help/proguard.html    Android, prevent reverse engineering

Solve ^M problem
If you get a “dos2unix: not found” error on Ubuntu 10.04 Lucid Lynx, there is the solution:
Install a “tofrodos” package and add two symlinks
root@ramune:/usr/bin# ln -s fromdos dos2unix
root@ramune:/usr/bin# ln -s todos unix2dos

2012年12月18日星期二

sqlite multi index


SQLite prefers to use a multi-column index such as this:
CREATE INDEX pg1_ix_all ON pg1(a,b,c);
If the pg1_ix_all index is available for use when the SELECT statement above is prepared, SQLite will likely choose it over any of the single-column indexes because the multi-column index is able to make use of all 3 terms of the WHERE clause.
You can trick SQLite into using multiple indexes on the same table by rewriting the query. Instead of the SELECT statement shown above, if you rewrite it as this:
SELECT d FROM pg1 WHERE RowID IN (
    SELECT RowID FROM pg1 WHERE a=5
    INTERSECT
    SELECT RowID FROM pg1 WHERE b=11
    INTERSECT
    SELECT RowID FROM pg1 WHERE c=99
)
Then each of the individual SELECT statements will using a different single-column index and their results will be combined by the outer SELECT statement to give the correct result. The other SQL database engines like PostgreSQL that are able to make use of multiple indexes per table do so by treating the simpler SELECT statement shown first as if they where the more complicated SELECT statement shown here.


NFS ans Samba


Network File System (NFS)

NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.
Some of the most notable benefits that NFS can provide are:
  • Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.
  • There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.
  • Storage devices such as floppy disks, CDROM drives, and USB Thumb drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.

Installation

At a terminal prompt enter the following command to install the NFS Server:

sudo apt-get install nfs-kernel-server

Configuration

You can configure the directories to be exported by adding them to the /etc/exports file. For example:

/ubuntu  *(ro,sync,no_root_squash)
/home    *(rw,sync,no_root_squash)

You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount.
To start the NFS server, you can run the following command at a terminal prompt:

sudo /etc/init.d/nfs-kernel-server start

NFS Client Configuration

Use the mount command to mount a shared NFS directory from another machine, by typing a command line similar to the following at a terminal prompt:

sudo mount example.hostname.com:/ubuntu /local/ubuntu

[Warning]
The mount point directory /local/ubuntu must exist. There should be no files or subdirectories in the /local/ubuntu directory.
An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted.
The general syntax for the line in /etc/fstab file is as follows:

example.hostname.com:/ubuntu /local/ubuntu nfs rsize=8192,wsize=8192,timeo=14,intr

If you have trouble mounting an NFS share, make sure the nfs-common package is installed on your client. To install nfs-common enter the following command at the terminal prompt:
sudo apt-get install nfs-common


Windows NFS Connect
https://code.google.com/p/nekodrive/

Samba

sudo apt-get install samba samba-common
sudo apt-get install python-glade2
sudo apt-get install system-config-samba
To setup samba - GUI > System > Administration > Samba
sudo smbpasswd -a username (same as your desired share folder owner)

create ram drive

mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/

#edit /etc/fstab
tmpfs /tmp/ramdisk tmpfs size=256M 0 0

2012年12月9日星期日

install subclipse 1.8.x



1. search subclipse from eclipse markerplace.

2. apt-get install libsvn-java


3. modify eclipse.ini.  add the below red line.  (source)

-showsplash
org.eclipse.platform
-framework
plugins/org.eclipse.osgi_3.4.0.v20080605-1900.jar
-vmargs
-Djava.library.path=/usr/lib/jni
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m



if it shows "incompatible javahl library loaded. 1.7.x or later required."

Remove your existing libsvn-java:

sudo apt-get purge libsvn-java
Then, add the following software source and re-install:

sudo add-apt-repository ppa:dominik-stadler/subversion-1.7
sudo apt-get update
sudo apt-get install libsvn-java
(source)