Friday, December 4, 2009
How to rsync without prompting for password
On host_a, run this command
$ ssh-keygen -t rsa
This will prompt for path for public key and a passphrase. Just press the enter key. It'll then generate an identification (private key) and a public key. The public key by default will save in ~/.ssh/id_rsa.pub
$ ftp host_b
$ ftp > put .ssh/id_rsa.pub
public key will copy to home folder
$ ftp > bye
$ ssh to host_b
$ cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys
DONE !!
You can try to rsync, no password will be prompted!!
Thursday, October 8, 2009
Generate .lib from 3rd party DLL without .lib file
2. List down all the function in anydll.dll with following command
dumpbin /exports C:\path\to\anydll.dll
3. Build .def by copy all the function into the anydll.def
the definition must start with EXPORTS
eg.
EXPORTS
anydll_function1
anydll_function2
......
3 Generate the lib file
lib /def:C:\path\to\anydll.def /out:C:\path\to\anydll.lib /machine:x86
Wednesday, September 9, 2009
How know which files are modified with svn update and awk
To check the files which been modify, we can use following command
svn status | awk '$1 ~ /M/'
Thursday, August 13, 2009
check process memory usage in unix
ps -eo pid,ppid,vsz,rss,pcpu,pmem |grep pid
In linux
ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd | grep pid
Wednesday, July 22, 2009
How to decode the tag id from IS41 Map parameter protocols specification
if IMSI tag is
1 0 0 1 1 1 1 1
1 0 0 0 0 0 0 1
0 1 1 1 0 0 1 0
Decode
1 0 (CS) 0 (primitive) 1 1 1 1 1 ( tag > 31 )
1 (extension) 0 0 0 0 0 0 1
0 (no extention)1 1 1 0 0 1 0
So the value of IMSI tag will be 1 1 1 1 0 0 1 0 = 242
Wednesday, June 24, 2009
How to create and remove a unix soft link
A symlink can be created like:
ln -s /path/ linkname
from the ln man pages:
ln [OPTION]… [-T] TARGET LINK_NAME (1st form)
-s, –symbolic
make symbolic links instead of hard links
to remove a symlink
rm linkname
You can't update the soft link to point to other target path, you must delete the soft link first and recreate it
Tuesday, June 9, 2009
C preprocessor use for replace string by '##'
eg.
#include "stdio.h"
void func_replace(){printf("func_replace is called\n");}
#define REPLACE_FUNC(A) func_##A()
void main()
{
/*func_replace will be invoked*/
REPLACE_FUNC(replace);
}
Wednesday, June 3, 2009
SS7 point code converter
#include "stdio.h"
#include "string.h"
int main()
{
char buffer[200];
int point_code;
int point_code1,point_code2,point_code3;
int convertion_type;
while(1)
{
printf("please enter converted format \n"
"0 - quit \n"
"1 - [3-8-3] -> hex \n"
"2 - [8-8-8] -> hex \n"
"3 - hex -> [3-8-3] \n"
"4 - hex -> [8-8-8] \n");
gets(buffer);
sscanf(buffer,"%d",&convertion_type);
if(buffer[0]=='q')
{
printf("app exit\n");
}
switch(convertion_type)
{
case 1:
//eq - 0x2044
//0010000001000100
//--100 00001000 100
//4-8-4
printf("enter your point code [3-8-3]\n");
gets(buffer);
sscanf(buffer,"%d-%d-%d",
&point_code1,&point_code2,&point_code3);
point_code = (point_code1<<11) point_code =" %x\n" point_code =" (point_code1<<16)" point_code =" %x\n" point_code1 =" (point_code">>11)&0x00000007;
point_code2 = (point_code>>3)&0x000000ff;
point_code3 = (point_code)&0x00000007;
printf("point_code = %d-%d-%d\n",point_code1,point_code2,point_code3);
break;
case 4:
printf("enter your point code [Hex]\n");
gets(buffer);
sscanf(buffer,"%x",&point_code);
point_code1 = (point_code>>16)&0x000000ff;
point_code2 = (point_code>>8)&0x000000ff;
point_code3 = (point_code)&0x000000ff;
printf("point_code = %d-%d-%d\n",point_code1,point_code2,point_code3);
break;
}
}
return 0;
}
precompiled version of point code converter can be downloaded here
pc_convertor
Saturday, May 23, 2009
Using pscp to transfer file
pscp username@host:./file .\file
or with private key
pscp -i "private_key" username@host:./file .\file
To transfer file from windows to unix
pscp .\file username@host:./file
Wednesday, May 20, 2009
Delete string vector item with find_if function
however, this function normally only support primitive, to support custom type we may need to supply own user function, below code show us how build the custom function.
// functional_bind1st.cpp
// compile with: /EHsc
#include <vector>
#include <functional>
#include <algorithm>
#include <iostream>
#include <strstream>
using namespace std;
class strequal
{
public:
strequal(char* ptr)
{
strcpy(str,ptr);
}
bool operator() (string& ptr)
{
if(!strcmp(str,ptr.c_str()))
{
return true;
}
else
{
return false;
}
}
private:
char str[100];
};
int main()
{
vectorv1;
vector::iterator Iter;
int i;
for (i = 0; i <= 5; i++)
{
string abc;
std::strstream abc_stream;
abc_stream << i << '\0';
abc = abc_stream.str();
v1.push_back(abc);
}
cout << "The vector v1 = ( " ;
for (Iter = v1.begin(); Iter != v1.end(); Iter++)
cout << (*Iter).c_str() ;
cout << ")" << endl;
char* data="1";
Iter = find_if(v1.begin(),v1.end(),strequal(data));
if(Iter!=v1.end())
{
v1.erase(Iter);
}
cout << "The vector v1 = ( " ;
for (Iter = v1.begin(); Iter != v1.end(); Iter++)
cout << (*Iter).c_str() ;
cout << ")" << endl;
return 0;
}
Wednesday, May 6, 2009
Delete item in vector iterator loop
for(iter = list.begin(); iter != list.end();++iter)
{
if(match(*iter))
{
list.erase(iter);
}
}
The correct way should be
for(iter = list.begin(); iter != list.end();)
{
if(match(*iter))
{
iter = list.erase(iter);
}
else
{
++iter;
}
}
or
list.erase(std::remove_if(list.begin(),
list.end(), match))
Tuesday, April 21, 2009
Upgrade open office from 2.4 to 3.0
First, remove your existing version of OpenOffice.org:
sudo apt-get remove openoffice*.*
Next, download a copy of OpenOffice.org 3.0 (OOo_3.0.1_LinuxIntel_install_en-US_deb.tar.gz worked for us) and extract the download:
tar -zxvf OOo_3.0.1_LinuxIntel_install_en-US_deb.tar.gz
That will create a directory called something like OOO300_m15_native_packed-1_en-US.9379.
Switch into the DEBS directory in that directory:
cd OOO300_m15_native_packed-1_en-US.9379/DEBS/
Now all you need to do is install all of those .deb packages:
sudo dpkg -i *.deb
That will do the trick. Once you’ve given your password your system should install all of the required files.
With that done you should have just one thing left to do: Install the desktop integration package. That should be in the DEBS folder:
cd desktop-integration
From that folder install the package:
sudo dpkg -i openoffice.org3.0-debian-menus_3.0-9354_all.deb
If everything works out you should be able to open OpenOffice.org 3.0 from the Applications menu on your desktop.
Monday, April 20, 2009
My essential open source application
http://www.getfirefox.com/
Web browser which replaces Internet Explorer
2. Thunderbird
http://www.mozilla.org/thunderbird/
Email client which replaces Microsoft Outlook.
3. OpenOffice
http://www.openoffice.org/
Office suite which replaces Microsoft office.
4. Vnc
http://realvnc.com
Remote administration tool for cross-platform.
5. Filezilla
http://filezilla.sourceforge.net/
Ttp client gui which used to replaces WinFTP
Saturday, April 18, 2009
How to add dell 640m wireless enable in ubuntu
STEP 1: CLEAN YOUR SYSTEM
remove any and all versions of Ndiswrapper that come installed by default on your system:
sudo rmmod ndiswrapper
sudo ndiswrapper -e bcmwl5
sudo apt-get remove ndiswrapper-utils
STEP 2: GET NEEDED PACKAGES
We'll need to install compiling tools (don't panic when you read that, just bear with me), the latest kernel headers, and then the source code for the latest ndiswrapper (seriously, don't panic. This will be very simple), and the wireless drivers from Dell.com.
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install linux-headers-`uname -r`
wget http://ftp.us.dell.com/network/R134881.exe
At this point, you need to go to the ndiswrapper sourceforge site and get the latest version of the Ndiswrapper program.
wget http://superb-east.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.54.tar.gz
Uncompress the ndiswrapper source (in my example, the file name is ndiswrapper-1.51.tar.gz):
tar -xzvf ndiswrapper-1.54.tar.gz
sudo echo blacklist bcm43xx >> /etc/modprobe.d/blacklist
sudo -s
echo blacklist bcm43xx >> /etc/modprobe.d/blacklist
exit
STEP 3: COMPILE PROGRAM
Now we'll complile the Ndiswrapper program. In a terminal, go to the directory where you extracted ndiswrapper and execute the following:
cd YOUR-NDISWRAPPER-DIRECTORY
sudo make uninstall
sudo make distclean
sudo make
sudo make install
STEP 4: INSTALL DRIVERS
If that worked, then you now have Ndiswrapper installed. Now we need to install the drivers. In a terminal, go to the directory where you have the R151517.EXE file:
unzip -a R134881.EXE
cd YOUR-DRIVER-DIRECTORY
sudo ndiswrapper -i w29n51.inf
sudo ndiswrapper -l
sudo ndiswrapper -m
sudo modprobe ndiswrapper
sudo echo ndiswrapper >> /etc/modules
sudo -s
echo ndiswrapper >> /etc/modules
exit
Your wifi light on your laptop should be illuminated, and you're all set! Try running this to see if your wireless card is functioning properly:
sudo iwlist scanning
STEP 6: Add wireless connection
Go to System-> Preference -> Network Configuration
In the Wireless tab add a new wireless connection.
This help is refer from
http://ubuntuforums.org/showthread.php?t=297092
Thursday, April 16, 2009
Linux service enable and disable on linux variant
1) Red Hat Method
# chkconfig httpd --add
# chkconfig httpd on --level 2,3,5This will enable the apache webserver to automatically start in the run levels 2, 3 and 5. You can check this by running the command:# chkconfig --list httpdOne can also disable the service by using the off flag as shown below:# chkconfig httpd off
# chkconfig httpd --delRed Hat also has a useful script called service which can be used to start or stop any service. Taking the previous example, to start apache webserver, you execute the command:# service httpd startand to stop the service...# service httpd stopThe options being start, stop and restart which are self explanatory.2) Debian Method
# update-rc.d apache2 defaults# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .And to disable the service in all the run levels, you execute the command:
# update-rc.d -f apache2 removeHere -f option which stands for force is mandatory.# update-rc.d apache2 start 20 5 . stop 80 0 1 2 3 4 6 .3) The old fashioned way# cd /etc/rc5.d/
# ln -s /etc/init.d/apache2 S20apache2lrwxrwxrwx 1 root root 17 Mar 31 13:02 S20apache2 -> ../init.d/apache2
# ln -s /etc/init.d/apache2 K80apache2If you have 'N' as the priority number for starting a service, you use the number (100-N) for the stopping priority number and vice versa.