Skip to content

Instantly share code, notes, and snippets.

View banksean's full-sized avatar

Sean McCullough banksean

View GitHub Profile
@banksean
banksean / mersenne-twister.js
Created February 10, 2010 16:24
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@banksean
banksean / perlin-noise-classical.js
Created February 15, 2010 10:00
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/

Keybase proof

I hereby claim:

  • I am banksean on github.
  • I am banksean (https://keybase.io/banksean) on keybase.
  • I have a public key whose fingerprint is 3E99 FD28 9011 FC06 BD23 5F95 8B27 DB6A 1F6D 6497

To claim this, I am signing this object:

<!doctype html>
<html>
<head>
<title>NodeJS Comet Chat Demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type='text/javascript'>
$(function() {
// This only works in modern browsers :)
var webSocket = new WebSocket('ws://localhost:8080/chat');
// I was going to use slices, but hey I'm lazy why not let the compiler
// verify that I put the right number rows and columns in?
type literalBoard [8][8]ScoreType
var (
LiteralBoard = literalBoard{
{TW, None, None, DL, None, None, None, TW},
{None, DW, None, None, None, TL, None, None},
{None, None, DW, None, None, None, DL, None},
{DL, None, None, DW, None, None, None, DL},
@banksean
banksean / ints.go
Last active February 14, 2018 16:31
type scoreInt uint64
var (
// If you think I came up with these values by hand... LOL
//
// Each bit in a value represents the presence or absence
// of a score multiplier in the 8x8 upper-left corner of
// the board.
TWInt = scoreInt(0x8000000000000081)
DWInt = scoreInt(0x100000810204000)
// ScoreAtConditional uses a series of conditional checks to determine what a
// particular square's score multiplier is.
func ScoreAtConditional(x, y int) ScoreType {
// Symmetric adjustments if x or y > 7 to simplify checks below.
if x > 7 {
x = 14 - x
}
if y > 7 {
y = 14 - y
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-16" />
<title>
λ in JavaScript
</title>
<script type='text/javascript'>
Array.prototype.forEach = function(λ) {
for (var i = 0; i < this.length; i++) {
@banksean
banksean / designer.html
Last active August 29, 2015 14:16
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icons/maps-icons.html">
@banksean
banksean / designer.html
Last active August 29, 2015 14:16
designer
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<polymer-element name="my-element">