Wednesday, June 26, 2013

Differents between rand() / mt_rand () in PHP

rand() :

          Slow process, max allowed length smaller than mt_rand(), may has dubious or unknown characteristics, can get max limit by getrandmax(), using old technique.

          Syntax:  int rand(min,max);
          Example: echo rand(0,500);         // return value between 0 to 500 (including 0 and 500)

mt_rand():

         Four times faster than rand(), had large max length, return known characteristics, can get max limit by mt_getrandmax().

          Syntax:  int mt_rand(min,max);
          Example: echo rand(100,99999);         // return value between 100 to 99999

Conclusion:

          In my point of view mt_rand() is better than rand() in any cases.

Tuesday, June 18, 2013

Get array input value in jquery

//js file

var tmp_array=new Array();
 $('input[name="search\\[\\]"]').each(function(){
tmp_array.push(this.value);
});

Wednesday, June 12, 2013

முதல் காதல், முடியாத அத்யாயம்

source: http://kakkaisirakinile.blogspot.in/2012/09/blog-post_2720.html

முதல் காதல், முடியாத அத்யாயம் 

மாலை 3 மணி...


இன்று திருமணமாகி நாளையே

குழந்தை வேண்டும் - என
எப்போதும் கேட்கும் client
இப்போதும் கேட்டான்
பொழுது விடிவதற்குள் 
ப்ராஜெக்ட் வேண்டுமென..

அடித்து பிடித்து முடித்து கொடுத்து
அண்ணாந்து பார்த்தேன்...

இந்த முறை,
ஓட்டப் பந்தயத்தில் தோற்றுப் போன 
பெரியமுள் ஒன்றைக் காட்ட,
சிறிய முள் இரண்டைக் காட்டியது..

சில அடிகள் அளந்து 
வெளியே வந்த நேரம்
லிப்ட் failure...

அடுத்தவனை நம்பாதே என 
அப்பா சொன்னது
அப்போது நினைவிற்கு வர..

பதினைந்தாவது மாடியிலிருந்து
பாதங்கள் படிகளை என்ன ஆரம்பித்தது..

களைப்பில், கண்கள் சொல்வதை
கால்கள் கவனிப்பதா யில்லை...

முட்டி மோதி முன் வாசல் அடைந்தேன்..

வீட்டிற்கு போக வண்டியேது மின்றி,
பாதங்கள், இரண்டு மயில் தூரம்
இன்னும் பாதயாத்திரை
செல்ல வேண்டியிருந்தது...

பயணத்தை தொடர்ந்தேன்..

வழியில்...

ஏழைக்கு கூலி தரும் எஜமான் போல
இரு வெள்ளை நாய்கள் எனை
விரோதமாய் பார்த்தது...

பூங்காவில் சில பூக்கள்
புன்னகையை அவிழ்க்க,
அதை கால் கடுக்க காத்திருந்து,
கண்ணடித்து காதலித்து கொண்டிருந்தது
அந்த கரண்ட் மரத்து கண்ணாடி விளக்கு..

பனித்துளி சில மலைதுளியாகி
என் உடலோடு உறவாடிக்
கொண்டிருந்தது...

திடீரென.. 
எங்கோ இடி விளுந்ததாய் ஒரு சத்தம்..

கண்ணுக் கெட்டும் தூரத்தில்,
காரிருள் நிறத்தில், 
கவிழ்ந்து கிடந்தது
அந்த கார்..

தடம் புரண்ட தண்டவாளமாய்
தவறி நடந்த கால்கள்,
சாரப் பாம்பின் வேகத்தில்
சீறிப் பாய...

சில நொடிகளில் கண்டேன்...

பாதி நினைவில்.,
கை முறிந்த நிலையில்
காருக்கு வெளியே அவன்..

நினை விழந்த மழலையாய்,
உடைந்து விழுந்த சிலையாய்
கார் கண்ணாடி ஓரத்தில் அவள்...

இதை கண்கள் கண்டதும்,
என் இதய துடிப்பின் ஓசையை
ஒவ்வொரு நரம்பும் எடுத்துச்
சொல்லியது...

உதவி வேண்டி உரக்கக்
கத்தினேன்...

கேட்க ஆள் எவருமின்றி
கேட்டது எனக்கு மட்டும்...

மனம் புயலுக்குள் சிக்கிய
பூவாய் தவிக்க,

ஆம்புலன்ஸ் என்னைத் தேடி
என் அழைப்பு அலைக் கற்றையாய்
பறந்தது போனது..

அரை மணி நேரத்தில்
வண்டியும் வந்தது..

