Monthly Archives: October 2013

Include JQuery UI framework from Google libs

Code snippet to include JQuery UI framework from Google libs

<script src=""></script>
<script src=""></script>
<link href="" rel="stylesheet" type="text/css"/>

How to make round corners by css

How to create round corners by css

Create class in css file like follows

.curved-5px {

Assign the class to any html element like here

<div class=’curved-5px’>
Blah! Blah! Blah!

Bonus: Drop shadow

.gray-shadow {
-moz-box-shadow: 2px 2px 2px #cccccc;
-webkit-box-shadow: 2px 2px 2px #cccccc;
box-shadow: 2px 2px 2px #cccccc;

Upload file and change permisions in right way

		if(! move_uploaded_file($file['tmp_name'], $this->full_name ) )
			throw new Exception("Error to save the file {$this->full_name}");
		$oldumask = umask(0);
		if( ! chmod( $this->full_name, 0755 ) ) 
			throw new Exception("Error to set permissions for the file {$this->full_name}");	

How to impose maxlength on textArea using JQuery

How to impose maxlength on textArea using JQuery

$(function() {

// Get all textareas that have a “maxlength” property.
$(‘textarea[maxlength]‘).each(function() {

    // Store the jQuery object to be more efficient...
    var $textarea = $(this);

    // Store the maxlength and value of the field.
    var maxlength = $textarea.attr('maxlength');
    var val = $textarea.val();

    // Trim the field if it has content over the maxlength.
    $textarea.val(val.slice(0, maxlength));

    // Bind the trimming behavior to the "keyup" event.
    $textarea.bind('keyup', function() {
        $textarea.val($textarea.val.slice(0, maxlength));



Best solution

window.onload = function() {
var txts = document.getElementsByTagName(‘TEXTAREA’)

for(var i = 0, l = txts.length; i < l; i++) {
if(/^[0-9]+$/.test(txts[i].getAttribute("maxlength"))) {
var func = function() {
var len = parseInt(this.getAttribute("maxlength"), 10);

if(this.value.length > len) {
alert(‘Maximum length exceeded: ‘ + len);
this.value = this.value.substr(0, len);
return false;

txts[i].onkeyup = func;
txts[i].onblur = func;


Recursive delete folders and subfolders

public function remove_dir($dir_name_based_on_script)
$dir_name_to_remove = dirname( $_SERVER['SCRIPT_FILENAME']) . ‘/’. $dir_name_based_on_script;

* Delete a file or recursively delete a directory
* @param string $str Path to file or directory
private function recursiveDelete($str){
return @unlink($str);
$scan = glob(rtrim($str,’/').’/*’);
foreach($scan as $index=&gt;$path){
return @rmdir($str);