Skip to content

Instantly share code, notes, and snippets.

View HallM's full-sized avatar

Matthew Hall HallM

View GitHub Profile
@HallM
HallM / sudokusolve.js
Last active September 23, 2016 16:54
a simple, easy-level sudoku solver (missing many techniques, but a start...)
// 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;

Introduction

What can I do with a language?

  • 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
<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>
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'));
@HallM
HallM / templatecode.txt
Last active July 28, 2016 22:43
First pass for a template bytecode / vm
{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.

Session State Management & Security

Intro

  • This talk is focused on the concepts, not the commonly used competing strategies.
  • Knowing the details helps fine tune the implementation for certain scenarios depending your requirements

JWT vs Session IDs:

Sessions IDs

@HallM
HallM / todo-ogre-concept.js
Last active February 12, 2016 20:35
just a concept of how the framework would handle the Todo MVC demo
// 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
// 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
'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');
/*
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