simple examples of how to

Monday, November 28, 2011

Launching xclock at remote using ssh

first, at remote enable accessing x from remote node by
remote$ xhost + remote-node

Then, at local, access remote using ssh (be sure X-forwarding is disabled)
then,

remote$ DISPLAY=:0 xclock



Deleting matching lines

in vim

:g/pattern/d

in sed

sed '/pattern/d' file


Monday, November 7, 2011

[Eclipse] If you encounter this error message

Cannot complete the install because one or more required items could not be found. Software being installed: Android Development Tools 15.0.0.v201110251216-213216 (com.android.ide.eclipse.adt.feature.group 15.0.0.v201110251216-213216) Missing requirement: Android Development Tools 15.0.0.v201110251216-213216 (com.android.ide.eclipse.adt.feature.group 15.0.0.v201110251216-213216) requires 'org.eclipse.wst.sse.core 0.0.0' but it could not be found

While installing android adt plugin, you probably missing a library with ssl.
So just try this.

$ sudo apt-get install openssl libssl-dev

[Eclipse] eclipse launching fails

Eclipse fails with the following logs.

!SESSION 2011-11-07 23:51:29.573 -----------------------------------------------
eclipse.buildId=M20100211-1343
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Command-line arguments: -os linux -ws gtk -arch x86

!ENTRY org.eclipse.osgi 4 0 2011-11-07 23:51:29.699
!MESSAGE Startup error
!STACK 1
java.lang.IllegalArgumentException: invalid qualifier: 44+drm33
at org.osgi.framework.Version.validate(Version.java:188)
at org.osgi.framework.Version.(Version.java:92)
at org.eclipse.osgi.framework.internal.core.Framework.initializeProperties(Framework.java:361)
at org.eclipse.osgi.framework.internal.core.Framework.initialize(Framework.java:196)
at org.eclipse.osgi.framework.internal.core.Framework.(Framework.java:157)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:286)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)

It seems eclipse does not take the kernel name with '44+drm33' as argument.
FYI, uname -r gives '2.6.32.44+drm33.19'

Fortunately there is a thread about this bug in Ubuntu

https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/600584


[Java] useful java gui libraries

swt, jface

If you write your GUI code with swt, the results will be the same as the GUI of host machineOS whatever the OS is.


[Ubuntu] How to setup network interface

You can modify the interface script which is /etc/network/interfaces

In case you want to set static IP, example

$ cat /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 203.237.53.112
netmask 255.255.255.0
gateway 203.237.53.254


in command line, it has the same effect of
$ sudo ifconfig eth0 203.237.53.112/24
$ sudo route add default gw 203.237.53.254

In case you want to set DHCP

$ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp


in command line, it has the same effect as follows
$ sudo dhclient eth0


[Linux] killall by shell script

As the another example of using xargs, you can do the following if your linux box does not have killall.

$ ps ax | grep killme-process | awk '{print $1}' | xargs kill

The above command files the process, killme-process, and kills it.
The chain of pipelining is the following.

First, ps ax gives all the name of processes where the first column is the process ID.
Second, grep killme-process finds the processes with the name, killme-process.
Third, awk only prints the first column ($1) which is the process ID.
Fourth, xargs turns the list of process IDs as the input arguments of kill.
Finally, kill kills them.


Sunday, November 6, 2011

[Linux] How to delete selected files in all subdirectory

Let's assume you want to delete the files with the name 'deleteme.dat' that reside several parts in the subdirectory.
Then, what you should do is the following

$ find . name deleteme.dat | xargs rm

where xargs changes the standard out as the argument of the command rm.
By default, the argument is placed as the last argument of the command.
In order to change the position of the argument, you can do the following.

$ find . name moveme.dat | xargs -I '{}' mv '{}' /tmp

The above command moves the found moveme.dat to /tmp folder. the -I '{}' means the indicator of the argument and you can place it the position you want.



[Linux] How to upgrade linux kernel

1. Downloading Linux kernel source

You can find Linux kernel source code in https://github.com/torvalds/linux.
In this github, you can browse, trace the history of changes, etc.

In order to download the source code, you need to install git.
For instance in ubuntu, try
$ sudo apt-get install git-core

Then,
$ git clone https://github.com/torvalds/linux.git

2. Configuring, Compiling, and Installing

In the top folder of the source code (for instance, linux-2.6.32), in order to use the configuration of the current Linux kernel, try this
$ cp /boot/config-
.config

Then, try
$ make menuconfig

in the text-based GUI, you can find a button in the below that "load configuration from .config".
This will looad the configuration of your current kernel into the download kernel source code.

Then, try
$ make && make modules && make modules_install && make install

the above sequence of commands will compile the kernel, modules, and install the modules and install the kernel. At this step, the kernel installation is onlyfor vmlinuz but not for the initrd.
In order to install initrd, try the following.
$ update-initramfs

This command will automatically find the missing part of initramfs in /boot folder and install the missing part.

Then you need to update-grub to apply the changes in the grub.
$ update-grub

That is all. Reboot now.

You will see the new kernel in the grub while booting.


[Android] How to compile wpa_supplicant in AOSP

