Skip to content

Instantly share code, notes, and snippets.

View Havvy's full-sized avatar

Ryan Scheel Havvy

  • Work is not programming related
  • Washington, USA
View GitHub Profile
/*
* A C-program for MT19937, with initialization improved 2002/1/26.
* Coded by Takuji Nishimura and Makoto Matsumoto.
*
* Before using, initialize the state by using init(seed)
* or init_by_array(init_key, key_length).
*
* Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
* All rights reserved.
*
// These are also the same function as below, with slightly different syntax.
function new (constructor, args) {
var binding = Object.create(constructor.prototype);
var retval = constructor.apply(binding, args);
if (retval === null || typeof retval !== 'object') {
return binding;
}
return retval;
Silly Proposal: Addition of the 'with' attribute to the <script> tag.
With 'with' attribute defines the global context for the script to run in.
The 'with' attribute defaults to the current global context, or `window` if in
the original HTML. By defaulting to the current global context, a script can't
create a new script that gains access to data outside of its context.
In scripts with the `with` attribute set, they shall run in ES5/strict mode.
Using `var` in the top level works as you would expect, setting values on the
@Havvy
Havvy / drill.js
Last active December 16, 2015 22:29
var drill = function (object, path) {
for (var ix = 0; ix < path.length - 1; ix++) {
if (typeof object !== "object" || object === null) {
return undefined;
}
object = object[path[ix]];
}
return object[path][ix];
var constructor = function (ctor, args) {
return function ctor_thunk () {
var ret = ctor.apply(Object.create(ctor.prototype), args);
ret.constructor = ctor_thunk;
return ret;
};
};
@Havvy
Havvy / Magic.lang.spec.mw
Last active December 17, 2015 18:39
Language specification.
= Magic =
== Scope ==
This standard defines the Magic programming language.
== Conformance ==
A conforming implementation of Magic must provide and support all the types,
values, objects, functions, and program syntax and semantics described in this
#lang typed/racket
(define-type my/symbol Symbol)
(define-type my/map (HashTable my/any my/any))
(define-type my/any (U my/symbol
my/map))
; Works
(define (a-map : my/map) #hash{[:call . :q]})
@Havvy
Havvy / ann.rkt
Last active December 18, 2015 05:39
#lang typed/racket
(define: (i [a : String] [b : String]) : String "#f")
(ann i (String * -> String))
Type Checker: Expected (String * -> String), but got (String String -> String) in: i

101 - The player agreement

  1. A player is a person who follows this rule.
  2. A player may only join before the game begins or at the beginning of a round.
  3. All players must always abide by all the rules that are in effect, in the order in which they were put in effect.
  4. The rules in the Initial Set are in effect whenever the game begins.
  5. The Initial Set consists of Rules 101-115.

102 - Definition: Rounds

  1. The game starts at the beginning of the first round.
  2. During a round, players take turns in alphabetical order.

JS Wishes

  • Remove labels. They clutter the syntax for no real gain compared to what PHP did.
  • Replace with break and continue statements taking an optional positive integer (default 1), breaking that many loops out.
  • Match statement (See match.js)
  • [[call]] special property in object literal syntax.
  • [[prototype]] special property in object literal syntax.
  • 'self' lexical variable that refers to current object.
  • 'self(integer n)' lexical function that refers to the nth highest object literal. This looks ugly, but that's intentional. Note that the integer passed must be a literal integer.
  • Mixins via the [[prototype]] property being an array. First go through the prototype chain of the first object in the array. If not found, go through the second. Ect. ect. Until the end. If not found, the key is empty, and return undefined.