I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.
I read the spec, some blog posts, and looked through some code. I learned how to
I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.
I read the spec, some blog posts, and looked through some code. I learned how to
# See list of docker virtual machines on the local box | |
$ docker-machine ls | |
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS | |
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1 | |
# Note the host URL 192.168.99.100 - it will be used later! | |
# Build an image from current folder under given image name | |
$ docker build -t gleb/demo-app . |
<--- | |
_._ _..._ .-', _.._(`)) | |
'-. ` ' /-._.-' ',/ | |
) \ '. | |
/ _ _ | \ | |
| a a / | | |
\ .-. ; | |
'-('' ).-' ,' ; | |
'-; | .' | |
\ \ / |
[ | |
{ | |
"name":"Avon", | |
"abbreviation":"AVN", | |
"country":"England" | |
}, | |
{ | |
"name":"Bedfordshire", | |
"abbreviation":"BDF", | |
"country":"England" |
// ==UserScript== | |
// @name Steam Broadcast Chat Cleaner | |
// @namespace http://jzhang.net/ | |
// @version 3.1.1 | |
// @description Cleans up Steam Broadcast chat | |
// @author waylaidwanderer | |
// @include http://steamcommunity.com/broadcast/watch/* | |
// @require //code.jquery.com/jquery-1.11.3.min.js | |
// @downloadURL https://gist.github.com/waylaidwanderer/6bb095e0731ef41d49dc/raw/SteamBroadcastChatCleaner.user.js | |
// @updateURL https://gist.github.com/waylaidwanderer/6bb095e0731ef41d49dc/raw/SteamBroadcastChatCleaner.user.js |
// store.js | |
let {store, handler} = sto(initialState, reduceFn); // where reduceFn: function(currentState, action, ...args){} | |
dispatcher.register(handler); | |
export store; | |
// elsewhere | |
store.get() // -> current state | |
store.toObservable() // -> to be used with .observe() |
let map = new Map(); | |
map.set("a", 1); | |
map.set("b", 2); | |
map.set("c", 3); | |
let obj = Array.from(map).reduce((obj, [key, value]) => ( | |
Object.assign(obj, { [key]: value }) // Be careful! Maps can have non-String keys; object literals can't. | |
), {}); | |
console.log(obj); // => { a: 1, b: 2, c: 3 } |
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
import java.util.Collection; | |
import java.util.List; | |
import java.util.Random; | |
public class Markov<T> | |
{ | |
protected final MarkovChain<T> root; | |
protected final MarkovChain<T> starters; |
# CLOSURES IN RUBY Paul Cantrell http://innig.net | |
# Email: username "cantrell", domain name "pobox.com" | |
# I recommend executing this file, then reading it alongside its output. | |
# | |
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments, | |
# then trying to guess the output of the code! | |
# A closure is a block of code which meets three criteria: | |
# |