Monday, August 22, 2016

Replace command

<-------------------------------------- Replace command -------------------------------------------------------->


sudo find /home/ngit/tomcat/webapps/mrb/js/ -type f -print0 | xargs -0 sed -i 's/KisanBazaar/KisanPoint/g';


Replace kisanbazar with kisanpoint

Thursday, July 28, 2016

Query to display whole data upto the previous day.

select XXXXX, SSSSSSSS, DDDDDD , CAST(date(h_date) as CHAR) as h_date from TABLENAME where h_date < (CURDATE()) order by h_date desc  ";

ie., If the current date is 22-08-2016 , It will display data upto 21-08-2016 .
Example:
+--------------+
| h_date |
+--------------+
| 2016-07-27   |
| 2016-07-27   |
| 2016-07-23   |
| 2016-07-20   |
| 2016-07-18   |
| 2016-07-15   |
| 2016-07-13   |
| 2016-07-13   |
| 2016-07-12   |
| 2016-07-10   |
+--------------+

Wednesday, July 20, 2016

Convert amount to indian rupees :

Convert amount to indian rupees : 

double totalinvestmentabilityamount = Double.parseDouble(totalamount);
String totalinvestmentabilityamount1=formatt(totalinvestmentabilityamount);


we should add this methods in our servlet:


public static String formatt(double value) {
 LogLevel.DEBUG(5,new Throwable(),"jhansi value:"+value );

    if(value < 1000) {
        return formatt("###", value);
    } else {
        double hundreds = value % 1000;
        int other = (int) (value / 1000);
        return formatt(",##", other) + ',' + formatt("000", hundreds);
    }
}

private static String formatt(String pattern, Object value) {
    return new DecimalFormat(pattern).format(value);
}

If total amount is 2003763714 it will display in indian rupee format as 2,00,37,63,714 

Saturday, July 16, 2016

How do you tell if caps lock is on using JavaScript?


<input autocomplete="off"  type="text" id="username" title="login" name="username" onkeypress="isCapLockOn(event)" class="width_100"><div id='username_error'style="display:none;"></div>


function isCapLockOn(e)
{
var charKeyCode = e.keyCode ? e.keyCode : e.which; // To work with both MSIE & Netscape
var shiftKey = e.shiftKey ? e.shiftKey : ((charKeyCode == 16) ? true : false);
// Check both the condition as described above
if (((charKeyCode >= 65 && charKeyCode <= 90) && !shiftKey)
|| ((charKeyCode >= 97 && charKeyCode <= 122) && shiftKey))
{
// Caps lock is on
document.getElementById('username_error').innerHTML = "Caps lock : <b>On</b>";
}
else
{
// Caps lock is off.
document.getElementById('username_error').innerHTML = "Caps lock : <b>Off</b>";
}

}

How to capitalize the first letter of a String in Java?

WordUtils.capitalize(str)

For Example:

<tr><th><p class='result_title'>Name</p> </th><td>:&nbsp;&nbsp;"+WordUtils.capitalizeFully(stragriname)+"</td></tr>

Monday, July 11, 2016

characters countfor description in jsp

<div class="form-group clear">
<label class="col-lg-3 col-md-3 col-xs-12 control-label">Description *:</label>
<div class="col-lg-9 col-md-9 col-xs-12">
<textarea rows="5" cols="5" class="form-control"  id='description1' name='description1' placeholder='Enter your Description' ></textarea><div id="textarea_feedback"></div><div class ="help-block" id='description1-error'style="display:none;"></div></div></div>



$(document).ready(function() {
var text_max = 500;
$('#textarea_feedback').html(text_max + ' characters remaining');

$('#description1').keyup(function() {
    var text_length = $('#description1').val().length;
    var text_remaining = text_max - text_length;

    $('#textarea_feedback').html(text_remaining + ' characters remaining');
});

});

Thursday, June 30, 2016

How do I make a field autofocus?

<form action="demo_form.asp">
  First name: <input type="text" name="fname" autofocus><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit">
</form>