Skip to content

Instantly share code, notes, and snippets.

// https://stackoverflow.com/questions/61411776/is-js-native-array-flat-slow-for-depth-1
// [--jsperf is down--] https://jsperf.com/flat-array-depth-1 - I added this jsperf benchmark after this gist was created and the SO question was asked.
let TenThouWideArray = Array(1000).fill().map(el => Array(10).fill(1));
let TenThouNarrowArray = Array(10).fill().map(el => Array(1000).fill(1));
let TenMilWideArray = Array(10000).fill().map(el => Array(1000).fill(1));
let TenMilNarrowArray = Array(100).fill().map(el => Array(100000).fill(1));
let benchmarks = { TenThouWideArray, TenThouNarrowArray, TenMilWideArray, TenMilNarrowArray };
let implementations = [
class MaxStack {
stack = [];
checkMaxStack(popped) {
if (this.max === popped)
this.stack.pop();
}
feedMaxStack(values) {
const largest = Math.max(...values);
if (!this.max) {
@netanel-haber
netanel-haber / python_threads_http.py
Created September 11, 2021 19:46
Python Has Threads!
from requests import Session
from time import time
from functools import partial
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
import requests
def fetch(i, fetch_object=requests):
return fetch_object.get(f"https://jsonplaceholder.typicode.com/todos/{i}").json()[
"id"
@netanel-haber
netanel-haber / repo-rinse.sh
Last active August 13, 2023 11:45 — forked from nicktoumpelis/repo-rinse.sh
add --remote
# https://stackoverflow.com/questions/3796927/how-do-i-git-clone-a-repo-including-its-submodules/56833308#comment132351771_56833308
git submodule foreach --recursive git clean -xfd
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive --remote
@netanel-haber
netanel-haber / settings.json
Created May 22, 2024 08:11
uBlacklist settings
{
"blacklist": "*://pynative.com/*\n*://pythonbasics.org/*\n*://realpython.com/*\n*://thispointer.com/*\n*://www.codecademy.com/*\n*://www.codingem.com/*\n*://www.digitalocean.com/*\n*://www.educative.io/*\n*://www.edureka.co/*\n*://www.freecodecamp.org/*\n*://www.geeksforgeeks.org/*\n*://www.javatpoint.com/*\n*://www.learnbyexample.org/*\n*://www.programiz.com/*\n*://www.pythontutorial.net/*\n*://www.simplilearn.com/*\n*://www.thoughtco.com/*\n*://www.toppr.com/*\n*://www.tutorialspoint.com/*\n*://www.w3resource.com/*\n*://www.w3schools.com/*\n// Highlighting:\n@1*://*.baeldung.com/*\n@1*://*.docs.python.org/*\n@1*://*.stackoverflow.com/*\n*://www.tutorialsteacher.com/*\n*://towardsdatascience.com/*\n*://flexiple.com/*\n*://www.askpython.com/*\n*://pythonprinciples.com/*\n*://appdividend.com/*",
"blockWholeSite": false,
"skipBlockDialog": true,
"hideBlockLinks": false,
"hideControl": false,
"enablePathDepth": false,
"linkColor": "default",
"blockColor": "default",
"highlightColors": [