This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Convert JavaScript string to UTF-8 bytes in modern browsers using the File API | |
| // callback function will be called with UTF8 bytes in Uint8Array | |
| // | |
| // jsPerf test reveals this method is slower than looping over each character. | |
| // http://jsperf.com/convert-javascript-string-to-utf-8-bytes-using-file-api | |
| function toUTF8(string, cb) { | |
| var reader = new FileReader(); | |
| reader.onload = function(evt) { | |
| cb(new Uint8Array(reader.result)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FS = require("fs") | |
| Path = require("path") | |
| Cheerio = require("cheerio") | |
| Hogan = require("hogan.js") | |
| htmlFile = process.argv[2] | |
| html = FS.readFileSync process.argv[2], encoding: "utf8" | |
| # console.log html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ npm -v | |
| 1.3.0 | |
| don@ironforge:~ | |
| $ npm outdated -g | |
| [email protected] /usr/local/lib/node_modules/c-pm/node_modules/superagent current=0.9.10 | |
| [email protected] /usr/local/lib/node_modules/uglify-js/node_modules/optimist current=0.3.7 | |
| [email protected] /usr/local/lib/node_modules/docco/node_modules/commander current=1.2.0 | |
| [email protected] /usr/local/lib/node_modules/recess/node_modules/less current=1.3.3 | |
| [email protected] /usr/local/lib/node_modules/yo/node_modules/yeoman-generator current=0.11.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TimeUtil = | |
| now: Date.now or -> new Date().getTime() | |
| # Returns wrapped function that no-ops if called within specified | |
| # duration in milliseconds of last call. | |
| throttle: (duration, fn) -> | |
| last = 0 | |
| -> | |
| now = TimeUtil.now() | |
| if now - last < duration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 info it worked if it ends with ok | |
| 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ] | |
| 2 info using [email protected] | |
| 3 info using [email protected] | |
| 4 verbose publish [ '.' ] | |
| 5 verbose read json /Users/don/dev/github/node-tld/package.json | |
| 6 verbose cache add [ '.', null ] | |
| 7 verbose cache add name=undefined spec="." args=[".",null] | |
| 8 verbose parsed url { protocol: null, | |
| 8 verbose parsed url slashes: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import time | |
| def terminal(cmd): | |
| local("osascript -e 'tell application \"Terminal\" to do script \"%s\"'" % cmd) | |
| def debugger(opts): | |
| url = "http://0.0.0.0:8080/debug?port=5858" | |
| build() | |
| terminal("node %(opts)s %(cwd)s/app.js" % { "opts": opts, "cwd": os.getcwd() }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if process.hrtime | |
| console.log "using process.hrtime for timing" | |
| clock = process.hrtime | |
| else | |
| console.log "using microtime for timing" | |
| Microtime = require('microtime') | |
| clock = (s) -> | |
| t = Microtime.nowStruct() | |
| t[1] *= 1000 # microseconds to nanoseconds | |
| if s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Delayed resize task runner | |
| class DeferredResizer | |
| constructor: -> | |
| @timer = null | |
| @tasks = [] | |
| addTask: (task) -> | |
| @tasks.push(task) if @tasks.indexOf(task) is -1 | |
| doTasks: => | |
| @timer = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- TLC - The Tiny Lua Cocoa bridge | |
| -- Note: Only tested with LuaJit 2 Beta 9 on x86_64 with OS X >=10.7.3 & iPhone 4 with iOS 5 | |
| -- Copyright (c) 2012, Fjölnir Ásgeirsson | |
| -- Permission to use, copy, modify, and/or distribute this software for any | |
| -- purpose with or without fee is hereby granted, provided that the above | |
| -- copyright notice and this permission notice appear in all copies. | |
| -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parseSDP = (text) -> | |
| return if not text | |
| lines = text.split('\r\n') | |
| readSession lines | |
| readSession = (lines) -> | |
| session = {} | |
| line = null | |
| while line = lines.shift() | |
| name = line.charAt(0) |