Tuesday, 4 November 2014

Live Digital Clock - Javascript 0

Here is the code for Live digital clock. Just we are going write a function to get the current time and display it in span. We are calling that function for each 1000 milli seconds. so, live clock is working. var int=self.setInterval("clock()",1000); function clock(){ var now=new Date(); var time=now.toLocaleTimeString(); document.getElementById("clock").textContent=time; };  Here is the live Demo Thanks Christian Whi...

Monday, 6 October 2014

Find how many times a search phrase is found in a string 0

Here is the function to tell how many times a search phrase is found in a string. Note: It's case sensitive. function howMany(str, term){ return str.match(new RegExp(term, 'g')).length; }; var text='Visit WHAK.com for WHAKy things!'; var phrase='HAK'; alert(phrase+' is found in\n'+text+'\n'+howMany(text,phrase)+' times.') Thanks Christian Whi...

Sunday, 24 August 2014

MySql return rows matching year month 0

If we want to get rows by filtering given month and year, We can use 2 popular ways. EXTRACT() BETWEEN 1. EXTRACT( ): The EXTRACT() function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc. SYNTAX: EXTRACT(unit FROM date) This function have a following units to use. MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR, SECOND_MICROSECOND, MINUTE_MICROSECOND, MINUTE_SECOND, HOUR_MICROSECOND, HOUR_SECOND, HOUR_MINUTE,...

Monday, 18 August 2014

How to resize image diagonally using javascript 0

In general we don't like to see our images stretched in view. In this case, If we want to reduce size diagonally, what should we do? We can do it by changing width property of image. First We need to get original width of image using javascript's naturalWidth property.  Then Multiply it with 0.5 to get 50% reduced image. If you want 2x larger image, then multiply it with 2. like this below code, domElement.width = doemElement.naturalWidth * 0.5; Then assign resultant...

HTML DOM Image naturalWidth, naturalHeight Property 0

The Javascript's naturalWidth and naturalHeight properties will return original width and height of an image. For an example, If we are using an image with 350px original width and 225px original height, It will return the same height and width even we made changes in DOM's height and width property. The following DEMO will make you understand more what I'm saying.  In this DEMO the original image size of image is 350 x 225 px. We are also changed image width...

Saturday, 9 August 2014

$_GET vs. $_POST - PHP 0

$_GET and $_POST Both GET and POST create an array. e.g. array(key=>value, key2=>value2, key3=>value3, ...). This array holds key/value pairs, where keys are the names of the form controls and values are the input data from the user. Both GET and POST are treated as $_GET and $_POST. These are superglobals, which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having...

Thursday, 7 August 2014

How reloadAfterSubmit working in jqGrid 0

This reloadAfterSubmit attribute always confusing with data type. I have seen so many post related to reloadAfterSubmit not working like that in jqGrid forum and stackoverflow posts. Here I gave explanation about reload process in jqGrid. jqGrid using AJAX to post data to Server Side (add, edit, delete). So, our page will not get refresh. jqGrid reloadAfterSubmit...

Tuesday, 29 July 2014

Solution : Can't quit Packagekit - adding software package in OpenSuse 4

Problem We can't run 2 updaters at the same time so if packagekit is running then you can't run Yast update or zypper. So, it will through confirm message to stop packageKit process. PackageKit is blocking software management. This happens when the updater applet or another software management application is running. Ask PackageKit to quit? if you click on 'Yes', it will try to stop the process of packageKit. If it is still busy, it will again arise the popup with this message.  PackageKit...

Monday, 28 July 2014

Resize jqGrid based on number of rows 0

To resize grid based on number of rows, Just we need to say this in configuration settings of jqGrid. Yes. we need to set like this below. $("#mygrid").jqGrid({     ...,     ...,     ...,     height:'auto',     ...,     ... });   simply set height property to auto. How it actually works? This height configuration...

Sunday, 27 July 2014

Convert CSV to Two dimensional array (2D Array) - PHP 2

When you get the data from CSV file, It will return return array of each row. To work with this, we need to convert it as 2D array. So, this following code snippet will help you to covert CSV array to 2D array. In this we used PHP's array_combine function. FUNCTION DEFENITION function get2DArrayFromCsv($file, $delimiter) { if (($handle = fopen($file, "r+")) !== FALSE) { $i = 0; $data2DArray = array(); while (($lineArray = fgetcsv($handle, 0, $delimiter)) !== FALSE)...

