Skip to content

Instantly share code, notes, and snippets.

View sushiljainam's full-sized avatar
💻
Working from home

Sushil Jain sushiljainam

💻
Working from home
View GitHub Profile
{
"basics": {
"name": "Sushil Kumar Jain",
"label": "Sr Software Engineer",
"image": "",
"email": "sushiljain1993@gmail.com",
"phone": "(912) 555-4321",
"url": "https://johndoe.com",
"summary": "A summary of John Doe…",
"location": {
@sushiljainam
sushiljainam / redirect.js
Created June 15, 2021 07:16
https redirect via browser
if (location.protocol !== 'https:') {
location.replace('https:'+location.href.substring(location.protocol.length));
}
@sushiljainam
sushiljainam / 2powers100000.txt
Created January 15, 2018 20:55
some huge powers of 2
9990020930143845079440327643300335909804291390541816917715292738631458324642573483274873313324496504031643944455558549300187996607656176562908471354247492875198889629873671093246350427373112479265800278531241088737085605287228390164568691026850675923517914697052857644696801524832345475543250292786520806957770971741102232042976351205330777996897925116619870771785775955521720081320295204617949229259295623920965797873558158667525495797313144806249260261837941305080582686031535134178739622834990886357758062104606636372130587795322344972010808486369541401835851359858035603574021872908155566580607186461268972839794621842267579349638893357247588761959137656762411125020708704870465179396398710109200363934745618090601613377898560296863598558024761448933047052222860131377095958357319485898496404572383875170702242332633436894423297381877733153286944217936125301907868903603663283161502726139934152804071171914923903341874935394455896301292197256417717233543544751552379310892268182402452755752094704642185943862865632744231
/*
* @Author: sushiljainam
* @Date: 2018-01-03 12:20:39
* @Last Modified by: sushiljainam
* @Last Modified time: 2018-01-03 12:31:37
*/
//----------------------- common
var afterLongWork = function () {
//regular expressions
v = /^a/.test('asdasaabb');
console.log("/^a/.test('asdasaabb')", v);
console.log("/.*/.test('/^a+b+$/')", /.*/.test('/^a+b+$/'));
console.log("/^\/.*\/$/.test('/^a+b+$/')", /^\/.*\/$/.test('/^a+b+$/'));
console.log("/^\/.\/$/.test('/^a+b+$/')", /^\/.\/$/.test('/^a+b+$/'));
console.log("/^a/.test('/^a+b+$/')", /^a/.test('/^a+b+$/'));
console.log("/^a/.test('/^a+b+$/')", /^a/.test('/^a+b+$/'));
//s = readline();
@sushiljainam
sushiljainam / linkedList.js
Last active April 5, 2017 20:30
linked list using JS, simple
var node = function (value){
this.value = value;
this.next = null;
return this;
}
var list = function (){
this.head = null;
return this;
}
@sushiljainam
sushiljainam / mathQue1.txt
Created February 21, 2017 16:30
There were 200 fishes in an aquarium, 99% of which were red. How many red fishes must be removed to make the percentage of red fishes 98%?
Solve this one!
Q. There were 200 fishes in an aquarium, 99% of which were red.
How many red fishes must be removed to make
the percentage of red fishes 98%?
Solution:
Initially
total: 200, red: 198, percent:99%
If we remove 1 red fish -
@sushiljainam
sushiljainam / rankName.php
Created February 18, 2017 18:08
php code to find rank of a name
function findRankByString($input){
$input = strtolower($input);
if(strlen($input) <= 1){
return 1;
}
$chars = [];
for ($i = 0; $i < strlen($input); $i++) {
array_push($chars, $input[$i]);
};
@sushiljainam
sushiljainam / rankname.js
Last active February 13, 2017 13:50
find alphabetical rank of a name
/*
* @Author: Sushil Jain
* @Date: 2017-02-13 17:06:37
* @Last Modified by: csnodejs4
* @Last Modified time: 2017-02-13 19:19:49
*/
'use strict';
var input = "sushil";
@sushiljainam
sushiljainam / combo.js
Last active February 20, 2017 14:15
to print all combinations for states, given length
function comb(len, states, rules){
if(len>16){
// return "out of limit, put force if you know better";
}
var states = states || ["0","1"];
var pos = [];
var powers = [];
for (var i = 0; i < len; i++) {
pos.push(0);