Skip to content

Instantly share code, notes, and snippets.

View dsngo's full-sized avatar
🔧
Fixing bugs from fixing bugs.

Daniel N. dsngo

🔧
Fixing bugs from fixing bugs.
View GitHub Profile
@dsngo
dsngo / serialize.js
Created February 24, 2023 09:54 — forked from istarkov/serialize.js
Serialize promise calls (run promises sequentially)
// promise
const sleep = (timeout, v) => new Promise(r => setTimeout(() => r(v), timeout));
// series to call
const series = [() => sleep(1000, 1), () => sleep(1000, 2), () => sleep(1000, 3)];
// serialize
const r = series
.reduce(
(m, p) => m.then(v => Promise.all([...v, p()])),
Promise.resolve([])
@dsngo
dsngo / fibonacci-generator.js
Created January 30, 2022 08:55 — forked from jfairbank/fibonacci-generator.js
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@dsngo
dsngo / ccdl.command
Created May 28, 2021 03:58 — forked from ayyybe/ccdl.command
Adobe Offline Package Generator v0.1.2 (macOS only) --- No longer being updated.
#!/bin/bash
CYAN="$(tput bold; tput setaf 6)"
RESET="$(tput sgr0)"
clear
if command -v python3 > /dev/null 2>&1; then
if [ $(python3 -c "print('ye')") = "ye" ]; then
clear
@dsngo
dsngo / iterm2.md
Created November 25, 2020 14:51 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@dsngo
dsngo / introrx.md
Created October 26, 2020 14:30 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@dsngo
dsngo / bitwise-hacks.js
Created August 26, 2020 06:18 — forked from leodutra/bitwise-hacks.js
Fast Int Math + Bitwise Hacks For JavaScript
// http://michalbe.blogspot.com.br/2013/03/javascript-less-known-parts-bitwise.html
// http://jsperf.com/bitwise-vs-math-object
// http://united-coders.com/christian-harms/results-for-game-for-forfeits-and-the-winner-is/
// https://mudcu.be/journal/2011/11/bitwise-gems-and-other-optimizations/
// https://dreaminginjavascript.wordpress.com/2009/02/09/bitwise-byte-foolish/
// http://jsperf.com/math-min-max-vs-ternary-vs-if/24
"use strict";
var PI = Math.PI;
@dsngo
dsngo / multiple_ssh_setting.md
Created July 11, 2020 09:15 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"