Skip to content

Instantly share code, notes, and snippets.

View tanvirstreame's full-sized avatar
💻
Superman

Tanvir Islam Streame tanvirstreame

💻
Superman
View GitHub Profile
@tanvirstreame
tanvirstreame / gist:1b0cc9968d3de40abff2c27d699b0d10
Last active December 9, 2022 20:42
Alternative to npm link is yalc
// Help in developing package locally
// https://medium.com/@sam-king/an-alternative-to-npm-link-cf9ab9408f56
// https://betterprogramming.pub/how-to-create-and-publish-react-typescript-npm-package-with-demo-and-automated-build-80c40ec28aca
npm i yalc -g
yalc publish
yalc add example-package@0.0.1
yalc remove example-package@0.0.1
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<style>
thead {
position: sticky;
position: -webkit-sticky;
top: 0;
screen.debug(undefined, Number.POSITIVE_INFINITY);
@tanvirstreame
tanvirstreame / rsa.js
Created August 19, 2022 11:13 — forked from sohamkamani/rsa.js
An example of RSA Encryption implemented in Node.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
})
@tanvirstreame
tanvirstreame / public_enc_example.sh
Created August 18, 2022 21:54 — forked from thinkerbot/public_enc_example.sh
Public-key encryption example using OpenSSL
#!/bin/bash
#
# Public-Key Encryption and Decryption
# * http://www.openssl.org/
# * http://barelyenough.org/blog/2008/04/fun-with-public-keys/
#
# Mac OS X 10.6.4
# OpenSSL 0.9.8l 5 Nov 2009
# Generate keys
@tanvirstreame
tanvirstreame / rsa.txt
Last active August 19, 2022 10:16
RSA
// Generate private.pem
openssl genrsa -out private.pem 512
// Generate public.pem
openssl rsa -in private.pem -pubout > public.pem
// Encrypt
openssl rsautl -in text.txt -out secret.enc -pubin -inkey public.pem -encrypt
// Decrypt
@tanvirstreame
tanvirstreame / two_pointers.js
Created June 11, 2022 14:04 — forked from scaryguy/two_pointers.js
Two Pointers Technique (in JavaScript)
// This gist is for my YouTube video which I tried to explain Window Sliding Technique.
// You can watch it from here: https://youtu.be/guDU5HnLqAs
// Given a sorted array A (sorted in ascending order), having N integers,
// find if there exists any pair of elements (A[i], A[j]) such that
// their sum is equal to X.
//
// Input: A = [2,3,4,5,6,7,8,9], k= 10
// Output: true
// NOTE: We slightly changed the question and the output in the video. We're returning pair indexes as an array.
mongorestore --uri <link> -d <new-db-name> dump/
@tanvirstreame
tanvirstreame / PurgeCss in Create React App without ejecting
Created May 28, 2022 14:03 — forked from DyadicGit/PurgeCss in Create React App without ejecting
remove unused css (PurgeCss) in Create React App without ejecting
//package.json
{
...
"devDependencies": {
...
"purgecss": "^3.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && npm run purge-css",
@tanvirstreame
tanvirstreame / gist:56142d5c12ad5c98894c9d4461d829fd
Last active March 17, 2022 13:00
Mongo extra instance in same server
cp /etc/mongod.conf /etc/mongod2.conf
cd /lib/systemd/system
cp mongod.service mongod2.service
edit ta service config and add /etc/mongod2.conf
sudo chown -R mongodb:mongodb /root/database/replica_database*
sudo systemctl start mongod2.service
sudo systemctl status mongod2.service