Today I will show simple, but simetimes very usefull example, how to remove empty paragrapth from your text.

My code:

<?php
$html = "abc<p></p><p>dd</p><b>non-empty</b>";
$pattern = "/<p[^>]*><\\/p[^>]*>/";
//$pattern = "/<[^\/>]*>([\s]?)*<\/[^>]*>/";  use this pattern to remove any empty tag

echo preg_replace($pattern, '', $html);
// output
//abc<p>dd</p><b>non-empty</b>
?>

Very simple 🙂

I recently had a hard drive go bad on me which actually turned out to be a hard drive going bad. There was definitely something goofy going on with access to the drive. I keep daily backups but a perfect backup of a corrupted source is no good. My most important files are my digital photos, mostly JPG images. I did some visual spot checking but once I hit the 1500 photos I looked for a better alternative. Here’s what I came up with. (This works on Linux. You’ll have to alter your process on Windows and Macs but the principles are the same.)

Continue reading

Currently, on the internet world are a lot of data. Very important is how and where to store them. Therefore, I decided to study database mongodb. MongoDB (from “humongous”) is a scalable, high-performance, open source NoSQL database. Written in C + +, MongoDB features:

Continue reading

At grub-boot loader screen select Recovery mode the version of the kernel that you wish to boot and type e for edit. Select the line that starts with kernel and type e to edit the line.

Go to the end of the line and type init=/bin/bash as a separate one word (press the spacebar and then type init=/bin/bash). Press enter key to exit edit mode.

Back at the GRUB screen, type b to boot into single user mode. This causes the system to boot the kernel and run /bin/bash instead of its standard init. This will allow us gain root privileges (w/o password) and a root shell.

If you wanna reset root password remount paritions
Code:
mount -rw -o remount /
Setup root password

Code:
passwd

Some days ago I have a problem with my server and all my innodb tables were locked. And now I want to tell, how I tried to repair these tables.

First of all, I tried to do force recovery. In mysql config file enable force recovery. Set innodb_force_recovery = 1 and try to do mysqldump. If it not work, try to increase innodb_force_recovery value to 6. Default innodb_force_recovery value is 0. After you change innodb_force_recovery value, restart mysql.

Continue reading

One more product using google API. It is google analytics based counter. With help of this service you can show page statistic for all your visitors counter image or full visits graph. Statistic data is collected directly from google analytics, using it’s API.

Continue reading