Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, June 21, 2011

insert dynamic row in table using jquery

Today i came across a problem that requires to  add rows in table dynamically.

This can be done in an easy way with jquery, where as typical with writing all code in javascript.

hope it helps.

$('#buttonOrLinkId').click(function(){
$('#TableId tbody>tr:last').clone(true).insertAfter('#TableId tbody>tr:last');
});

Monday, June 13, 2011

How to delete .svn folder recursively on Linux or mac?

I came across a situatin where i needed to copy all the files ( svn commited ) from one project to another. but did not wanted to have .svn into new project, so looked for to delete all the .svn folder/files from new project set up.
I found the way to delete all .svn folder from my project folder in Linux.
To delete all .svn folder in Linux just follow the steps below:-

  • Start Terminal
  • change your current directory to your project folder (ex: /var/www/html/PROJECTNAME)
  • type [ check if the file list is proper to be sure :) ]
      find ./ -name ".svn"
  • type
    find ./ -name ".svn" | xargs rm -Rf
    and enter.
  • Done, all your .svn folder has been deleted.

Hope it helps

Friday, May 6, 2011

calculate long ip from Ip address - IP number from IP address - ip2number

Today, i came across to compare IP addresses and needed to have it stored in the long int as well. its also called IP number

Reason for storing values in long int  is that it would help to get the ip details like contry and location within its range.

Any IP address is divided into 4 parts. generally each parts has different weightage.

To calculate IP number for any IP address:

IP Number = 16777216 * A + 65536 * B + 256 * C + D

This way we can also get range of IP address.

so if we have IP address say 74.125.236.80 than 
IP Number = 16777216 * 74 + 65536 * 125 + 256 * 236 + 80 =  132406480

I have made a function to calcualte above IP number in PHP, hope its helpful

 Function To get  IP Number from IP Address to in PHP

function ip2numer($ipaddress=''){
      if ($ipaddress == "") {
         return 0;
     } else {
         $ips = split ("\.", "$ipaddress");
          return ($ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] *16777216);
     }
}

Tuesday, April 26, 2011

Nice symfony plugin for flash based grpahs

I came across to build flash based graph in symfony. Found a nice plugin available , easy to integrate and has good customistion

http://www.symfony-project.org/plugins/stOfcPlugin

In case, anyone needs any help or concern, feel free to post .

Have a good time!!!