Skip to content

Instantly share code, notes, and snippets.


James jamesplease

Block or report user

Report or block jamesplease

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jamesplease /
Last active Aug 29, 2015
The schema for Gistbook entities.

A Gistbook is a JSON file. Individuals are encouraged to build applications that render the Gistbook format in a variety of ways. One example of this is, which happens to be linked to Github Gists for convenience.


title: The name of the Gistbook
author: The author
updatedAt: The datetime that the Gistbook was last updated as an ISO8601 string
createdAt: The datetime that the Gistbook was created as an ISO8601 string
pages: An array of Pages
resources: URIs to external resources that are necessary to render the Gistbook

jamesplease / appRouter.js
Created May 9, 2014
View appRouter.js
// Set up your appRouter
var appRouter = Marionette.appRouter.extend({
controller: myController,
routes: {
// These can be an array of middleware functions
'/': [ 'authorize', 'home' ],
'/schedule/user': [ 'authorize', 'schedule', 'users' ],
// Or just one function
'/logout': 'logout'
jamesplease / marionette.router-2.js
Last active Aug 29, 2015
A possible API for a future Marionette router.
View marionette.router-2.js
// Create our Application
var app = new Marionette.Application();
// Attach a router to it
app.router = new Marionette.Router({
channelName: 'myRouter',
states: {
'profile': {
url: 'profile',
View index.js
// within /login
// These two files exist, and are identical. They just return some arbitrary object.
// login.js & what.js
// This always returns undefined
var login = require('./login');
// This returns the object
var what = require('./what');
View state.js
define(function(require) {
var angular = require('angular');
'$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
.state('portal.login', {
url: '/login',
templateUrl: '/modules/auth/login.html',
View latex-unicode.json
"mathexclam": { "unicode": "00021", "type": "mathpunct", "desc": "exclamation mark" },
"mathoctothorpe": { "unicode": "00023", "type": "mathord", "desc": "number sign" },
"mathdollar": { "unicode": "00024", "type": "mathord", "desc": "dollar sign" },
"mathpercent": { "unicode": "00025", "type": "mathord", "desc": "percent sign" },
"mathampersand": { "unicode": "00026", "type": "mathord", "desc": "ampersand" },
"lparen": { "unicode": "00028", "type": "mathopen", "desc": "left parenthesis" },
"rparen": { "unicode": "00029", "type": "mathclose", "desc": "right parenthesis" },
"mathplus": { "unicode": "0002B", "type": "mathbin", "desc": "plus sign b:" },
"mathcomma": { "unicode": "0002C", "type": "mathpunct", "desc": "comma" },
jamesplease / ams-symbols.js
Created Sep 27, 2014
The list of new KaTeX symbols.
View ams-symbols.js
module.exports = [
// Mathjax only
jamesplease / gistbook.json
Last active Aug 29, 2015
Gistbook New Features
View gistbook.json
{"title":"Gistbook New Features","author":"jmeas","pages":[{"pageName":"","sections":[{"type":"text","source":"This is where I test new features.\n\n:tada:"},{"type":"text","source":"Hello friend\n"},{"type":"html","source":"<div>ok</div>"},{"type":"javascript","source":"var _ = require('underscore');\nvar $ = require('jquery');\nvar Backbone = require('backbone');\nBackbone.$ = $;\n\n_.each([1,2,3], function(num) {\n console.log('ok!', num);\n});"}]}],"public":true}
jamesplease / to-json-shim.js
Created Nov 9, 2014
toJSON is bad for serializing stuff.
View to-json-shim.js
* toJSON Shim
* Marionette 1.8.7 uses toJSON to serialize the model data for views,
* which goes against the specifications of Backbone. toJSON should be
* used for serializing your data back into JSON, primarily for the purposes
* of returning it back to the server. Views should include their own version
* of toJSON for display purposes.
* This is an open PR on Marionette and will be merged soon.
jamesplease / gistbook.json
Last active Aug 29, 2015
Calculating the norm of a vector in Javascript
View gistbook.json
{"title":"Calculating the norm of a vector in Javascript","author":"jmeas","pages":[{"pageName":"","sections":[{"type":"text","source":"Determining the norm of a vector can be daunting :fearful: But after you've read this exercise you'll be a pro at it :+1:\n\nThe norm of a vector is its length. In two dimensions, the norm of a vector \\(\\vec{v}\\) can be calculated with the following equation:\n\n$$\\lvert v \\rvert = \\sqrt{x^2+y^2}$$\n\nIn Javascript, we could write a function to calculate this like so:"},{"type":"javascript","source":"var math = require('mathjs');\n\nfunction norm(x, y) {\n return math.sqrt(math.square(x) + math.square(y));\n}"},{"type":"text","source":"Let's take a look at how we can use this to calculate the norm of a vector \\(\\vec{v} = [3, 4]\\)"},{"type":"javascript","source":"var val = norm(3, 4);\n\n// Set it to the output div\ndocument.getElementsByClassName('output')[0].innerHTML = val;"},{"type":"html","source":"<!-- This is a div to show our output -->\n<div>The norm of our
You can’t perform that action at this time.