Monday, December 16, 2013

Array in javascript - Basics

Declare an Array

var arr = new Array(); // Declaring an empty array.

var arr = [5,'sky blue','test']; // Simple array with custom values and default keys.
Structure: arr( [0] => 5,
                       [1] => sky blue,
                       [2] => test
                     );

var arr = [ {'id':23}, {'name':'green'}, {'category':'color'} ]; // Simple array with custom values and custom keys.
Structure: arr( [id]  => 23,
                       [name] => green,
                       [category] => color
                     );

var arr=[ {'id':23,'name':'green','category':'color'}, {'id':24,'name':'mango','category':'fruit'}, {'id':25,'name':'rose','category':'flower'} ]; // Multidimensional array with custom values and custom keys.


Access an Array

// Now consider arr is an array, which had we already created.

console.log(arr); // Display array in JavaScript console.

arr['new']='something'; // Add a new value with specific key.

arr.push('somemore'); // Add a new value with out specific key.

arr.pop(); // Remove last element from array.

arr.shift(); // Remove first element from array.


For Each in Array

<script type='text/javascript' src='js/jquery.js'></script> // JQuery need for use $.each function
var arr = [5,10,15];
$.each(arr,function(key,value){
console.log(key+' : '+value);
});
//Out put:
0 : 5
1 : 10
2 : 15


Monday, September 30, 2013

Host website on Linux Server using Git and SSH

1. Open terminal in your local system, and connect to linux server system using SSH.

Syntax: ssh -i <pem_file> <server address>
Example: ssh -i site.pem ubuntu@54.251.245.22

Now you are in linux server. So you can run all usual commands in server. First go to "www" directory in server. Using following command,

Example: $ cd /var/www/

Now by using "ls" command, you can see all folders or sites in side that server.

Example: $ ls

2. Copy your site to server using git clone.

