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
Related Posts Plugin for WordPress, Blogger...