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
| app.get( '/bob', function( req, res, next ){ | |
| if( !req.session ){ | |
| console.log( 'no session!' ); | |
| } | |
| else{ | |
| console.log( req.session ); | |
| req.session.counter++; | |
| } |
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
| /** | |
| * Very simple Mealy style finite state machine relying on a nodejs event emitter. Absolutely not tested | |
| * and contains absolutely no fancy feature. You can put multiple "from" and "to" states by separating | |
| * them with a space. Putting no "from" or "to" amounts to setting them as "undefined", a supported state. | |
| */ | |
| // Example: | |
| /* | |
| var fsm = new Fsm([ | |
| { name : 'wakingup' , from: 'sleeping' , to : 'awake' }, |
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 data = { | |
| id : uploaded_file._id, | |
| filters : [ | |
| { | |
| name : 'image', | |
| options : [ | |
| { | |
| operation : 'resize', | |
| width : $placeholder_img.width(), | |
| height : $placeholder_img.height() |
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
| // url : | |
| /user/:userId/upload/delete | |
| //post-body : | |
| { | |
| _id : <imageId> | |
| } |
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
| <snippet> | |
| <content><![CDATA[ | |
| // ${1:SECTION-NAME} | |
| //////////////////////////////////////////////////////////////////////////////// | |
| $2 | |
| ]]></content> | |
| <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
| <tabTrigger>sep</tabTrigger> | |
| <!-- Optional: Set a scope to limit where the snippet will trigger --> | |
| <!-- <scope>source.python</scope> --> |
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 wrap( middleware, trigger ){ | |
| return function( req, res, next ){ | |
| // The trigger can be a function that gets dynamically evaluated every time | |
| // or a static truthy/falsy variable | |
| if( typeof trigger === 'function' ? trigger() : trigger ){ | |
| middleware( req, res, next ) | |
| } | |
| else{ | |
| next(); | |
| } |
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
| // Template loading code | |
| //////////////////////////////////////////////////////////////////////////////// | |
| // Reload the cached files when it changes. | |
| function onFileChange( filename, filePath, cb ){ | |
| function exec( event ){ | |
| if( process.env.NODE_ENV !== 'production' ){ | |
| console.error( 'Loading template:'.yellow, filePath.grey ); | |
| } |
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 add( x,y ){ | |
| return x + y; | |
| } | |
| function staticAdd( x ){ | |
| return function( y ){ | |
| return x + y; | |
| } | |
| } |
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
| ^.*(?:\.\$)([a-zA-Z0-9_]+)\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
| var EventEmitter = require( 'events' ).EventEmitter; | |
| var emitter = new EventEmitter(); | |
| // SECTION-NAME | |
| //////////////////////////////////////////////////////////////////////////////// | |
| function emitterClass(){ | |
| EventEmitter.call( this ); | |
| } |