Skip to content

Instantly share code, notes, and snippets.

@Tin
Tin / print_react_router.js
Last active March 25, 2017 04:32
iterate react-router config and print out all paths
// Say we have routes configuration like
const routes = [
{
"childRoutes": [
{
"path": "/"
},
{
"path": "/anonymous-landing"
},
@Tin
Tin / server-ext.js
Last active January 25, 2016 20:18
hapi plugin to handle custom string array query param format
var Url = require('url');
// This ext add support of string-array value in query param
// syntax is `?param=[value1, value2]` which return `{ param: ['value1', 'value2'] }`
// It turns out that we don't need this at all. Because even hapi.js 8.x support `param=value1&param=value2` which is more standard!
// hapi.js supports param=value1&param=value2
server.ext({
type: 'onRequest',
method: function(request, reply) {
@Tin
Tin / keybase.md
Created October 27, 2014 06:56
keybase.md

Keybase proof

I hereby claim:

  • I am Tin on github.
  • I am diamondtin (https://keybase.io/diamondtin) on keybase.
  • I have a public key whose fingerprint is F56F 506D C1AA BE4A E06C 9B3D 7076 9DED D0B5 EEB1

To claim this, I am signing this object:

@Tin
Tin / Coffeescript-version-of-baotuo-jQuery-Retina-Plugin.coffee
Created April 26, 2011 10:07
Coffee script version of jQuery-Retina-Plugin
$ = JQuery
$.fn.retina = (options) ->
settings = { 'retina-background': false, 'retina-suffix': "@2x" }
if options
$.extend settings, options
preload = (path, callback) ->
img = new Image()
img.onload = ->
callback img