This file contains 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
/* | |
* The Daily Voice | |
* Copyright 2012 Daily Voice (www.DailyVoice.com) | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains 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
/** | |
* With some magic getters/setters you can achieve similar syntax like Ruby | |
**/ | |
function foo() { console.log('im foo') } | |
foo.__defineGetter__('new', function(){ return new foo }) | |
f = foo.new | |
// >> im foo | |
void console.log((new foo) instanceof foo) | |
// >> im foo |
This file contains 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
function Module(scope, global){ | |
this.scope = scope; | |
this.exports = {}; | |
this.global = global || window || this; | |
} | |
function ModuleError(message) { | |
Error.call(this); | |
Error.captureStackTrace(this, ModuleError); | |
this.name = 'ModuleError'; |
This file contains 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
var http, server, emit | |
http = require('http') | |
server = http.createServer(function () { console.log('ok') }) | |
emit = emit = server.emit | |
server.emit = function () { | |
// log it out | |
console.log('[server]:', arguments[0]) | |
// apply old emit | |
emit.apply(this, arguments); | |
}; |
This file contains 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
var mongoose = require('mongoose'), | |
Config = mongoose.model('Config') | |
exports.create = function(req, res) { | |
var conf = new Config(req.body); | |
console.log(conf) | |
conf.save(function(err) { |
This file contains 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
var app = {} | |
!function (app) { | |
// boolean to indicate whether | |
// the `app` is ready | |
var isReady = false; | |
// the ready stack to house | |
// all of the callbacks pushed | |
// to it |
This file contains 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
var app = {} | |
!function (app) { | |
// container to push booleans | |
// for each event to indicate whether | |
// the `app` is ready | |
var isReady = []; | |
// the ready stack to house | |
// all of the callbacks pushed |
This file contains 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
[].filter.call(document.querySelectorAll('div'), function (div) { return (/^foo_*/).test(div.id); }) |
This file contains 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
function stopAnimations () { | |
// Get the Body Element | |
var body = document.body | |
body.addEventListener('webkitAnimationStart', stopAnimation, false); | |
body.addEventListener('webkitAnimationIteration', stopAnimation, false); | |
body.addEventListener('animationstart', stopAnimation, false); | |
body.addEventListener('animationiteration', stopAnimation, false); | |
function stopAnimation (e) { | |
var target = e.target; |
This file contains 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
#include <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int | |
main (void) { | |
double v, r; | |
v = 1000.0; | |
r = log10(v); | |
printf("%f\n", r); |
OlderNewer