Monday, October 31, 2011

optimize mysql with index

if you want to join large table, indexing may help.

table1: 30,000 rows
table2: 40 rows

indexing for example user ID may speed up select query

SELECT name, phoneNo, address FROM table1 INNER JOIN table2 ON table1.userid = table2.userid

with no index, query takes about 8second
but with index query only 0.4second

Wednesday, October 26, 2011

convert image into ASCII

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx




This is me in Color Mode


::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::
::::::::::::::::.::+**+:::::::::::::::::
:::::::::::::::#########*:::::::::::::::
:::::::::::::+#@#@@@@#####*+::::::::::::
::::::::::::*#@@@#####@@@@##+:::::::::::
::::::::::::#@@#+::::::+*@@##:::::::::::
:::::::::::#@@*:.......::+#@@:::::::::::
:::::::::::@@*::........::+@@*::::::::::
:::::::::::@#:::........:.:#@*::::::::::
:::::::::::@*+::..........:+@*::::::::::
:::::::::::@++::.........::+#*::::::::::
::::::::.::@++:..,....,..:::#+::::::::::
:::::::::.:@+++**+...:+++:::#:::::::::::
::::::::::.@+++:+++.::+:+,::#.::::::::::
:::.....::.#:+**#*::+:+#:**+#......:::::
........:.+#++++::+..:::::+:+++:....::::
.........:+++::.:.:..+:..:::+.+......:::
.........:+++:::+::..:....::+:+.........
..........++++:..:::..:...:+............
..........:+++::.:**+*:...:+:+..........
...........:++::.:::::...::+:...........
............:++::++++++::::::...........
.............+++***:::*+::::............
.............++++:+**+:::++.............
..............*+++:...::+++.............
..............**++:::::++++.............
..............****+++++**++.............
..............+***####***+:.............
..............#+********++:#............
..............#+:+*+++++::,##+..........
..........*###@,::++++::::,#####:.......
........#######,+:::::::+,,########+....
.....:#########:,::::::+ ,.#########*#+.
..:*#*########## ,:.::+ ,,*#############
*#*#############, ...:,.,,##############
*###############, ,::,.*, ##############
################,+*,.,,::,##############
################*.,.,, ,,:##############
#################  ,    ,###############
################# ,     .###############
#################       :###############
#################,      *###############
######@##########.,,    ################
######@##########*,,    ################
################## ,    ################
##################    ,,################
@######@##########   ,,+################
@######@########## ,,,,###########@#####
@@################,,,,,#################
@@################:,,,,################@
@@######@#########*,,,.##########@#####@
@@@#####@##########, ,+###############@@



This is me in black and white ;)




get yours at:
http://speedfinger.org/html/modules/ASCIIArtist/exe.php?image=http%3A%2F%2Fspeedfinger.org%2Fhtml%2Fmodules%2FASCIIArtist%2Fimages%2Fkatok02.jpg&resolution=2&mode=1&color#000000&font-size=11&line-height=9&letter-spacing=0&fixed_char=W&new_window=on

Sunday, October 16, 2011

Javascript (remove character outside bracket)

i want to extract some information from text
for example. My Name Is Abu (19) years old

final output is 19

searching thru i found this code


pattern = /([a-z]+)([0-9]+)([A-Z]+)([0-9]+)/;
subject = 'test1234TEST1234';
matches = subject.match(pattern);
match1 = matches[1];
match2 = matches[2];
match3 = matches[3];
match4 = matches[4];
alert(match1);
alert(match2);
alert(match3);
alert(match4);

this is near but cannot add spaces or bracket on regex search

finally i remove space using this code


bb = "AAA AAA AAA(asdasd0 )asdasd asdasd";alert(bb.replace(/[\(\) ]/g,""));



reference: http://lawrence.ecorp.net/inet/samples/regexp-format.php


Thursday, October 06, 2011

install rrdtool centos

ref: http://www.cyberciti.biz/faq/howto-install-rrdtool-on-rhel-linux/


Step # 1: Install required dependencies

Login as root and type the following command:
# yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel
Untar tar ball, enter:

Step # 2: Download latest rrdtool tar ball

# tar -zxvf rrdtool-1.3.1.tar.gz

Step #3: Compile and install rrdtool

You need to set PKG_CONFIG_PATH, enter:
# export PKG_CONFIG_PATH=/usr/lib/pkgconfig/
Type the following commands:
Now compile and install RRDTool on RHEL:
# ./configure
# make
# make install
# cd /usr/local/
# ln -s rrdtool-1.3.1/ rrdtool/
# cd rrdtool
# ls -l
Type the following commands:
# cd /opt/
# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz

Saturday, October 01, 2011

read LVM from windows

i want to recover old files from server to new disk



http://www.chrysocome.net/explore2fs - use explore2fs to read data

reference: http://www.coderchris.com/linux/how-to-mount-a-linux-lvm2-partition-in-windows/2008/02/10 and google

updates: this software not works. i'm using vmware player with centos and mount using this

To mount xen guest image (with lvm)

1. Check the partition on the image
# fdisk -lu /path/to/image

2. You have to install kpartx to handle lvm partiton
# yum install kpartx

3. Run kpartx on the image
# kpartx -av /path/to/image

4. Run vgscan to scan volume group available
# vgscan

5. Run vgchange to activate the volume group in the image
# vgchange -ay VolGroup00

6. Use lvs to see what is the name of your low volume group
# lvs

7. Mount the low volume group
# mount /dev/VolGroup00/LogVol01 /mnt

8. You can access your lvm image at the mounted directory which is /mnt

9. To unmount it, a few commands have to be executed (umount for unmounting, vgchange -an to deactivate volume group, kpartx -d to delete device map and losetup -d to delete loop device used)
# umount /mnt/

reference: http://linuxwave.blogspot.com/2008/02/accessing-data-on-xen-lvm-guest-image.html

4gb seg fixup after reformatting


[root@linux ~]# rpm -q glibc.i386
glibc-2.5-65
[root@linux ~]# rpm -q glibc.i686
package glibc.i686 is not installed

it works as expected. now production server works but files gone. hope to get files back using backup disk.
Related Posts Plugin for WordPress, Blogger...