View flow-maybe.js
// @flow
// https://flow.org/en/docs/types/unions/#toc-disjoint-unions
type Response = {
success: boolean,
value?: boolean,
error?: string
};
// works.
View flow-union-refinement.js
// @flow
// https://flow.org/en/docs/types/unions/#toc-unions-refinements
// flow can refine on the union.
// and knows when the code is operating on a number here for eg.
// works
function toStringPrimitivesGood(value: number | boolean | string): string { // Error!
if (typeof value === 'number') {
return value.toLocaleString([], { maximumSignificantDigits: 3 }); // Works!
View gist:6b22b5ddf7f3e896c8bac9ae910cf6e9
// chaining then. chain is then -> catch -> then
// case 1: promise is resolved
new Promise((resolve, reject) => resolve("some data")).then(data => { alert(`data: ${data}`); return data; }).catch(err => { alert(`err: ${err}`); return Promise.reject(err); }).then(data => { alert(`data again: ${data}`); return data; })
// case 2: promise is rejected
new Promise((resolve, reject) => resolve("some data")).then(data => { alert(`data: ${data}`); return data; }).catch(err => { alert(`err: ${err}`); return Promise.reject(err); }).then(data => { alert(`data again: ${data}`); return data; })
View rust-slice-panics.rs
fn main() {
let mut s = String::from("hello world");
let len = first_word(&s);
{
let word = &s[0..len];
println!("word is {}", word); // word is hello
}
s.clear();
let word = &s[0..len]; // thread 'main' panicked at 'byte index 5 is out of bounds of ``', src/libcore/str/mod.rs:2144
println!("word is {}", word);
View node.eslint.json
{
"env": {
"node": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": [
View use-currying.js
let MODIFY = "MODIFY";
let ADD = "ADD";
let DELETE = "DELETE";
function checkAction(actions, recon, action, cb) {
if (actions.indexOf(action) > -1) {
cb(recon);
}
}
View deep-es6-destructuring.js
const params = {
pagination: {
prevId:1,
nextId: 3
},
location: {
query: {
step: 10
}
}
View better react devtools.md

better react devtools

  • which React component is rendered at the top-level
  • performance information
  • error page
View misc.txt
karl.jakober [7:13 AM]
looking for a good alternative to webview.ContentWindow.postMessage for electron, people are saying webview.send is a good alternative, but that requires ipc to be invoked inside the webview itself
View README.md

packaging an Electron app on windows, using "Node.js command prompt"

steps to reproduce:

  1. git clone https://github.com/deepak/electron-webview-todo/ && cd
  2. npm install
  3. npm install -g electron-forge
  4. npm run package:win32

packaging works on windows though: