Skip to content

Instantly share code, notes, and snippets.

View pooooriya's full-sized avatar
💭
To be or not to be ,that Is a question

Pouriya Babaali pooooriya

💭
To be or not to be ,that Is a question
View GitHub Profile
@arvinall
arvinall / create-timer.js
Last active May 10, 2023 13:39
Create multiple timers with just one setTimeout call
function createPromise () {
let resolve, reject
// eslint-disable-next-line promise/param-names
const promise = new Promise((...args) => ([resolve, reject] = args))
return { promise, resolve, reject }
}
const remove = (a, y) => (
@ali-master
ali-master / redux-from-scratch.ts
Created July 9, 2021 19:12
A simple redux from scratch
/**
* Redux
* - getState()
* - subscribe()
* - dispatch() -> ui -> state
* - combineReducer
*
*
* - replaceReducer
* - injectReducer
@ali-master
ali-master / scratch_16.js
Created December 8, 2020 13:57
Find missing number in an array of numbers
// Find theoretical sum of the consecutive numbers using a variation of Gauss Sum.
// Formula: [(N * (N + 1)) / 2] - [(M * (M - 1)) / 2];
// N is the upper bound and M is the lower bound
function missingNumber(n) {
let upperBound = 0;
let lowerBound = 99999999;
let sum = 0;
for (let i = 0; i < n.length; i++) {
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active July 15, 2024 22:10
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@MoienTajik
MoienTajik / iranian-phone-numbers-regex.md
Last active June 10, 2024 22:59
Regex For Iranian Mobile Phone Numbers

Regex For Iranian Phone Numbers

This regex supports all kinds of Iranian mobile phone numbers :

^(\+98|0)?9\d{9}$


Regex Visualized