KLog

September 17, 2008

Some must-have add-ons for Mozilla Thunderbird

Filed under: Misc tips — hwkang @ 3:45 pm

1. Remove Duplicate Messages(Alternate)
2. Thunderbird Message Filters Import/Export
3. Simple Search-for Extension

September 10, 2008

How to download a Youtube video & extract video frames from it

Filed under: Misc tips — hwkang @ 6:04 pm

1. Install Mozilla Firefox VideoDownloadHelper

https://addons.mozilla.org/en-US/firefox/downloads/file/34137/video_downloadhelper-3.2-fx.xpi

2. Install SUPER © to decode and convert flv files you get to whatever format you want

http://www.erightsoft.com/SUPER.html

3. You can use any video editing  program to extract the video frames

September 4, 2008

Build executable from Python scripts

Filed under: Misc tips — hwkang @ 8:41 pm

I found it necessary to build executable from my Python scripts(since Maui/Torque cluster does not support submit Python as jobs.)

1. Install python2.5-examples and python-dev

apt-get install python2.5-examples

apt-get install  python-dev

2. Use freeze.py coming  along with python2.5-examples(/usr/share/doc/python2.5/examples/Tools/freeze/freeze.py)

freeze.py hello.py

make

July 26, 2008

Setting up Samba server

Filed under: Misc tips — hwkang @ 3:02 pm

http://www.linuxforums.org/forum/linux-tutorials-howtos-reference-material/54415-fileserver-samba-printserver-cups-howto.html

http://oreilly.com/catalog/samba/chapter/book/ch09_01.html

July 22, 2008

How to increase VMWare preallocated disk space

Filed under: Misc tips — hwkang @ 5:02 am

Problem: my Ubuntu image comes with pre-allocated 8GB disk space.  More space needed to keep up with growing programs

Solution: using vmware-vdiskmanager,  from VMWare WorkStation.

1. go to Windows command line

2. vmware-vdiskmanager -x sizeGB file.vmdk

3. fire up VM Player (or VM WorkStation)

4. install gparted if not already installed

5. start gparted, and you’ll see a unallocated partition.

6. create a new partition from the unallocated one.

7.  Edit /etc/fstab so that the new partition mounts automatically at boot time

July 19, 2008

Install OpenCV with FFMPEG Step by Step

Filed under: Misc tips — hwkang @ 3:22 pm

1) Download ffmpeg:

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

2) Install ffmpeg:

cd ffmpeg

./configure –enable-shared

make

make install

mkdir /usr/local/include/ffmpeg