ஒருபுற படுக்கையில் அவன்.
மறுபுறம் அவள்..
ஓரத்தில் உட்காந்து
கொண்டேன் நான்...

சுத்தமான காற்று இருந்தும்,
அவளுக்கு சுவாச காற்று
தேவைப் பட்டது...

தலை சற்று சருக்கவே,
அவளை தாங்கிக்கொள்ள 
மடி கொடுத்தேன்...

சைரன் பறந்தது...

*பௌர்ணமி நாளில்
மடியில் ஒரு நிலவு...*

அந்த நிலவிற்கு துணை
கோளாய் நெற்றிப் பொட்டு..

சண்டையிட்டுக் கொள்ளாத,
இரண்டு வில், இரண்டு அம்பு.
அவள் புருவமும் விழிகளும்..

அடர்ந்த காட்டுக்குள்,
அரவணைக்கும் 
ஒற்றையடிப் பாதையாய்
அவள் உச்சந்தலை வகிடு..

அதைப் பாதுகாக்கும் பூட்டாய்
நெற்றியில் ஒரு பொட்டு...

பூக்கடையில், பூவிற்கு 
தெளிக்கப் பட்ட தண்ணீராய் 
வியர்வைத் துளி..

குயிலின் நிறத்தில்,
மின்னும் மயில் தோகையின் 
நீளத்தில் கூந்தல்..!

இந்த காட்சிகள் என் கடந்த கால
காதலை கண்ணில் காட்டியது..

என்னோடு சிரித்துப் பேசிய பூக்கள்..
Bye என்று அவள் சொல்லிச் சென்ற பூங்கா..

அவள் அதைச் சொன்னதும்,
வலியில் துடித்த விழிகள்,
வெளியில் கூட சொல்லிக் 
கொள்ள வில்லை...

உளி அடித்து பிறந்த வழியை,
சிலை ஊராருக்கு என்று சொல்லியது..!?

உண்மையைச் சொன்னால்...

என் காதல் காவிரியாகவும்,
அவள் காதல் கடலாகவும்
இருந்தது - அந்த
அமெரிக்க மாப்பிளை
ஆட்டத்தைக் கலைக்கும் வரை..

அது,
திருமணமாகாத அமெரிக்க மாப்பிள்ளைகள்
எனக்கு தீவிரவாதிகளாக தெரிந்த காலம்.

அடுத்தவன் காதலியை
கொத்திச் செல்லும் இவர்களுக்கு
கருட புராணத்தில் தண்டனை
உண்டா ? - என 
அம்பியிடம் கேட்டு, 
அந்நியனிடம் முறையிட நினைத்த காலம்..

ஆனால் எனை ஏமாற்றிச் சென்ற
அவள் மீதி ஏனோ 
துளியளவும் துயர மில்லை...

ஹலோ, எனக்கு ஒன்று மில்லையே
என அருகில் இருந்த அவன் 
எட்டாவது முறையாக கேட்க,

நிகழ் காலத்திற்கு
நினைவுகள் திரும்பியது..

கட்டிய மனைவியை பற்றி
இதுவரை சற்றும் சிந்திக்காத
கல் நெஞ்சுக் காரனைக் கண்டு
ஆச்சர்யம் அருவியாய் கொட்டியது..

என் விரலில் ஏதோ ஊறுவதாய்
அறிந்து உற்று நோக்கினேன்..

அவள் தலையில் ரத்தம் கசிய,
அதைக் கண்டு நான் கத்திய வேகத்தில்,
கார் hospital வாசலை வந்தடைந்தது..

கருவேலங் காட்டு சில் வண்டின்
சத்தமாய் ICU அலறிக் கொண்டிருந்தது.

அவள் உயிரைக் காக்க 
அவர்கள் ரத்தம் கேட்க...

ஒரு பாவமும் அறியாத 
எனது O நெகடிவ் ரத்தம்,
HIV டெஸ்டுக்கும் கட்டுப் பட்டு,
அவள் உடலில் ஓட ஆரம்பித்தது..

மருத்துவர் 24 மணி நேரம் கெடு சொல்ல..

நான் வேண்டியவர்களுக்கு 
சொல்லி விட்டு,
தனிமையில் நடந்தேன்..

வீடு என்னை வரவழைத்தது.
கட்டில் ஒரு கை கொடுத்தது..

அன்று அந்த பூங்காவில்...

BYE என்று சொல்லி - என்
உயிரை ஊசியால் குத்திச்
சென்றவளின் உடலில்,
இன்று என் உதிரம் 
ஓடிக் கொண்டிருகிறது..

