Skip to content

Instantly share code, notes, and snippets.

@kmontg
kmontg / Promise.js
Created May 20, 2017 01:28
Promise Implementation
'use strict';
let [PENDING, FULFILLED, REJECTED] = [0, 1, 2];
let pn = 0;
let tick = 0;
console.log('Executing Main Script...');
let clr = setInterval(() => {
console.log('TICK #' + (++tick) + '...');
}, 0);
@jpierson
jpierson / switch-local-git-repo-to-fork.md
Last active December 26, 2022 21:48 — forked from jagregory/gist:710671
How to move to a fork after cloning

If you are like me you find yourself cloning a repo, making some proposed changes and then deciding to later contributing back using the GitHub Flow convention. Below is a set of instructions I've developed for myself on how to deal with this scenario and an explanation of why it matters based on jagregory's gist.

To follow GitHub flow you should really have created a fork initially as a public representation of the forked repository and the clone that instead. My understanding is that the typical setup would have your local repository pointing to your fork as origin and the original forked repository as upstream so that you can use these keywords in other git commands.

  1. Clone some repo (you've probably already done this step)

@montanaflynn
montanaflynn / pget.go
Last active January 17, 2025 17:07
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
@hectorguo
hectorguo / getLocalIP.js
Last active November 25, 2024 13:47
Get local IP address through Javascript
/**
* Get Local IP Address
*
* @returns Promise Object
*
* getLocalIP().then((ipAddr) => {
* console.log(ipAddr); // 192.168.0.122
* });
*/
function getLocalIP() {
@tonytonyjan
tonytonyjan / 1-README.md
Last active June 21, 2023 06:14
Remote React Components Loading
@vasanthk
vasanthk / System Design.md
Last active April 19, 2025 20:36
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@wcharczuk
wcharczuk / word_path.py
Last active October 22, 2016 03:25
Generate "Word Path" Between Two Words
#goal is to compute the 'path' from one valid word to another by only changing one letter at a time (forming valid words inbetween)
#example:
# cat -> dog
# cat -> cot -> cog -> dog
import sys
import string
alphabet = string.ascii_lowercase
@staltz
staltz / introrx.md
Last active April 19, 2025 05:15
The introduction to Reactive Programming you've been missing
@mikaelbr
mikaelbr / destructuring.js
Last active February 20, 2025 13:00
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
var Promise = function(wrappedFn, wrappedThis) {
this.then = function(wrappedFn, wrappedThis) {
this.next = new Promise(wrappedFn, wrappedThis);
return this.next;
};
this.run = function() {
wrappedFn.promise = this;
wrappedFn.apply(wrappedThis);
};