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
| // Mini Framework | |
| Object.extend = function(original, extensions){ | |
| original = original || {}; | |
| for (var i in extensions) if (extensions.hasOwnProperty(i)) original[i] = extensions[i]; | |
| return original; | |
| }; | |
| flo = function(selector){ | |
| if (!(this instanceof flo)) return new flo(selector); |
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 str = 'foo'; | |
| switch (str) { | |
| case true: | |
| console.log('got it'); | |
| break; | |
| default: | |
| console.log('default'); | |
| break; |
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
| ;(function(){ | |
| function typeOf(item){ | |
| if (item._family) return item._family(); | |
| return typeof item; | |
| } | |
| Array.prototype._family = function(){ return 'array'; }; | |
| var _ = this._ = function(obj){ |
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
| <?php | |
| /** | |
| * CSV Class | |
| */ | |
| class CSV | |
| { | |
| public static function from_file($path = '') | |
| { |
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
| // assign variables; | |
| var a = 'whatever'; | |
| // create functions | |
| function whatever(arg, arg2){ | |
| // use arguments | |
| console.log(arg, arg2); | |
| } | |
| // same as above (basically) |
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
| /* | |
| Mediator | |
| -------- | |
| This object mediates custom events among objects on the page. Objects don't need to know about other objects in order to communicate with them--they simply subscribe to global publications. This decouples all of the objects from each other. In most cases, an object's entire implementation can be described in one code block anywhere in the application code. | |
| ### mediator method: publish | |
| Publishes an event to the application that objects can subscribe to, passing along information. |
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
| /** | |
| * Module dependencies. | |
| */ | |
| var express = require('express') | |
| , io = require('socket.io'); | |
| var app = module.exports = express.createServer(); | |
| // Configuration |
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
| <?php | |
| $arr = array( | |
| 'Color' => array('Red', 'Blue'), | |
| 'Size' => array('Regular', 'Large'), | |
| 'Material' => array('Metalic', 'Nylon') | |
| ); | |
| function magic_algorithm($arr){ | |
| // |
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
| slideshow.addEvent('showComplete', | |
| ( | |
| // this function is immediately called before passing in the argument to addEvent | |
| function(){ | |
| // these are scoped variables, a lot like | |
| // protected variables in PHP | |
| var looped = false, | |
| length = slideshow.slides.length - 1; | |
| // this function is the actual argument that gets sent to addEvent |
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 pair = {} | |
| pair.create = function (x, y){ | |
| var _x, _y, publik = {} | |
| function init(x, y){ | |
| _x = x | |
| _y = y | |
| sum() | |
| diff() | |
| prod() |