Skip to content

Instantly share code, notes, and snippets.

View SiddharthaChowdhury's full-sized avatar
🌄
Journey

Austin4Silvers SiddharthaChowdhury

🌄
Journey
  • Germany
View GitHub Profile
interface IKeyEventsListeners {
keyup: { [componentId: string]: (event: KeyboardEvent) => void };
keydown: { [componentId: string]: (event: KeyboardEvent) => void };
}
export interface IKeySubscription {
unsubscribe: () => void;
}
const keyListener = (<T extends keyof IKeyEventsListeners>() => {
@SiddharthaChowdhury
SiddharthaChowdhury / async-devtool.js
Last active May 10, 2022 11:32
Promise-settimeout-setinterval interceptor for devtool
const initDevToolCode = () => {
const devToolSignalName = 'DEVTOOL_ASYNC_MONITOR__ASYNC_STATUS_CHANGE';
const getNameId = (customName) => customName || `${(Math.random() + 1).toString(36).substring(7)}-${+ new Date()}`;
// PubSub outside our app
var eventPool = (function() {
var topics = {};
var hOp = topics.hasOwnProperty;
return {
@SiddharthaChowdhury
SiddharthaChowdhury / main.js
Created February 4, 2021 12:17
VideoPlayerDRM_LIVE
(function () {
'use strict';
/**
* Displays logging information on the screen and in the console.
* @param {string} msg - Message to log.
*/
function log(msg) {
var logsEl = document.getElementById('logs');
import AWS from 'aws-sdk';
import multer, { FileFilterCallback } from "multer"
import multerS3 from "multer-s3";
import {Request} from 'express';
import { v4 as uuidv4 } from 'uuid';
AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_KEY,
signatureVersion: 'v4'
@SiddharthaChowdhury
SiddharthaChowdhury / utilResponsive.js
Last active August 21, 2019 09:45
Conditional Rendering
export const getDeviceTypeInfo = () => {
const { width, height } = getWindowDimension()
const buildDeviceDetails = {
deviceType: '',
deviceTypeVariant: '',
orientation: 'Portrait',
width,
height,
isFallback: false
}
@SiddharthaChowdhury
SiddharthaChowdhury / Approach2.js
Last active March 13, 2019 17:09
Tree Hierarchy parent-child from array of objects
console.time("execution");
var posts = [{
"id": 1,
"name": "Earth",
"children": [2, 3]
}, {
"id": 2,
"name": "Asia",
"children": []
}, {
@SiddharthaChowdhury
SiddharthaChowdhury / jwt-module.js
Last active February 21, 2024 14:51
Implementation of JWT using private and public keys
const fs = require('fs');
const jwt = require('jsonwebtoken');
// http://travistidwell.com/blog/2013/09/06/an-online-rsa-public-and-private-key-generator/
// use 'utf8' to get string instead of byte array (1024 bit key)
var privateKEY = fs.readFileSync('./private.key', 'utf8'); // to sign JWT
var publicKEY = fs.readFileSync('./public.key', 'utf8'); // to verify JWT
module.exports = {
sign: (payload, $Options) => {
/*
module.exports = {
onlyNumber: function(sample){
// returns false if input is not a number
return /^([0-9]+)$/.test(sample);
},
onlyAlphabets: function(sample){
// returns false if input is not a string of alphabets
return /^([a-z]+)$/.test(sample);
},
module.exports = {
uniqueID: function(){
const length = 38;
const unixTstamp = Math.round(new Date().getTime()/1000);
const chars = Math.random().toString(36).slice(2)
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
return result;
},
randomString: function(){ // returns 128 bit string
# Change directory -> to your login directory
cd ~
# ---------------------------------- J A V A dependency installation
# Installing Java 8
# Add Oracle Java PPA to apt
sudo add-apt-repository -y ppa:webupd8team/java
# Update repo