cp /usr/local/include/libavcodec/*.h /usr/local/include/ffmpeg

cp /usr/local/include/libavdevice/*.h /usr/local/include/ffmpeg

cp /usr/local/include/libavformat/*.h /usr/local/include/ffmpeg

cp /usr/local/include/libavutil/*.h /usr/local/include/ffmpeg

3) configure and install opencv-patched

./configure –enable-apps –enable-shared –with-ffmpeg –with-gnu-ld –with-x –without-quicktime CXXFLAGS=-fno-strict-aliasing CFLAGS=-I/usr/local/include CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib

make

make install

July 7, 2008

extra qualification in C++

Filed under: Misc tips — hwkang @ 5:54 pm

It’s a problem of some older C++ code.

e.g.

class Foo

{

Foo::fun();

} ;

Here Foo:: has to  be removed because it is an over-complete constraint on fun().

Example:  compiling QuickNet v3_20 will result in the following errors,

QN_fir.h:116: error: extra qualification ‘QN_InFtrStream_FIR::’ on member ‘FillDeltaFilt’
QN_fir.h:118: error: extra qualification ‘QN_InFtrStream_FIR::’ on member ‘FillDoubleDeltaFilt’

Solution:  remove ‘QN_InFtrStream_FIR::’

June 28, 2008

Useful Linux command

Filed under: Misc tips — hwkang @ 3:15 pm

lshw: list hardware information snapshot

———————-

cat /proc/version: show the Linux version

———————-

rm`ls -1 | grep -v ‘precious$’ | xargs` -rf

: remove all files/folders in current directory except ‘precious’; ls -1 list all in a column; -rf removes without confirmation

———————-

rm -i `ls -1 | grep -v ‘\.abc$’ | grep -v ‘\.xyz$’ | xargs`

: remove all files in current directory except files with extension ‘.abc’ or ‘.xyz’; -i prompts for confirmation for each deletion

———————-

rm `find | grep .ext | xargs`

: remove all files with extension’.ext’, in current folder and all subfolders.

———————-

useful gcc debug options:

`-print-search-dirs’
: Print the name of the configured installation directory and a list of program and library directories gcc will search–and don’t do anything else.

———————-

mount remote directory

sudo apt-get install sshfs

sudo modprobe fuse

sudo adduser username fuse

sudo chown root:fuse /dev/fuse

sudo chmod +x /dev/fuse(rmout?)

logout and login again

mkdir ~/remoteserv

sshfs username@ipaddress:/remotepath ~/remoteserv

———————-

show size of folders
du –max-depth=1 “somedir” | sort -n -r
du -h –max-depth=1 “somedir”
———————-
count the number of files in a certain folder:
ls “somedir” | wc -l
———————-
ldd “some_binary”
: list the dependency for “some_binary” file. It’s very useful to correct some mis-linked libraries.
———————-
remove a long list of files.
rm is the most frequently used command to remove a bunch of files, however, sometimes we would see this message “rm: Argument list too long”. What I would guess is the way ‘rm’ is implemented is that it first creates a list of file names with string and then iterates through the list to delete each file. Therefore, it’s reasonable to set an upper-bound.
A good workaround, I found from google is : find <some dir> -name “<some pattern>” -print | xargs rm
Before you use this command, run this first to check if they are actually the files you are looking for: find “some dir” -name “some pattern” | more
———————-

Add user access to afs directories(could be used for cvs project sharing)

fs sa <directory> <username> <permission>

fs la: to list access information

to remove someone’s access and recursively:

find . -type d -print | xargs fs setacl -acl <username> none -dir

———————-

Shell for statement

e.g.

for ((i=1; i<1000; i++))

do

qdel $i

done
———————-
# rename every *.htm file *.html
for f in *htm ; do mv $f `basename $f htm`html; done”
———————-

List only directories:

ls -d */

———————-

Redirecting stdout and stderr to file:

1) stderr to file:

e.g. foo 2> file.out

2) stdout to file:

e.g. foo > file.out

3) stdout and stderr to file:

e.g. foo &> file.out

———————-

A link to some handy commands(will update to my list when tried each):
http://www.daniweb.com/forums/thread1743.html

June 20, 2008

Getting raw char array from a string

Filed under: Misc tips — hwkang @ 5:56 pm

string str=”I am a string”;

char chr[256]=”" ;

strcpy(chr, str.c_str());

mkdir, cp, mv in C/C++

Filed under: Misc tips — hwkang @ 5:55 pm

#include <sys/stat.h>

#include<sys/types.h>

int mkdir(const char *pathname, mode_t mode);

note 1. definition of mode:

sequence: owner, group, others

4=read, 2=write, 1=execute -> 3=wx, 5=r-x, 6=rw, 7=rwx

e.g. 0700, grants the owner read, write, execute privilege while exclude group and other users.

note 2.

The final mode of the folder depend on a variable called “umask” , and

final_mode = input_mode & ~umask

e.g.

normally umask = 0022 , which exclude group and other users from writing the folder(file)

therefore: putting 0666, actually with result in 0666 & ~0022 = 0644

<< Update on Oct 30, 2008>>

I just found there’s still problem in there.  I set all the permission like the following:

mkdir(somedir, 777);

The actually permission was set to: r—-x–x

Instead, I found I have to do this:

#define MY_MASK 0777

int temp;

printf(“Default mask: %o\n”, MY_MASK & ~022 & MY_MASK);

temp = umask(0);

printf(“Previous umask = %o\n”, temp);

mkdir(sub_match_dir, MY_MASK);

Next Page »

Powered by WordPress