Skip to content

Instantly share code, notes, and snippets.

View stagas's full-sized avatar
🤸

stagas stagas

🤸
View GitHub Profile
Number.prototype.__defineGetter__('f', function() { return this.toFixed(2) })
var b = 2345.324234
console.log('b:', b.f)
// outputs: 2345.32
@stagas
stagas / testing
Created November 10, 2010 02:40
just a test
test here!
$ npm --loglevel verbose uninstall yui3
npm info it worked if it ends with ok
npm verb cli []
npm info using npm@0.2.7-3
npm info using node@v0.2.4
npm verb config file /home/plato/.npmrc
npm verb config file /usr/local/etc/npmrc
npm info removing [ [ 'yui3', '0.5.9' ] ]
npm ERR! Error: ENOENT, No such file or directory '/usr/local/lib/node/.npm/yui3/0.5.9/package/package.json'
npm ERR! at node.js:772:9
$ npm --loglevel verbose uninstall yui3
npm info it worked if it ends with ok
npm verb cli []
npm info using npm@0.2.7-3
npm info using node@v0.2.4
npm verb config file /home/plato/.npmrc
npm verb config file /usr/local/etc/npmrc
npm info removing [ [ 'yui3', '0.5.9' ] ]
npm verb caching /usr/local/lib/node/.npm/yui3/0.5.9/package/package.json
npm info preuninstall yui3@0.5.9
meryl.p('GET /lib/*', function(req, res, next) {
var pathname = req.params.pathname
, filename = path.join(publicDir, pathname)
fs.readFile(filename, 'utf8', function(err, data) {
pathname = pathname.replace(/^\/lib\//, "").replace(/.js$/,"")
res.send("require.module('" + pathname + "', function(module, exports, require) {\n// start module: " + pathname + "\n\n" + data + "\n\n// end module: "+ pathname +"\n});\n")
})
})
// Flash websockets policy server
net.createServer(function (socket){
socket.write([
'<?xml version="1.0"?>'
, '<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">'
, '<cross-domain-policy>'
, '<allow-access-from domain="*" to-ports="*"/>'
, '</cross-domain-policy>'
].join('\n'))
// node-github leak?
var GitHubApi = require('github').GitHubApi
, github = new GitHubApi(true)
, repoApi = github.getRepoApi()
setInterval(function() {
repoApi.getRepoLanguages('ry', 'node', function(err, data) {
if (!err) console.log('.')
})
server.on('error', function (e) {
if (e.errno == require('constants').EADDRINUSE) {
log('Address in use, retrying...')
setTimeout(function () {
server.close()
server.listen(PORT, HOST)
}, 1000)
}
})
@stagas
stagas / check.js
Created December 1, 2010 12:17
typeof alternative
// typeof alternative
var check = function() {
var args = Array.prototype.slice.call(arguments)
, o = args[0]
, a = args.slice(1)
if (typeof o !== 'undefined' && (typeof o[a[0]] !== 'undefined') || !a.length && typeof o !== 'undefined')
if (a.length > 1) {
b = o[a[0]]
{ message: 'Parse Error',
stack: [Getter/Setter],
bytesParsed: 21260 } [ ' at Client.onData [as ondata] (http.js:889:27)',
' at Client._onReadable (net.js:762:27)',
' at IOWatcher.onReadable [as callback] (net.js:276:10)' ]