Skip to content

Instantly share code, notes, and snippets.

@Tin
Tin / print_react_router.js
Last active Mar 25, 2017
iterate react-router config and print out all paths
View print_react_router.js
// Say we have routes configuration like
const routes = [
{
"childRoutes": [
{
"path": "/"
},
{
"path": "/anonymous-landing"
},
@Tin
Tin / server-ext.js
Last active Jan 25, 2016
hapi plugin to handle custom string array query param format
View server-ext.js
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) {
View 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 Apr 26, 2011
Coffee script version of jQuery-Retina-Plugin
View Coffeescript-version-of-baotuo-jQuery-Retina-Plugin.coffee
$ = 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