Monday, 21 July 2014

Add border-bottom / border-top to table row using CSS 0

We can do it with table's border-collapse property. Collapse In which both the space and the borders between table cells collapse. So, there is only one border and no space between cells. Just change the table border-collapse style into collapse using this following css table { border-collapse: collapse; } Now the each cells are independent. So, you can apply border-bottom or border-top style for each td like bellow CSS. To...

Saturday, 19 July 2014

24 jQuery UI themes 0

Here we listed 24 jQuery UI themes... Click on the names to get raw code of themes. Black tie Blitzer  Cupertino Dark Hive Dot luv Egg plant Excite bike Flick Hot Sneaks Humanity Le frog Mint Choc Overcast Pepper grinder  Redmond  Smoothness  South Street  Start  Sunny  Swanky purse Trontastic UI Darkness UI Lightness Vader   Click...! Download...!! Enjoy... !!! ...

Thursday, 17 July 2014

Uncaught TypeError: Cannot read property 'integer' of undefined - jqGrid 0

This sounds "Language supporting file is missing". * One get the error message typically if one don't included required language file grid.locale-xx.js (for example grid.locale-en.js). * You can Include it before jquery.jqGrid.min.js or jquery.jqGrid.src.js. See the example of the usage of jqGrid in Documentation * If you don't have that file, Click Here to download. Have any doubt? Feel free to comment here!!! Related post : jqGrid "reloadGrid" using Local Data...

Wednesday, 16 July 2014

Convert CSV to JSON with header row as key - PHP 1

When you get the data from CSV file, It will return return array of each row. If we want this array in JSON as header row as key and cell value as value, We can use PHP's array_combine function. So, We can use this following function to achieve this task. FUNCTION DEFENITION function getJsonFromCsv($file,$delimiter) { if (($handle = fopen($file, 'r')) === false) { die('Error opening file'); } $headers = fgetcsv($handle, 4000, $delimiter); $csv2json = array(); while...

Saturday, 12 July 2014

Strict Standards: Non-static method DOMDocument::load() should not be called statically - PHP 0

In PHP recently I faced this issue. When I tried to use my xml file using php's document load() function. Problem $dom = DOMDocument::load('myXml.xml'); It works perfectly. But I throws error Strict Standards: Non-static method DOMDocument::load() should not be called statically Solution The reason why it's happening is because I called a load() method in the DOMDocument class in which is not static.  Instead of calling it with :: We need to call...

Thursday, 3 July 2014

Get all the dates between two dates - Javascript 7

We can do this using Javascript's Date() object. You can use this following function to get between two dates. It will return array. Here we are using isDate() and isValidRange() functions to make sure is the given string is Date and end date is not greater then start date. If the given string is not date, then it will return "error occured!!!... Please Enter Valid Dates" in browser console and it will return empty array. ...

Tuesday, 24 June 2014

Get all dates in given month and year in php 0

To get all dates in given month and year, we need to know how many days in that given month and year. to do that we are going to use PHP's date() and mktime() functions. Syntax : date(format,timestamp) mktime(hour,minute,second,month,day,year,is_dst); Function: the following function will return dates in array format for given month and year in Y-m-d format. This file contains bidirectional Unicode text that may be...

Monday, 16 June 2014

எவ்வளவோ மேல்... 0

(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); $( "a.see_more_link" ).on( "click", function(e) { e.preventDefault(); alert('hi'); }); Post by சுபா ஆனந்தி...

Saturday, 14 June 2014

வெற்றியை நோக்கி... Towards victory... 0

வெற்றியை நோக்கி பற ! பறக்க முடியாவிட்டால் ஓடு ! ஓட முடியாவிட்டால் நட ! நடக்கவும் முடியாவிட்டால் ஊர்ந்து செல். ஆனால், எப்படியாவது நகர்ந்து கொண்டே இரு. English Version:  Fly to Victory! If you can't fly, then run ! If you can't run, then Walk ! If you are unable to walk, then Crawl. But, Somehow, Keep Moving......

Friday, 13 June 2014

Help !!! உதவி !!! 0

முற்காலத்தில்  உதவி என்பதை கேட்காமல் செய்வார்கள்! ஆனால், இக்காலத்தில் உதவி என்று கேட்டாலும் செய்வதற்கு நல்ல மனமும் இல்லை,  நல்ல மனிதர்களும் இல்லை English Language Difference: "May I help you" (past) " Please Help Me" (Present) Google Search: "Definition of Help" (Future)  ...

