- Domain Specific Language (DSL) for sharing data or making a task simpler
- template language (dust, handlebars, lisplate)
- maybe you want your own ES2017 to ES5
- port a language/environment (porting Smallbasic to a browser)
- create a whole new langauge
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
// see https://github.com/HallM/sudokusolvers/ | |
// first 4 bits are allocated for the value (1-9) | |
// next 9 bits are used for the "pencil marks" | |
const ONE = 1 << 4; | |
const TWO = 1 << 5; | |
const THREE = 1 << 6; | |
const FOUR = 1 << 7; | |
const FIVE = 1 << 8; | |
const SIX = 1 << 9; |
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>BOT CONTROLLER</title> | |
</head> | |
<body> | |
<input type="text" id="botcontroller" /> | |
</body> | |
<script src="/socket.io/socket.io.js"></script> | |
<script src="http://code.jquery.com/jquery-1.11.1.js"></script> |
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 five = require("johnny-five"); | |
var app = require('express')(); | |
var http = require('http').Server(app); | |
var io = require('socket.io')(http); | |
var path = require('path'); | |
var board = new five.Board(); | |
app.get('/', function(req, res) { | |
res.sendFile(path.resolve('index.html')); |
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
{fn (p1 p2) | |
{def c {fn (p3 p4) | |
{* {+ p1 p3} {- p4 p2}} | |
}} | |
{c 1 2} | |
} | |
fns immediately executed in the same scope do not need special closure style | |
using the stack works just fine. |
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
// types/todo.js | |
export default Type({ | |
owner: User, // user is assumed defined for this example | |
message: { | |
type: String, | |
validators: /\\w+/ // maybe a function, maybe an array, maybe an object with a custom error message | |
} | |
}); | |
// db/todo.js |
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
// Methods could be any of the CRUD actions | |
// they may return data like newest info, result data, or just a status | |
// they could set flash vars (universally) using Flash.post('error', 'something went wrong') | |
// POST->redirect flow without JS | |
// the result is probably ok to ignore when you think about the workflow. | |
// the redirect-to should load a page that loads data anyway. | |
// we expose Flash system on both sides anyway, so call that in here. | |
// would just need a way to know where to redirect following a non-XHR |
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
'use strict' | |
var TrieRouter = require('./experimental-router'); | |
TrieRouter.add(['get'], '/', function(req, res) { | |
//console.log('index'); | |
}, {}); | |
TrieRouter.add(['get'], '/aboutus', function(req, res) { | |
console.log('aboutus'); |
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
/* | |
how dynamic paths work | |
while this design sounds good, may wish to consider allowing something like | |
{param|/regex/} | |
would require the existance of "DynNode" to store the regex validator | |
but also, the parent Node would need to store an array of DynNodes | |
don't need to store the param names though, since it can be stored in the dynnodes themselves | |
when adding, must verify the names match up |
NewerOlder