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' | |
| process.mixin global, require 'sys' | |
| APP_NAME: 'USO-Updater' | |
| COFFEE_ARGS: ['--no-wrap', '-c'] | |
| BUILD_DIR: 'build' | |
| SOURCE_DIR: 'src' | |
| directoryWalker: (dir, callback, maxLevels, currentLevel, fromRoot) -> |
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
| exports.someMethod = function (arg1, arg2, callback) { | |
| // Do this for safety's sake, people might accidentally send us an extra arg | |
| arg1 = arguments[0]; | |
| arg2 = arguments[1]; | |
| callback = arguments[arguments.length - 1]; | |
| callback(null, 'win!'); | |
| }; |
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
| directoryWalker: (dir, callback, maxLevels, currentLevel, fromRoot) -> | |
| maxLevels: if 'number' is typeof maxLevels then maxLevels else 0 | |
| currentLevel: if 'number' is typeof currentLevel then currentLevel else 1 | |
| fromRoot: if 'string' is typeof fromRoot then fromRoot else '' | |
| fs.readdir dir, (error, files) -> | |
| if error then puts error.message | |
| else files.forEach (file) -> | |
| fs.stat path.join(dir, file), (error, stats) -> | |
| return puts error.message if error |
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
| db.get('stuff', gotThatStuff); | |
| function gotThatStuff (value) { | |
| db.store('stuff', 1 + value, storedThatStuff); | |
| }; | |
| function storedThatStuff() { | |
| puts('Great success!'); | |
| } |
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
| var Test = function Test() {}; | |
| var temp = function Test() {}; | |
| temp.prototype = Array.prototype; | |
| Test.prototype = new temp(); | |
| Test.prototype.constructor = Test; | |
| // Prints "Test" | |
| new Test().constructor.name; |
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
| var Post = function Post() { | |
| ORM.prototype.constructor.apply(this, arguments); | |
| }; | |
| Post.prototype = Object.create(ORM.prototype); | |
| Post.belongsTo = ['article']; | |
| Post.hasMany = ['comments']; | |
| // Alternate name |
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
| var CoffeeScript = require('coffeescipt-compiler'); | |
| require.registerExtension('.coffee', function(async, source, asyncCallback) { | |
| if (true === async) | |
| asyncCallback(CoffeeScript.compile(source)); | |
| else | |
| return CoffeeScript.compile(source); | |
| }); |
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
| test: { | |
| bob: 123 | |
| fail: 'caching' | |
| } | |
| alert 'The $test is a $test.bob ${test}' |
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
| // This returns a Javascript string | |
| require.registerExtension('.coffee', function(async, source, callback) { | |
| return compileCoffee(source); | |
| }); | |
| // True | |
| require('coffee').test === 123; | |
| // This returns a object | |
| require.registerExtension('.mu', function(async, source, callback) { |
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
| var Wrapper, postToPastebin, wrapper; | |
| // This is a concept for making a script wrapper with a userscript and pastebin.ca | |
| Wrapper = function Wrapper(scriptId) { | |
| this.id = scriptId; | |
| return this; | |
| }; | |
| // Will contain / contains the meta data | |
| Wrapper.prototype.meta = null; |