Skip to content

Instantly share code, notes, and snippets.

View santhosh17s's full-sized avatar

Santhosh santhosh17s

  • Altan Calsoft Labs
  • Chennai
View GitHub Profile
@santhosh17s
santhosh17s / greater-number.js
Last active October 23, 2019 06:51
Combination of greater number from random 10 digits.
/*
Take 10 random number. From that to get combination of greater number.
Example to take number - 4132 And result to be 4321.
*/
let randomNumber = 3159705179;
let greaterNbr;
let randomNumberArray = (''+randomNumber).split('');
@santhosh17s
santhosh17s / input-value-change-arrowKeys.html
Last active March 5, 2019 09:46
Input text value need to change based on arrow key - left & right change cursor position and up & down increment or decrements respectively
<!DOCTYPE html>
<meta name="robots" content="noindex">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
$('document').ready( function(){
//WITHOUT ARROW FUNCTION
$('.my-name').on('click', function() {
var that = this;
setTimeout( function() {
$(that).toggleClass('on');
}, 1000);
//---main.js
if (window.Worker) {
//worker(aURL, options)
const worker = new Worker("worker.js");
worker.onmessage = e => {
const msg = e.data;
console.log(`From Worker thread: ${msg}`);
//CSS units - viewport - vh,vw,vmax,vmin
//Refered in - https://alligator.io/css/viewport-units/
body {
margin: 0;
padding: 0;
}
html, body {
overflow-x: hidden;
}
nav {
@santhosh17s
santhosh17s / throttle-debounce.js
Created April 23, 2018 09:40
Throttling & debounce technique in JS
// Referred in - https://codeburst.io/throttling-and-debouncing-in-javascript-b01cad5c8edf
// Start execute the function until, no more action request. Last requrest get performed.
// Use case - Auto Save, Submit, file send action
const debounce = (func, delay) => {
let inDebounce
return function() {
const context = this
const args = arguments
clearTimeout(inDebounce)
//Simple Class function
function API() {
this.name = 'This is API name';
}
//prototype function for share between the object
API.prototype.getName = function() {
//Take copy of this keyword
var self = this;
@santhosh17s
santhosh17s / sort.js
Created February 27, 2018 09:54
Sort by Two Fields in JS
var obj = [
{ "name":'a', "count1": 1, "count2": 9 },
{ "name":'b', "count1": 10, "count2": 4 },
{ "name":'c', "count1": 21, "count2": 93 },
{ "name":'d', "count1": 10, "count2": 10 },
{ "name":'e', "count1": 10, "count2": 2 },
{ "name":'f', "count1": 5, "count2": 9 },
];
@santhosh17s
santhosh17s / string.js
Created February 27, 2018 07:41
String reverse
//STRING REVERSE
var myStringa = "UI FRONTEND";
myStringa.split('').reverse().join(''); //"DNETNORF IU"
@santhosh17s
santhosh17s / index.html
Last active February 20, 2018 14:18
Angular 4 - CLI - Build and Deploy URL options
//Angular CLI - Build with base-href and deploy-url options
> ng build --prod --base-href /projectName --deploy-url /publicFolderName
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Single Page Application</title>