Skip to content

Instantly share code, notes, and snippets.

const createKeyEventObserver = () => {
const PRESS_THRESHOULD_MS = 500
const LONG_PRESS_TIME_MS = 1500
const keyDowns = fromEvent(document.body, 'keydown')
const keyUps = fromEvent(document.body, 'keyup')
const source = keyDowns
.pipe(
merge(keyUps),
st=>start: Start:>http://www.google.com[blank]
e=>end:>http://www.google.com
op1=>operation: My Operation
sub1=>subroutine: My Subroutine
cond=>condition: Yes
or No?:>http://www.google.com
io=>inputoutput: catch something...
para=>parallel: parallel tasks
0x277E034c59dDD2c56539459B0C566075685a681f
@roadmanfong
roadmanfong / app.js
Created October 5, 2016 07:53 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
let tree = {
name: 'root',
children: [
{
name: 'a',
children: [
{ name: 'd' },
{ name: 'e' }
]
@roadmanfong
roadmanfong / Package Control.sublime-settings
Created July 17, 2015 04:02
Package Control.sublime-settings
{
"in_process_packages":
[
],
"installed_packages":
[
"All Autocomplete",
"AutoFileName",
"Autoprefixer",
"Babel",
@echo off
rem Based on a gist for adding sublime text 2:
rem https://gist.github.com/mrchief/5628677
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3" /t REG_SZ /v "" /d "Open with ST3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@echo off
rem Based on a gist for adding sublime text 2:
rem https://gist.github.com/mrchief/5628677
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3" /t REG_SZ /v "" /d "Open with ST3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@roadmanfong
roadmanfong / promiseWhile.js
Last active November 22, 2018 15:14
promiseWhile demo
function promiseWhile(condition, body) {
var dfd = $.Deferred();
function loop() {
if (!condition()) return dfd.resolve();
body.apply(this, arguments)
.done(loop)
.fail(dfd.reject);
}
//call loop async