This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reference - https://www.w3resource.com/javascript-exercises/javascript-date-exercise-8.php | |
var date_diff_inseconds = function (date1, date2) { | |
let dt1 = new Date(date1); | |
let dt2 = new Date(date2); | |
return Math.floor((Date.UTC(dt2.getFullYear(), dt2.getMonth(), dt2.getDate(), dt2.getHours(), dt2.getMinutes(), dt2.getSeconds()) - Date.UTC(dt1.getFullYear(), dt1.getMonth(), dt1.getDate(), dt1.getHours(), dt1.getMinutes(), dt1.getSeconds())) / (1000)); | |
}; | |
var date_diff_inminutes = function (date1, date2) { | |
let dt1 = new Date(date1); | |
let dt2 = new Date(date2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"validPort" : ["256"], | |
"invalidPort" : [], | |
"minPort" : "1000", | |
"maxPort" : "1200" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IPv4 | |
var regexStringIPv4 = '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'; | |
var regexIPv4 = new RegExp(regexStringIPv4, flags); | |
console.log(regexIPv4.test("192.168.0.25.25.23")); // false | |
console.log(regexIPv4.test("192.168.0.25")); // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var someFunctionToUse = function (obj) { | |
// Form data | |
var formData = new FormData(); | |
// Appending the files data in form data | |
formData.append("doc_file", document.getElementById("upload_input_id").files[0]); | |
// (Example) attribute from an object | |
formData.append("data_filed_name", obj.getAttribute("object_attribute_name")); | |
// Creating the Request object | |
var oReq = new XMLHttpRequest(); | |
// Creating event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gives the current Date Time in this format --> ddmmyyyy hh:mm:ss | |
var getLCurrentDateFormated = function () { | |
let date_now = new Date(); | |
return date_now.toLocaleString('en-IN', { day: "2-digit", month: "2-digit", year: "numeric", hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false, timeZone: 'Asia/Kolkata' }).replace(/[\/\,]/g, ""); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Node.js Time measure for benchmarking | |
// Way One : in microseconds | |
var hrTime1 = process.hrtime(); | |
// code | |
var hrTime1 = process.hrtime(); | |
startP = hrTime[0] * 1000000 + hrTime[1] / 1000; | |
endP = hrTime1[0] * 1000000 + hrTime1[1] / 1000; | |
// Shows the time difference in micro second | |
console.log(endP - startP); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ucFirstAllWords( str ) | |
{ | |
var pieces = str.split(" "); | |
for ( var i = 0; i < pieces.length; i++ ) | |
{ | |
var j = pieces[i][0].toUpperCase(); | |
pieces[i] = j + pieces[i].substr(1).toLowerCase(); | |
} | |
return pieces.join(" "); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Importing libraries | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
// Sample JSON string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2018 Jasti Sri Radhe Shyam | |
// Permission is hereby granted, free of charge, to any person obtaining | |
// a copy of this software and associated documentation files (the "Software"), | |
// to deal in the Software without restriction, including without limitation | |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
// and/or sell copies of the Software, and to permit persons to whom the | |
// Software is furnished to do so, subject to the following conditions: | |
// The above copyright notice and this permission notice shall be included in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Referesh automatially | |
<script type="text/javascript"> | |
setTimeout(function(){ | |
location = '' | |
},60000) | |
</script> | |
//Hard Refersh | |
location.reload(true); |