Peace in the world 0

Where there is righteousness in the heart there is beauty in the character, when there is beauty in the character there is harmony in the home, when there is harmony in the home there is order in the nation, when there is order in the nation, there is peace in the world. - Dr. APJ Abdul Kala...

Thursday, 12 June 2014

Don’t compromise with time... 0

Don’t compromise with time... Time will not change our life... Time only changes the expiry dates of  opportunities......

Iyarkai Thai Kavithai | இயற்கைத் தாய் 0

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

பூமிக்கு வேறு எங்கும் கிளைகள் கிடையாது. 0

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

Wednesday, 11 June 2014

Compare and remove array element - javascript 2

In this post we are going to see how to compare two array elements? and do something, when the element is matched. This below prototype method will do that trick. Array.prototype.diff = function(arr2) { this.sort(); arr2.sort(); for(var i = 0; i < this.length; i += 1) { if(arr2.indexOf( this[i] ) > -1){ arr2.splice(arr2.indexOf( this[i] ), 1); } } }; from the above code, first we are sorting both arrays. Then, We searching for index of same element...

Wednesday, 4 June 2014

Solution for noreply@blogger.com in blogger feed 2

Problem  This issue is arise with only RSS feed not in ATOM feed.  Example I'm going to show my blogger blog feed as an example in this post. RSS Feed This below URL is my blog post feed URL which will return my RSS feed data of posts. http://cj-ramki.blogspot.in/feeds/posts/default?alt=rss It creates the JSON data empty blog author name and noreply@blogger.com(author name). I just...

Tuesday, 3 June 2014

How to get full referrer url in php 0

To get referrer url, we are going to use $_SERVER variable called HTTP_REFERER. In some cases we need to check, this page redirected from where? To fill up that "where" we should use  $_SERVER[HTTP_REFERER]. NOTE: If users use a bookmark or directly visit your site by manually typing in the URL, HTTP_REFERER will be empty. If the users are posting to your page programatically (CURL) then they're not obliged to set the HTTP_REFERER as well. So,...

How to get current full URL in PHP 0

To get current full url in php, we can use php's $_SERVER variables. We are going to use $_SERVER[REQUEST_SCHEME]  - It will print which type scheme (ex.http) $_SERVER[HTTP_HOST]       -  Server host name $_SERVER[REQUEST_URI]      - current URI  So, We can combine those three like below, $URL = $_SERVER[REQUEST_SCHEME].'://'.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];  Simply echo it like this echo $_URL; to test it. Have...

Monday, 2 June 2014

வெற்றி பற்றிய புரிதல் 0

தோற்காமல் இருக்க வேண்டுமே என்பதற்காக நீங்கள்ஜெயிக்க பார்த்தால், தோல்விதான் உங்களுக்கு மிஞ்சும். வெற்றியை  மட்டும் மனதில் வைத்துக் கொண்டு ஓடுங்கள்... அதிவேகமாக ஓடுங்கள். தோல்வி உங்களைத் துரத்தட்டும்... பரவாயில்லை. ஆனால் தோல்வியை துரத்திக் கொண்டு நீங்கள் ஓடாதீர்கள்...                                     - கோபிநாத் சந்திரன் (ப்ளீஸ்...

சந்தோஷம் எதில் தான் இருக்கிறது? 3

சந்தோஷம் எதில் தான் இருக்கிறது? ரொம்ப சுலபம். சந்தோஷமாக இருக்க வேண்டும் என்ற உங்கள்எண்ணத்தில்தான் அது இருக்கிறது.                          - கோபிநாத் சந்திரன் (ப்ளீஸ் இந்த புத்தகத்தை வாங்காதீங்க.) $('.status-msg-wrap').hide();...

Sunday, 1 June 2014

30 lessons from Narayana Murthy - Infosys 0

NR Narayana Murthy, who steps down as Infosys chairman on August 20, is a role model for not just what he achieved but also how he did it. Here are 30 lessons from Murthy, one for each year he spent at company. 1-Seize Your Gandhi Moment Murthy, a self proclaimed socialist in the mid '70s was jailed for 72 hours in Bulgaria. The experience taught him that entrepreneurship and job creation is the way to alleviate poverty. 2-You might fail, but get started Learn from mistakes and move on....