By the way, AOSP stands for Android Open Source Project,
http://source.android.com/

Once you follow the tutorial in AOSP, you can get the source of android platform, etc.
You can find various sources in external/ folder and if you want to compile, for instance wpa_supplicant, you can modify

You can change
WPA_BUILD_SUPPLICANT:=true in external/wpa_supplicant/Android.mk file

and try make in the top directory.

Thursday, November 3, 2011

[Linux] whiptail simple example

Simple whiptail example.

#! /bin/bash
if (whiptail --title "PPP Configuration" --backtitle "Welcome to SEUL" --yesno "
Do you want to configure your PPP connection?" 10 40 )
then
echo -e "\nWell, you better get busy!\n"
elif (whiptail --title "PPP Configuration" --backtitle "Welcome to
SEUL" --yesno " Are you sure?" 7 40)
then
echo -e "\nGood, because I can't do that yet!\n"
else
echo -e "\nToo bad, I can't do that yet\n"
fi



Credit goes to http://archives.seul.org/seul/project/Feb-1998/msg00069.html

Wednesday, November 2, 2011

[Ubuntu] ccache

compiler caching for gcc, g++

here goes an example

$ sudo apt-get install ccache

$ PATH=$PATH:/usr/lib/ccache

next time you compile with gcc, g++, it is faster

[Error] Package sun-java6-jdk is not available, but is referred to by another package.

Ubuntu 11.10 (Oreinic)

If this error happens, just follow this.

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

# note that we use lucid repo, although we use oreinic, it works for me anyway

then

$ sudo apt-get update

$ sudo apt-get install sun-java6-jdk

[Linux] screen simple how to by example

Assume you have 'a remote' and 'a local'.

At the remote, you access via ssh and launch 'screen -S test'.
Then, you will see a terminal-look which is no difference, but in background, there are lot of difference.
First, this terminal-look is not the ssh session that you connect but the session stored in the remote itself (i.e., screen session).
The difference is that although the ssh session dies unexpectedly, screen session does not die.

You can whenever connect this session by screen command.
Here are the most frequently used screen commands

screen -S test (create a new screen session named as 'test')
screen -ls (list the currently created screen sessions)
the results would look like this

16373.test1 (11/03/2011 10:29:08 AM) (Multi, detached)
15342.test2 (11/03/2011 10:30:08 AM) (Multi, attached)

Multi means that multiple attachments are possible.
Attached means that this session is already attached by someone.
If you want to join the attached session, you should use screen -x.
If you want to join the detached session, you should use screen -r.
For example

$ screen -r test1 #reattaching screen session
$ screen -x test2 #attach the currently attached screen session (it looks like a remote desktop of terminal version)
In order to use screen -x, make sure that it is Multi.

At the screen session, if you type 'exit' then the screen session quits.
If you just want to leave the session without quiting it, you type Ctrl+A and d.
it means Detaching from the current screen session.

[Latex] error ! I can't find file `pcrr7t'.

If you encounter the following error " ! I can't find file `pcrr7t'. " while you compile a tex in ubuntu, try this

sudo apt-get install texlive-fonts-recommended

then try again

[Ubuntu] Expanding workspace in Ubuntu 11.10

first install compizconfig-settings-manager

$ sudo apt-get install compizconfig-settings-manager

then

# for vertical size
$ gconftool-2 --type=int --set /apps/compiz-1/general/screen0/options/vsize 4
$ gconftool-2 --type=int --set /apps/compiz-1/general/screen0/options/hsize 4

[Linux] terminator restoring layout

Terminator version above 0.91

1) open up a terminator.

2) split the terminals the way you want

3) left click, and choose preferences

4) go to the layouts tab

5) at the left bottom, click add button

6) write a name for adding layout (for example, test)

7) now launch terminator at any terminal with the added layout
( e.g., terimnator -l test)


Tuesday, November 1, 2011

[Linux] Tip for assuring download file

In some projects, they give tutorials about how to download and install.
Some of them also provide with checksum (such as the following)

The SHA-1 checksum for repo is e1fd3bef059d152edf4d0522590725d317bc637f

you can easily verify the checksum by various sum binaries such as md5sum, sha1sum, etc

$ sha1sum bin/repo
e1fd3bef059d152edf4d0522590725d317bc637f bin/repo


it is useful in the sense that the downloaded file is not corrupted but also useful to find out that the downloaded file is right on track on without any further update on the project since fast evolving project, there could be un-noted changes which brings you to the hell of install and configuration bugs


[Android] services

racoon service: acoon speaks the IKE (ISAKMP/Oakley) key management protocol, to establish security associations with other hosts. The SPD (Security Policy Database) in the kernel usually triggers racoon.


drm service: stands for digital rights management for protecting contents.

dbus service: dbus (Desktop Bus) is a simple inter-process communication (IPC) open-source system for software applications to communicate with one another. An implementation of dbus supports most POSIX operating systems.

http://en.wikipedia.org/wiki/D-Bus

zygote service: this service half-initializes the android apps and if the android app is launching (e.g., clicked by user) the other half is initialized using zygote service.