Skip to content

Instantly share code, notes, and snippets.

View kevinwucodes's full-sized avatar

Kevin Wu kevinwucodes

View GitHub Profile
@kevinwucodes
kevinwucodes / realtime.html
Created June 27, 2014 07:12
plotting realtime coordinates for hackathon's adopt-a-block
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<SCRIPT TYPE="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></SCRIPT>
@kevinwucodes
kevinwucodes / fileupload.html
Created September 10, 2014 06:33
file upload test using FormData and XMLHttpRequest
<html>
<head>
<title>FormData file test</title>
<SCRIPT TYPE="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></SCRIPT>
</head>
<body>
<input id="filebutton" type='file' />

Keybase proof

I hereby claim:

  • I am kevinwucodes on github.
  • I am kevinwu (https://keybase.io/kevinwu) on keybase.
  • I have a public key whose fingerprint is 5901 231A 16D9 AA4B A9A4 1EE1 6826 2134 727D 8CB1

To claim this, I am signing this object:

@kevinwucodes
kevinwucodes / async-await-reject.js
Created December 7, 2016 00:24
async await sandbox
const prom = () => new Promise((resolve, reject) => {
setTimeout(() => {
reject('got rejected')
}, 2000)
})
const foo = async () => {
try {
console.log('good', await prom())
} catch(err) {
@kevinwucodes
kevinwucodes / react-components-props-spread-operator.js
Last active December 12, 2016 21:57
react components prop spread operator sandbox
//http://www.webpackbin.com/NkMEv-_7M
import React from 'react';
import {render} from 'react-dom';
import HelloWorld from './HelloWorld.js';
const divContainer = document.querySelector('#app')
const obj1 = {
first: 'kevin'
@kevinwucodes
kevinwucodes / onename.txt
Created August 27, 2017 20:03
onename verification
Verifying that "kevinwu.id" is my Blockstack ID. https://onename.com/kevinwu
### Keybase proof
I hereby claim:
* I am kevinwucodes on github.
* I am kevinwu (https://keybase.io/kevinwu) on keybase.
* I have a public key whose fingerprint is 1CD7 0CF4 B2B2 787F A3A0 93FF 9EE9 8632 FCFC AA9D
To claim this, I am signing this object:
@kevinwucodes
kevinwucodes / koa-server.md
Last active December 28, 2023 11:31
understanding koajs middleware architecture stack order

Notes

Koa middleware cascade in a more traditional way as you may be used to with similar tools - this was previously difficult to make user friendly with node's use of callbacks. However with async functions we can achieve "true" middleware. Contrasting Connect's implementation which simply passes control through series of functions until one returns, Koa invoke "downstream", then control flows back "upstream".

The following example responds with "Hello World", however first the request flows through the x-response-time and logging middleware to mark when the request started, then continue to yield control through the response middleware. When a middleware invokes next() the function suspends and passes control to the next middleware defined. After there are no more middleware to execute downstream, the stack will unwind and each middleware is resumed to perform its upstream behaviour.

const Koa = require('koa');
const app = new Koa();
@kevinwucodes
kevinwucodes / readme.md
Last active October 11, 2017 00:28
All about transformers and reducers (aka transducers)

Eric Elliott had an interesting tweet that intrigued me: https://twitter.com/_ericelliott/status/912407669683609600?s=03

Here's what he posted:

const map = transform => reducer => ((acc, current) => reducer(acc, transform(current)))

const filter = predicate => reducer => (
  (acc, current) => predicate(current) ? reducer(acc, current) : acc
)
@kevinwucodes
kevinwucodes / using-debounce.md
Last active October 16, 2017 01:11
ways to use debounce in React