Skip to content

Instantly share code, notes, and snippets.

View wh1100717's full-sized avatar

Eric Wang wh1100717

  • Shenzhen, China
View GitHub Profile
@wh1100717
wh1100717 / viewport
Last active August 29, 2015 14:24
getViewport
function getViewport() {
var viewPortWidth;
var viewPortHeight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
viewPortWidth = window.innerWidth,
viewPortHeight = window.innerHeight
}
@wh1100717
wh1100717 / bson.coffee
Last active August 29, 2015 14:09
generate ObjectID
define (require, exports, module) ->
'use strict'
BinaryParser = require('lib/binary-parser')
hexTable = ((if i <= 15 then '0' else '') + i.toString(16) for i in [0...256])
class ObjectID
constructor: (id, _hex) ->
@_bsontype = 'ObjectID'
@wh1100717
wh1100717 / Define-root-var-in-Coffeescript
Last active August 29, 2015 14:02
Global var in Coffeescript
# 如果是 node 环境,则通过 exports 来获取全局域
# 如果是 BOM 环境,则通过 this 来获取全局域
root = exports ? this