Log in to git site(https://github.com/), and copy HTTP clone URL which is on right bottom of your project listing page. Now run the following command to copy your git repository to server.

git clone https://site.com/dir/project.git <localfolder>

Now your site moved to server. Now you have to implement local virtual host on server. So that your site.com redirect to specific folder on the server.

3. Make local virtual host on server.

Go to sites-available folder on server system, and open default file in a editor

Syntax: $ cd /etc/apache2/sites-available
             $ sudo vim default

On above syntax note we used "sudo" command for avoid unnecessary errors, like editor may throw error as "cannot edit read only file" or "need admin permission".
Now add the following lines on end of the file add save.

<VirtualHost *:80>
DocumentRoot /var/www/yoursitefolder
ServerName sitename.com
ServerAlias www.sitename.com
</VirtualHost>

Note: Press "i" to edit the file, use "<esc>:w" to save file.

Now open hosts file which is on 'etc' folder, and add your site name as explained below.

Syntax: 
             $ cd /etc
             $ sudo vim hosts

             Add follwoing lines, after the line "127.0.0.1 localhost".
             127.0.1.1       sitename.com
             127.0.1.1       www.sitename.com

Now, restart your apache to consider the new changes.
             $ sudo /etc/init.d/apache2 restart

4. Upload your database
Go to www.sitename.com/phpmyadmin or www.servername.com/phpmyadmin
enter username and password, then upload your database.

Thats all..


Monday, September 23, 2013

My seminar about: Learn JavaScript for Beginners

What is JavaScript
JavaScript(also known as JS) is a programming language that can understand by web browsers. That is JS run on browser, there is no need of any additional software. And note even internet connection also not need to run JS.

Why JavaScript
Before going to ask why JavaScript, first thing what will happen on a website which does not has JS code?.. Its going to had no.of static or sleeping pages which are build by HTML and CSS, and there html taking care about what contents are to be display and CSS taking care about how that contents are to be display. And one more person is there that is server language, but he only active at when our website trying to send request to server. This usually happening only on form submit, so we need to wait until our site request to and get response from server. Abort from that our site always sleeping, and we cannot perform any action even a adding two integers. Because our HTML and CSS are not know these. So in this point we need something that should make our website alive without any energy(network). For this JavaScript came. I hope now you may get some undefinable imagine about JS, yess.. thats it. We can define that imagine as JavaScript add behavior to your website where you no need for connect to server. Some of that behaviors are add or alter any HTML elements, styling that elements, making animations, form validations, even can request and response with server with out reloading the page, etc..

Okay now you had some basic idea about why and what is JS. And next you have to know how can write JS.

How to start writing JS
We can write JS in any portion of the HTML page. But writing it on top or bottom of the page is good practice, because by doing this you can separate you HTML and JS codes.

Example 1:
Write something into top of html page, and also make an alert message.

<script type="text/javascript">
document.write("Hello JavaScript World");
alert("Welcome to JavaScript World");
</script>
<html>
    <head>
         <title>Hello JavaScript World</title>
    </head>
    <body>
        <p>This is my first JavaScript Programme</p>
    </body>
</html>
How to RUN: Make a separate folder for our tutorial in any location. And save the above file as hello_world.html in that folder and open it on any browser.
Output: First your html page had line "Hello JavaScript World", then get one alert as "Welcome to JavaScript World", after that alert the page will get a line "This is my first JavaScript Programme".

You can save JS codes in new file with the extension ".js" and can include in on your HTML page.

Example 2:
Integrate Example 1 with external JS file.

First write the following codes in file and save it as hello_world_2.html on our folder.
<script type="text/javascript" src="hello_world_2.js"></script>
<html>
    <head>
         <title>Hello JavaScript World</title>
    </head>
    <body>
        <p>This is my first JavaScript Programme</p>
    </body>
</html>

Now write the following JS codes in new file and save it as hello_world_2.js on our folder.
document.write("Hello JavaScript World");
alert("Welcome to JavaScript World");

Output: Same example 1 output.

Variables in JS
Okay now you got some idea about how to write, save and run JS codes. Next you have to know how write and use variables in JS. Its not a difficult matter, its easier than you used in some basic programming languages such as C, C++. Because you do not need to declare datatype of the variable, its takes that as you defined. That is if you mention a=24 it takes it as number, if you declare a="24" then it take it as string. You have to use "var" keyword on declaration. If you do not assigned any value on the declaration it consider as a undefined.

You can declare variables as following ways,
var a;                           // here a declared as undefined
var a=5;                       // here a declared as number
var a="apple";            // here a declared as string
var a,b,c;                    // here a,b,c are declared as undefined in single line
var a=2,b=3,c=a+b;   // here a,b declared as number and c declared with expression; here c=5;

DOM
I think before you going to write JS codes, you have know about DOM. Because JS fully designed for integrate with DOM. So by learning DOM you can outline what are JS works.

DOM is an abbreviation of Document Object Model. That is when a web page is loaded, the browser creates a Document Object Model of the page. This is constructed as a tree of Objects that is looks like in the below picture.


That is our browser makes every elements in the html page as programmable object model. So our JS can interact with all these objects or elements.

Our JS actions among these objects are below:
1. JS can change all the HTML elements in the page
2. JS can change all the HTML attributes in the page
3. JS can change all the CSS styles in the page
4. JS can react to all the events in the page


So, now we are going to learn about these actions. And before that one more thing we have to do is, to apply these actions first we have to find a element on the page.

Finding HTML Elements
You can find/ get elements on the page Id, Class or TagName.
Find by ID:
var element1=document.getElementById('elemnt_id');

Find by TagName:
var para=document.getElementById('p');    // get all p tags

Note: Finding elements by class name does not work in Internet Explorer 5,6,7, and 8.


Change HTML Element Content
We can change the content of a html element by JS.

Example 3: Change HTML element content
<script type="text/javascript">
var wel_div=document.getElementById("welcome_div");  //get element
wel_div.innerHTML("Welcome to JavaScript");   // change element
</script>
<html>
    <head>
         <title>Welcome to JavaScript</title>
    </head>
    <body>
        <div id="welcome_div">Welcome to HTML</div>
    </body>
</html>
Output: The message "Welcome to JavaScript" will display on the div which having the id "welcome_div".

Change HTML Style
As we said can change the style of a html element by JS.

Example 4: Change HTML element style
<script type="text/javascript">
var wel_div=document.getElementById("welcome_div");  //get element
wel_div.style.color="#2E9AFE";
</script>
<html>
    <head>
         <title>Welcome to JavaScript</title>
    </head>
    <body>
        <div id="welcome_div">Welcome to JavaScript</div>
    </body>
</html>
Output: The message "Welcome to JavaScript" will display as blue color, which is on the id "welcome_div".

Call JS on Event
We can call JS function and make some operation when event is triggered on DOM or html page.

Example 5: Call JS function on a event
<script type="text/javascript">
function my_fun()
{
    var wel_div=document.getElementById("welcome_div");  //get element
    wel_div.innerHTML("Welcome to JavaScript");   // change element
}
</script>
<html>
    <head>
         <title>Welcome to JavaScript</title>
    </head>
    <body>
        <div id="welcome_div">Welcome to HTML</div>
        <button value="Change" onclick="my_fun();" />
    </body>
</html>
Output: The message "Welcome to HTML" is change to "Welcome to JavaScript" when you click on the button.

Some basic things need to know about JavaScript
1. Your JS code can view by users, so do not include any sensitive datas on JS file.
2. User can disable JS on browsers, so make sure your website can run with out JS. Just it add some           extra functionality to site.
3. Its runs on browser, so it can run even you are not connect to internet.
4. JQuery is just a JS file, which has list of functions to minimize our coding stuff and length.

Note: Now I hope you had some basic ideas about JS. Which means you are ready to write JS, but you have to know more about it. This tutorial only made for push you to learn JS. And here I explained just outline of the JS use. You can learn more about JS here: http://www.w3schools.com/js/default.asp
http://javascript.about.com/od/reference/a/javascriptpurpose.htm

Friday, September 20, 2013

Android: Change app background image when orientation change(toggle b/w landscape and portrait) without restarting main class

Avoid main or activity class restart:
To do this note go to bin/res/AndroidManifest.xml, and add the following line under any activity where you want disable activity class refresh when orientation change.

android:configChanges="orientation|screenSize"

Change background Image:
To do this go to src/com.example.<yourproject>/<yourclass>Activity.java, for example src/com.example.firstapp/MainActivity.java, and add following function.

public void onConfigurationChanged(Configuration newConfig)
{
   super.onConfigurationChanged(newConfig);
   View mainLayout = findViewById(R.id.main_layout); // getting the layout

  // Checks the orientation of the screen
  if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
  {
    mainLayout.setBackgroundResource(R.drawable.my_bg_land);
  }
  else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
  {
     mainLayout.setBackgroundResource(R.drawable.my_bg);
  }
}

Note:
Please note on above code we access layout by its id(main_layout). To use this we have note it on layout xml file(that is xml file for your specific activity which is under res/layout here:res/layout/activity_main.xml)
android:id="@+id/main_layout"


Reference:
Changing background of a layout at run time - http://manijshrestha.wordpress.com/2011/04/05/android-sdk-changing-background-of-a-layout-at-run-time/
Detect orientation change - http://stackoverflow.com/questions/5726657/how-to-detect-orientation-change-in-layout-in-android

Tuesday, September 3, 2013

Is slash required at the end of URL?

Actually what happening?:

When you mentioned forward slash(/) at the end of your URL, the server will consider last word as directory and try to enter that directory and try to run index.html or any other index files. If can not found that directory then server try to find a file with that name.

If you do not mentioned forward slash(/) at the end of your URL, the server will consider last word as file and try to run that file. If that file not found then server try to find a directory with that name and then enter.

What problem arrives here?:

As per above two cases, the server will meet two request on following situations,

1. If we provided forward slash(/) at the end of URL, when we had file at the end.
    Example: http://example.com/product/list.php/
    
    (Here the server first try find a folder with the name "list.php", Once it not found then only its try to find a file with the name "list.php".)

2. If we not provided forward slash(/) at the end of URL, when we had directory at the end.
    Example: http://example.com/product/lists

    (Here the server first try find a file with the name "lists", Once it not found then only its try to find a folder with the name "lists".)

Conclusion:

When you are had folder at the end of URL use forward slash(/), otherwise do not use.

Note: You can speed up access to your home page by including the forward slash(/) on your domain name URL. Example: http://example.com/

Thursday, August 29, 2013

Strange and Interesting facts about PHP

Comparison:
In PHP the boolean values TRUE and FALSE are case in-sensitive.

Example:
$a=TrUe;
if($a)
 echo 'Entered';     //will come
if($a==TRUE)
 echo 'Entered';    //will come
if($a===TRUE)
 echo 'Entered';   //will come

And TRUE = Something other than FALSE or 0 or '0'.

Example:
$a='test';
$b='0';
if($a==TRUE)
    echo 'Entered';   //will come
if($b==TRUE)
    echo 'Entered';   //will not come

Increment Operator:
If we use an increment operator along with a string, it will increment last letter of the string(When the last letter of the string is alpha numeric, that is other than special characters).

Example:
$a='apple3';
$b='apple';
$c='apple?';

echo ++$a;    // output: apple4
echo ++$b;   // output: applf
echo ++$c;   // output: apple?

Case Sensitive:
In PHP variables are case sensitive but functions are not.

Example:
$test='red';
echo $tesT;   // will not work
sample();      // will work

function Sample()
{
echo 'inside function';
}


Please go throw the following links for more details:
http://www.sitepoint.com/3-strange-php-facts-you-may-not-know/
http://php.net/manual/en/types.comparisons.php

Thursday, August 22, 2013

Javascript Local Storage

Reference: http://www.htmldog.com/guides/javascript/advanced/localstorage/

When building more complex JavaScript applications, it’s very useful to be able to store information in the browser, so that the information can be shared across different pages.

Unlike cookies, local storage can only be read client-side - that is, by the browser and your JavaScript. If you want to share some data with a server, cookies may be a better option.

Set Item: localStorage.setItem('name', 'tom');

Get Item: var name = localStorage.getItem('name');


Example:

<html>
      <head> 
              <title>Javascript Local Storage</title>
      </head>
      <body>
              Give some input to store on local: <input type="text" id="input_msg" />&nbsp&nbsp              <input type="button" value="Submit" id="submit" onclick="saveOnLocal();" />
              <br /><br />
              Data from local: <span id="local_data"></span>
      </body>
</html>

<script type="text/javascript">
function saveOnLocal()
{
var data=document.getElementById('input_msg').value;
localStorage.setItem('input_msg',data); //Set local storage
document.getElementById('local_data').innerHTML=localStorage.getItem('input_msg'); //Get local storage
 localStorage.removeItem('input_msg'); //Clear specific local storage item
 //localStorage.clear(); //Clear all local storage item

}
</script>

You can only save string using javascript local storage, use JSON for save array.

Example:
<script type="text/javascript">
localStorage.setItem('name', JSON.stringify(your_array));
var user = JSON.parse(localStorage.getItem('name'));
</script>


Browser support for local storage is not 100% but it’s pretty good - you can expect it to work in all modern browsers, IE 8 and above, and in most mobile browsers too. And the storage size depends on the browser.




Thursday, August 8, 2013

Get file size using Java Script only

HTML:
<input type="file" name="photo" id="photo" />

Java Script:
$('#photo').live('change', function(){
      var file_size=this.files[0].size;
      alert(file_size);
});

Notes:
1. This is a HTML5 feature. So I think its only works on HTML5 supported browsers.
2. Similarly we can get some attribute of file.

Source:
http://stackoverflow.com/questions/8192516/html5-file-browse-tag
http://forum.jquery.com/topic/how-to-validate-file-size-function-before-submitting-form

Wednesday, July 24, 2013

Apply Even and Odd classes for elements on, "while" or "for" loop

When we display list of elements using any looping, we need to add some two classes for differentiate one row from another. On this case we need use one extra variable, and increment it throw loop, then we can get '0' or '1' by mod(%) this value. So now we can have two different classes repeatedly like 'r0','r1'. And now write style for these two classes.

Example:
<style type="text/css">
Output
.list0{
background-color: #00B2C1;
}
.list1{
background-color: #50D4FF;
}
</style>
<html>
<title>Even and Odd classes for loopig elements</title>
<body>
<table cellspacing="0">
<tr>
<td>NO</td>
<td>Name</td>
</tr>
<?php $i=0; while($i<=10) { ++$i; ?>
<tr class="list<?php echo (++$x%2); ?>">
<td><?php echo $i; ?></td>
<td>Name <?php echo $i; ?></td>
</tr>
<?php } ?>
</body>
</html>


Note: Here we can use '$i' to mod. But most of cases we don't has this option, and more over here we wrote single line(++$x%2) to get mod value.

Monday, July 22, 2013

Regular Expression validation for frontend(JS) and backend(PHP)

Start with one example:

For validate Name Field: Alphabets, numbers and space(' ') no special characters min 3 and max 20 characters.

var ck_name = /^[A-Za-z0-9 ]{3,20}$/; 
if (!ck_name.test(name))
{
        alert('Enter valid Name.');
        return false;
}


Note: The above code for front end using JavaScript. If you are using PHP use key word preg_match instead of test.

Some important conditions:
[abc] Find any character between the brackets
[^abc] Find any character not between the brackets
[0-9] Find any digit from 0 to 9
[A-Z] Find any character from uppercase A to uppercase Z
[a-z] Find any character from lowercase a to lowercase z
{3,10} Check for the string length in between give boundary.


Important Links:


Wednesday, July 10, 2013

Implement "Remember Me" option for login using Javascript(JQuery) cookies

1. Get JQuery Cookie library in hand

To implement this first you need to have JQuery Cookie library. So please save following JS file as "jquery.cookie.js", or you can directly download from Github .

//Save it as jquery.cookie.js
/*!
 * jQuery Cookie Plugin v1.3.1
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2013 Klaus Hartl
 * Released under the MIT license
 */
(function (factory) {
 if (typeof define === 'function' && define.amd) {
  // AMD. Register as anonymous module.
  define(['jquery'], factory);
 } else {
  // Browser globals.
  factory(jQuery);
 }
}(function ($) {

 var pluses = /\+/g;

 function raw(s) {
  return s;
 }

 function decoded(s) {
  return decodeURIComponent(s.replace(pluses, ' '));
 }

 function converted(s) {
  if (s.indexOf('"') === 0) {
   // This is a quoted cookie as according to RFC2068, unescape
   s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  }
  try {
   return config.json ? JSON.parse(s) : s;
  } catch(er) {}
 }

 var config = $.cookie = function (key, value, options) {

  // write
  if (value !== undefined) {
   options = $.extend({}, config.defaults, options);

   if (typeof options.expires === 'number') {
    var days = options.expires, t = options.expires = new Date();
    t.setDate(t.getDate() + days);
   }

   value = config.json ? JSON.stringify(value) : String(value);

   return (document.cookie = [
    config.raw ? key : encodeURIComponent(key),
    '=',
    config.raw ? value : encodeURIComponent(value),
    options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
    options.path    ? '; path=' + options.path : '',
    options.domain  ? '; domain=' + options.domain : '',
    options.secure  ? '; secure' : ''
   ].join(''));
  }

  // read
  var decode = config.raw ? raw : decoded;
  var cookies = document.cookie.split('; ');
  var result = key ? undefined : {};
  for (var i = 0, l = cookies.length; i < l; i++) {
   var parts = cookies[i].split('=');
   var name = decode(parts.shift());
   var cookie = decode(parts.join('='));

   if (key && key === name) {
    result = converted(cookie);
    break;
   }

   if (!key) {
    result[name] = converted(cookie);
   }
  }

  return result;
 };

 config.defaults = {};

 $.removeCookie = function (key, options) {
  if ($.cookie(key) !== undefined) {
   // Must not alter options, thus extending a fresh object...
   $.cookie(key, '', $.extend({}, options, { expires: -1 }));
   return true;
  }
  return false;
 };

}));



2. Add "Remember Me" check box on Login page

Add "Remember Me" check box in login form, then include "jquery.cookie.js" and your JS file (here: login.js).

<input type="text" id="username" /><br />
<input type="password" id="password" /><br />
<input type="checkbox" id="c1" />Remember Me<br />
<input type="submit" id="loginsubmit" />
.
.
.
<script src="js/jquery.cookie.js"></script>
<script src="js/login.js"></script>


3. Set and Get Cookie using JQuery

Now, set entered username on cookie, or display username if already avail on cookie. To do this,
include following line in your JS file (here: login.js)

$(document).ready(function()
{

// Please read these set of code after you read next set. So that you can understand simply.
var username=$.cookie("username");   // Get username from cookie on form load.
if(username!=undefined)
{
$('#loginsubmit').val(username);   // Display username on input box if avail on cookie.
      $('#c1').prop('checked', true);  // Check check box manually by us. So that duration for current email will reset.
}

// Read this set first.
$('#loginsubmit').click(function()
{
      if($('#c1').is(':checked')) // If user checked remember me check box
{
                var email=$('#loginsubmit').val(); // Get entered username or email
                //  Set username on cookie when login form submit.
$.cookie("username", email, { expires: 365 });  // Remember username for 1 year.
}
      // Your other codes...
}

});


Note:
1. Assign username or email to cookie after you done form validation like email validation, empty checking, so that you can sure for stored value are original.

2. And here we set username or email on cookie for one year. You don't need to worry about like "will expire after one year?". Because it will reset to one year whenever user try to login. And only go empty once if the user not login even one time for a year. You can change this duration as you need.

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>


Friday, May 31, 2013

Save output as CSV file and ask for download using PHP

<?php
header("Content-Type: text/csv");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: attachment; Filename="Selected_Resumes.csv"');

$outstream = fopen("php://output",'w');  //Directly ask for download with out saving
//$outstream = fopen('bath/list.csv', 'w'); // Save file on sever then ask for download

fputcsv($outstream, $titles);

foreach ($result as $data) {
    fputcsv($outstream, $data);
}
fclose($outstream);

//unlink('bath/list.csv');  // Use this to delete file, if you are using save file on server.
?>

Note: Better we can directly ask for download output as CSV, with out saving them in server.

Thursday, May 30, 2013

செங்கோட்டை பாசஞ்சர் - சிறுகதை

'ஐ லவ் யூவுக்கு என்ன வயசு சார் இருக்கும்?'' என்றபடி என் அருகில் அமர்ந்த ஆல்வினை எனக்கு அவ்வளவு பிடித்திருந்தது. அவன் இந்தக் கேள்வியைக் கேட்கவும் கலெக்டர் கொடி அசைக்கவும், ரயில் புறப்படவும் சரியாக இருந்தது. சமயங்களில் இப்படித்தான் எல்லாம் சொல்லிவைத்தபடி நிகழ்ந்துவிடுகிறது. ஆல்வின் சொன்ன வார்த்தைகள் என்று இல்லை...

continue reading here: http://goo.gl/MlKsd


MGR கொலை முயற்சி வழக்கு, 1967 (நிகழ்வை படித்து உங்கள் கருத்தை சொல்லுங்கள்.)

1967-ம் ஆண்டு ஜனவரி 12-ம் நாள் மாலை 5 மணி அளவில் எம்.ஆர். இராதாவும், திரைப்படத் தயாரிப்பாளார் வாசுவும் எம்.ஜி.ஆரின் நந்தம்பாக்கம் வீட்டிற்குச் சென்று அவரைச் சந்தித்துப் பேசியுள்ளனர். இந்த சந்திப்பின்போது எம்.ஜி.ஆர். துப்பாக்கியால் தனது இடது காதருகே சுடப்பட்டார். இராதாவின் உடலில் நெற்றிப் பொட்டிலும் தோளிலுமாக இரு குண்டுகள் பாய்ந்தன. மருத்துவமனையில் அனுமதிக்கப்பட்ட இருவரும் உயிர்பிழைத்தனர். இந்தத் துப்பாக்கிச் சூட்டையடுத்து...

continue reading here: http://goo.gl/U1t96


Git Basic Commands

git status                                         -    display changes
git checkout .                                  -    clear all files from last edit
git checkout <file> <file>                -    clear specified files last edit only
git pull                                             -    pull all files from server
git diff > <file>                                 -    write whole diff on new file
git diff <file> > <file>                       -    write specific file diff on new file
git diff <file> <file> > <file>             -    write more than one files diff on new file
git add .                                           -    add all files to client from buffer 
git commit -m “msg”                       -    record local changes to local repository
git push                                           -    push the local repository recorded code(done by git commit) to server repository.
git add <file>                                   -    add untracked file to buffer
git diff --cached >> <file>               -    append new file changes to exist diff file.
git log                                              -    List commits
ctrl l or clear                                   -    clear screen
git diff --diff-filter=D >> <file>         -    Append all deleted file details to diff
git help <verb>                               -    Detail about specific verb
git reset HEAD <file>                     -    Move file from staged to unstage (Note: When new file added and send for push by       diff(used --cached), and if you try to pull from repository first you use ‘git reset HEAD <file>’ and then delete that file manually, then only you can pull.)
ctrl + ins (or) ctrl + shift + c           -    Copy
shift + ins (or) ctrl + shift + v         -    Paste
Q                                                    -    Go to new cmd
ctrl + c                                            -    Stop / Cancel current process
patch -p1 --dry-run < <diff_file>    -    List affecting file if we add or integrate specific diff file.
patch -p1 < <diff_file>                   -    Add or integrate specific diff file
git clone https://site.com/dir/project.git <localfolder> - Clone git from server using https
(Note: First open terminal and go to local folder where you want to pull and use above command to copy/ clone project to local.)
git checkout <branch_name>      -    Will switch to specified branch.
git branch <branch_name>          -    Will create a branch.
git checkout -b <branch_name>  - Will create and switch to branch at the same time.

Note: Be care full when using red marked comments above. Because it may affect your codes permanently, and most of the time will only used by admin of the project.

Learn JavaScript - String and its methods - 16

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