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
// example function where arguments 2 and 3 are optional | |
function example( err, optionalA, optionalB, callback ) { | |
// retrieve arguments as array | |
var args = []; | |
for (var i = 0; i < arguments.length; i++) { | |
args.push(arguments[i]); | |
} | |
// first argument is the error object |
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
// example function that raises an error | |
function example (callback) { | |
// correct approach | |
return callback ( new Error('an error occurred') ); | |
// NO! BAD KITTY! | |
return callback ('an error occurred'); |
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 fs = require('fs'); | |
// read a file | |
function read_the_file(filename, callback) { | |
// begin by reading a file | |
fs.readFile(filename, function (err, contents) { | |
// an error occurred, i.e. the file was not found. | |
// instead of throwing an error, skip the other |
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 the filesystem module | |
var fs = require('fs'); | |
// fs.readFile: read a file and all its contents, | |
// then call a callback function | |
fs.readFile('/some/file', function (err, contents) { | |
// if any error occurred, throw it | |
if (err) throw 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
// include the express framework | |
var express = require('express'); | |
// include the node-walker module | |
// -> npm install node-walker | |
var walker = require('node-walker'); | |
// the express server instance | |
var app = express.createServer(); |
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
<div id="navbar" class="navbar"> | |
<ul id="navtabs" class="navtabs floatcontainer<vb:if condition="$show['member'] AND $notifications_total"> notify</vb:if>"> | |
{vb:raw template_hook.navtab_start} | |
<vb:if condition="!$vboptions['selectednavtab'] AND THIS_SCRIPT != 'search'"> | |
<li class="selected"><a class="navtab" href="{vb:link forumhome}">{vb:rawphrase forum}</a> | |
<ul class="floatcontainer"> | |
{vb:raw template_hook.navbar_start} | |
<vb:if condition="$show['searchbuttons']"> | |
<vb:if condition="$show['member']"> | |
<li><a href="search.php?{vb:raw session.sessionurl}do=getnew&contenttype=vBForum_Post">{vb:rawphrase new_posts_nav}</a></li> |
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
// ----- throw your class into one single file = a seperate scope | |
// constructor and export | |
var myClass = module.exports = function () { | |
// .. | |
} | |
// a public method | |
myClass.prototype.publicMethod = function () { |
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
<html> | |
<head> | |
<title>...</title> | |
<style> | |
<!-- | |
p { | |
border-left:4px solid #00FF00; | |
display:block; |
NewerOlder