PHP

Step by step moving from blogspot beta to wordpress blog

I do like blogspot except for few things :

  1. No categories, I’m familiar with label in gmail but not label in blogspot beta icon smile Step by step moving from blogspot beta to wordpress blog
  2. No timestamp modification, I do try to use “future posting” but it’s show as immediately in blogspot not waiting for right moment.
  3. Performancing can’t upload image with blogspot beta.

I think it’s enough for me to stay in blogpot, might be reconsider for other time when “beta” change into stable.

Searching in google for process moving from blogspot beta to wordpress blog make me afraid since no easy solution to do it. Until I found solution for easy moving from one link ( I forget the place). I try to post my way during transition from blogspot beta to wordpress blog.

read more »

Database

Top 10 SQL Performance Tips 5

“Have good SQL query standards”

Gee, seem easy to say but often difficult to deploy.

Many people tend to use abstraction layer like adodb, pear, ezsql etc . They have coding convention and good manual.

Portable SQL will lead on good application, seamless integration with other DB.

How about You?

Database

Top 10 SQL Performance Tips 4

“Use benchmarking”

Yes, big hit to database with not optimized configuration will make disaster and stress.

More reading related to benchmarking.

Stupid MySQL Benchmarking Lesson #153

MySQL Benchmarking

Database

Top 10 SQL Performance Tips 3

“increase temp table size in a data warehousing environment (default is 32Mb) so it doesn’t write to disk (also constrained by max_heap_table_size, default 16Mb)”

Data working faster in memory process not in disk write mode.

Nowadays many linux livecd distro created to gain that benefit, more memory more speed icon smile Top 10 SQL Performance Tips 3

in windows try to find this value on file named my.ini

Database

Top 10 SQL Performance Tips 2

Another tip :

“Don’t use DISTINCT when you have or could use GROUP BY”

I prefer to use GROUP BY than DISTINCT since I can retrieve more field.

SELECT DISTINCT town_name from city;

SELECT town_id, town_zip, town_name from city group by town_name;

the result also not quite accurate using DISTINCT, I still have duplicate data.

Keep learn, get new stuff icon smile Top 10 SQL Performance Tips 2

Database

Top 10 SQL Performance Tips I

mysql Top 10 SQL Performance Tips IToday Google show me interesting link :

Top 10 SQL Performance Tips – MySQL Forge

Right now it’s consist of 84 tips, I can understand some of them but many I don’t know what it means icon smile Top 10 SQL Performance Tips I

one of them :

“partition your database when you have real data”

Hmm, I’m totally agree

I have to mysql server that serve almost 2000 account (it’s huge for me)

By seperate the data directory, I can optimize input/output process, maintenance HD etc.

By doing symlink to special partition in unix server all hard work working seamlesly.

-bash-2.05b$ cd /var/db
-bash-2.05b$ ls -l
total 26118
drwx—— 2 operator operator 512 Nov 21 11:44 entropy
drwx—— 2 root wheel 512 Jan 11 2004 ipf
-r–r–r– 1 nobody wheel 12771235 Nov 18 04:30 locate.database
-rw-r–r– 1 root wheel 153183 Aug 23 17:52 mergemaster.mtree
-rw-r–r– 1 root wheel 0 Oct 27 2004 mountdtab
lrwxr-xr-x 1 root wheel 15 Aug 20 11:49 mysql -> /data2/db/mysql
drwxr-xr-x 3 nobody nobody 512 Feb 2 2005 ntop
-rw-r–r– 1 root wheel 13708288 Sep 5 06:55 pflog.db
drwxr-xr-x 133 root wheel 4096 Nov 18 08:56 pkg
-rw-r–r– 1 root wheel 9 Jan 11 2004 port.mkversion
drwxr-xr-x 28 root wheel 512 Nov 1 07:22 ports
drwxr-xr-x 2 root wheel 512 Oct 30 2005 portsnap

mysql folder symlink to /data2/db/mysql

PHP

PHP Ternary Operator

php PHP Ternary OperatorPHP ternary operator isn’t beautiful for reading reason

It’s also make confuse, but for the sake of simple it’s OK icon smile PHP Ternary Operator

Syntax :

( expr1 ) ? ( expr2 ) : (expr3)

If expr1 return true, then it evaluates to ( expr2 )
If expr1 return false, then it evaluates to ( expr3 )

it’s similar to if..else

if(true) {

code 1

}

else {

code2

}

example :

// ternary operator

$year=2006;
$james_bond_title = ($year==2006) ? “Casino Royale” : ” I forgot “;

echo “James Bond Movie Title in 2006 is : $james_bond_title”;

//if … else

if($year==2006){

$james_bond_title=”Casino Royale”;

}

else {

$james_bond_title=”I forgot “;

}

echo $james_bond_title;

Which one is your favorite ?

PHP

Recover Your Joomla Administrator Password

logo Recover Your Joomla Administrator PasswordJoomla is very popular CMS, it’s easy to setup and require only working php and mysql installation.

A problem may arise when your administrator password lost or forgot.

Can I recover my admin password or create a new one ?

It’s common question in "Setting your own Content Management System" workshop.

Use php md5() function !

Here’s the steps :

1. Open your php ide and type this code :

$my_new_password =’my_joomla_administrator_password’;
$my_md5_password=md5($my_new_password);
echo "My New Joomla Administrator Password is : $my_md5_password";

save this snippet as joomla.php and run it in browser.

2. Copy paste your md5 generated password.

3. Open phpmyadmin and select joomla database.

4. Select user table (jos_users) and find administrator entry, click edit icon.

edit Recover Your Joomla Administrator Password

5. Replace your password with password in step 2

edit2 Recover Your Joomla Administrator Password

6. Save your changes

edit3 Recover Your Joomla Administrator Password

7. Done, try login to administrator page with new password.

PHP

Year Validation with PHP

This code snippet validate user input from a form :

$year=strip_tags($year);

if(empty($$year) || is_numeric($year) || strlen($year)!=4 || $year

  1. strip all html tags ( handle by strip_tags )
  2. make sure the year in 4 digit (with strlen help)
  3. make sure its number not character (is_numeric)
  4. not empty (php empty function)
  5. force user enter year of birth not less than 1970

More information about those function, read php manual or search from php.net

PHP

Regex, nightmare for newbie

buddy Regex, nightmare for newbieRegex (Regular Expression) is nightmare for me, validation email, pattern recognizing task always depend on regex.

A few software out there will help us (newbie) to learn regex faster with “experience mentor”

I like these software :

1. Regexbudy
A lot of video demo
PHP section

2. Regexcouch
For medium level, since I’m totally newbie icon smile Regex, nightmare for newbie

Mastering regex book also helpfull, I just forgot the title, but in my amazon wishlist.

I just spend some money for openbsd books icon smile Regex, nightmare for newbie

Other good source :

PHP Manual on Regex Section

Happy learning icon smile Regex, nightmare for newbie

Speak

Performancing, blogspot beta and upload picture vi…

Still trying to upload picture to blogspot using API, trying both blogspot beta and wordpress and the result is :Blogspot beta : encounter error (fail to upload via API)

WordPress : success

I have try at home too :

Home :

Firefox 2.0 and performancing 1.3.5

Office :

Firefox 1.5.0.8 and performancing 1.3.5

Example