என் ஒவ்வொரு செல்களிலும்
இன்றும் வாழும் அவள் உயிர்,
எப்படியும் அவளை
உயிர்பிக்கு மென்ற நம்பிக்கையோடு...

கதவை மூடியது விழிகள்
வழிந்து விழுந்தது சில துளிகள்..

இது என் முதல் காதல்,
முடியாத அத்யாயம்..!

Friday, June 7, 2013

Make GIT on local

GIT basically used for listen our code changes in step by step. And we can revert back to any of these changes. This means  GIT does not totally backup our code for every changes, it just saving changes not all codes. From my point of view, this is the most short description for GIT.

For more clear details about GIT visit : http://git-scm.com/documentation

Now come to the point, We need to make GIT on local. GIT has one common stored are area where all our git data are saved. You may call this as GIT BARE REPOSITORY. And has one are more stored area which is used by programmer where they writing or changing coding. You may call this as GIT WORKING REPOSITORY.



Now you can understand our job easily, that is we need to make one GIT bare repository and more than one GIT working repository, and make a connection between them. That is changes on working repository need to saved or tracked in bare repository.

Reference: http://try.github.io/levels/1/challenges/1
(Most of the matter I noted follow are, learned from above link.)

Step 1: Make one directory for our whole work(called "git").

$ sudo mkdir git
$ sudo chmod 777 git (Changing file permissions. It may unnecessary)

Step 2: Make 'server' and 'client1' directory inside the folder "git".(Note: For only easy understanding I mentioned bare repository us 'server' and working repository us 'client1'. But there is no server and client in GIT.

$ cd git
$ sudo mkdir server
$ sudo chmod 777 server
$ sudo mkdir client1
$ sudo chmod 777 client1

Step 3: Setup 'server' folder as bare repository.

$ cd server
$ git init --bare

Output:
Initialized empty Git repository in /var/www/git/server/bare/.git/

Step 3: Setup 'client1' as working repository.

$ cd ..
$ cd client1
$ git init

Output:
Initialized empty Git repository in /var/www/git/client1/.git/

Step 4: Check status (Feel free to check status on any time, It not affect code.)

$ git status

Output:
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

Step 5: Make one index.html file in 'client1'.  Content of index file is follows

<html>
<head>
<title>Git Test</title>
</head>
</html>

Step 6: Again check status

$ git status

Output:
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# index.html
nothing added to commit but untracked files present (use "git add" to track)

Step 7: Now add this untracked file to stage. (Can check for "git status" after add to know file moved from untracked to stage)

$ git add index.html

Step 8: Now commit this add

$ git commit -m "first commit"

Output:
[master (root-commit) 3bdae52] first commit
 Committer: Ramasamy <ramasamy@dcmanilaptop-HP-430-Notebook-PC.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 9 insertions(+)
 create mode 100644 index.html

Step 9: This is important step so do carefully.

$ git remote add origin ../server/

//On above code 'origin' is a name of our repository. You can use anything. And last one is path to repository.

Step 10: Now push 'client1' datas to 'server'.

$ git push -u origin master

//Here origin is name of repository we made previously, and "master" is the name of  branch under repository. Default is pointing branch is "master". And "-u" used for remember current repository and branch name. So we need not give these when we push again.

Output:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 314 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To ../server/
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

You can make more clients like we made 'client1' and make connection and interaction with them.

Graphical and live Demo avail here: http://try.github.io/levels/1/challenges/1

Thats all... We successfully made GIT on local.






Wednesday, June 5, 2013

Custom attribute for html element

<a href="javascript:void(0);" detail="<?php echo $id; ?>" title="View" class="view">View</a>


Can access this via :
document.getElementById('view').getAttribute("detail");
OR
$(this).attr('detail');

Example:
<html>
<head>
<title>Custom Attribute</title>
</head>
<body>
<a href="javascript:void(0);" detail="1" title="Click to alert this id." class="view">Alert this id</a><br /><br />
<a href="javascript:void(0);" detail="2" title="Click to alert this id." class="view">Alert this id</a><br /><br />
<a href="javascript:void(0);" detail="3" title="Click to alert this id." class="view">Alert this id</a><br /><br />
<a href="javascript:void(0);" detail="4" title="Click to alert this id." class="view">Alert this id</a><br />
</body>
</html>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
$('document').ready(function(){
$('.view').click(function(){
alert($(this).attr('detail'));
})
})
</script>


Learn JavaScript - String and its methods - 16

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>String and it's methods - JS&l...