2012年12月22日 星期六

Ascii hex (IEEE754) 轉成 flaot in python

import sys
form binascii import unhexlify
s = unhexlify(sys.argv[1]) + unhexlify(sys.argv[2]) \
+ unhexlify(sys.argv[3]) + unhexlify(sys.argv[4])
import struct
result = struct.unpack_from('f', s)
print result[0]

2012年12月6日 星期四

Route setting under multi interfaces

The GATEWAY setting in ifcfg-eth0 will add a default gateway while interface starts, but may be overwrited by next started interface. To avoid this, remove the GATEWAY setting in ifcfg-eth0 and use route-eth0 file
Note. NetworkManager should be stopped

for Example, If there are two interface eth0 and eth1
ifcfg-eth0

DEVICE=eth0
IPADDR=10.3.23.221
NETMASK=255.0.0.0
#GATEWAY=10.3.23.254
ifcfg-eth1
DEVICE=eth0
IPADDR=172.18.101.2
NETMASK=255.255.0.0
#GATEWAY=172.18.254.254
route-eth0
default 10.3.23.254 dev eth0
route-eth1
172.16.0.0/12 via 172.18.254.254 dev eth1

2012年10月3日 星期三

Create a Package repo

1. create /var/pxe/centos6 directory
mkdir -p /var/pxe/centos6
2. mount iso and copy all files into /var/pxe/centos6 and create repo
cp -ivr /media/CentOS_6.3_Final/* /var/pxe/centos6
cd /var/pxe/centos6
createrepo .
3. create conf file /etc/httpd/conf.d/pxeboot.conf
Alias /centos6 /var/pxe/centos6
<Directory /var/pxe/centos6>
  Options Indexes FollowSymLinks
  AllowOverride None
</Directory>
4. Allow selinux httpd_sys_content_t
cd /var/pxe
chcon -R -t httpd_sys_content_t './centos6'
5. Restart httpd
service httpd restart
6. Open browser to check "http://127.0.0.1/centos6" is available Reference:
http://practical-tech.blogspot.tw/2011/10/how-to-configure-pxe-server-in-rhel-6.html
http://httpd.apache.org/docs/current/sections.html

2012年9月27日 星期四

Install RockMongo on Ubuntu

1. Install mongodb
follow the link below to install mongodb
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/


2. Install php5, php-pear
>apt-get install php5 php-pear

3. Install php-mongo
http://www.php.net/manual/en/mongo.installation.php

4. download rockmongo and the unzip and put in /var/www
http://rockmongo.com/downloads

5. restart apache2 mongodb
>service apache2 restart
>service mongodb restart
(If mongodb is locked, please check below link)
http://blog.brianbuikema.com/2011/01/mongodb-ubunto-overview-installation-setup-dev-python-2/


6. Login with admin/admin on http://localhost/rockmongo
(Modify config.php to change login username/password) 

2012年8月29日 星期三

Install mongodb on Ubuntu

1. import public key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
2. create /etc/apt/sources.list.d/10gen.list
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
3.
sudo apt-get update
4.
sudo apt-get install mongodb-10gen

Reference: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/

tsocks

1. install epel first
http://fedoraproject.org/wiki/EPEL
1. insatll tsocks
yum install tsocks
2. add file /etc/tsocks.conf
server = 127.0.0.1
server_type = 5
server_port = 1234
3. establish ssh tunnel
ssh -D 1234 user@xxx.remote.host
4. wget with socks proxy
tsocks wget http://get.something
5. you might want to unset the http_proxy variable
unset http_proxy