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
// variables | |
var number = 2, | |
count = 0; | |
// while prime count | |
while (number < 100) { | |
if (isPrime(number)) { | |
count++; | |
} | |
number++; |
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 express = require('express'), | |
bodyParser = require('body-parser'), | |
app = express(); | |
// third party middleware | |
app.use(bodyParser.urlencoded()); | |
// custom middleware | |
app.use(function (req, res, next) { | |
console.log('this will log on every request'); |
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 express = require('express'), | |
bodyParser = require('body-parser'), | |
app = express(); | |
// configurations | |
app.set('env', 'development'); // default: process.env.NODE_ENV | |
app.enable('trust proxy'); // for reverse proxy; disabled by default | |
app.set('jsonp callback name', 'cb'); // json with padding | |
app.set('json replacer', function (attr, val) { | |
if (attr === 'passwordHash') { |
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
{ | |
"links": { | |
"next": "http://localhost:3050/movies?page=2" | |
}, | |
"request_info": { | |
"seconds": 0.002, | |
"cached": false, | |
"result_count": 4 | |
}, | |
"items": [ |
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 express = require('express'); | |
var app = express(); | |
var Datastore = require('nedb'); | |
var db = {}; | |
var responder = require('./httpResponder'); | |
var port = process.argv[2] || 3050; | |
var root = 'http://localhost:' + port; | |
// Connect to an NeDB database |
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
<script runat="server"> | |
protected override void OnInit(EventArgs e) | |
{ | |
base.OnInit(e); | |
var school = CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("{?School?}").ToString().ToLower(); | |
var modality = CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("{?Modality?}").ToString().ToLower(); | |
var nodeAlias = CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros("{?NodeAlias?}").ToString().ToLower(); | |
if (school != "" && modality != "" && nodeAlias != "") |
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 $mainNavItem = jQuery('#mainNav .two-column-nav'); | |
jQuery($mainNavItem).on('mouseover', function () { | |
var mousedOver = jQuery.data(this, "mousedOver"); | |
if (!mousedOver) { | |
var $this = jQuery(this); | |
var height = 0; | |
$siblings = $this.find('li.level2'); |
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 naive = function (a, b) { | |
var x = a; // 1 unit | |
var y = b; // 1 unit | |
var z = 0; // 1 unit | |
while (x > 0) { // runs twice | |
z = z + y; | |
x = x - 1; | |
return z; | |
} | |
}; |
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
// event listener on each child node | |
$('#parent li').on('click', function(e) { | |
console.log('List item:', e.target.id, 'was clicked'); | |
}); |
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
// eventUtility.js | |
var eventUtility = { | |
addEvent: function (el, type, fn) { | |
/* | |
el: HTML element object (DOM object) | |
type: event type to listen to | |
fn: function | |
*/ |