Skip to content

Instantly share code, notes, and snippets.

@JustinMorgan
JustinMorgan / TestShuffle.aspx
Created October 19, 2015 20:39
Shuffle Visualizer: Visual sanity-check for randomness in deck-shuffling algorithms (C#/ASP.NET WebForms version)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestShuffle.aspx.cs" Inherits="TestShuffle" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test shuffle</title>
<style>
body {
@JustinMorgan
JustinMorgan / shuffle-visualizer.coffee
Last active February 22, 2016 19:21
Shuffle Visualizer: Visual sanity-check for randomness in deck-shuffling algorithms (JS and CoffeeScript versions)
#Usage:
#1. Declare your shuffle() function. No parameters necessary, since `deck` is a global variable.
#2. Run `test()`.
deckSize = 52
deck = [0...deckSize]
rand = (min = 0, max = deckSize) ->
Math.floor(Math.random() * (max - min)) + min
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) {
sys.puts(stdout)
}
exec("ls -la", puts);
var mongoose = require("mongoose"),
connection = mongoose.connection,
gracefulExit = function() {
connection.close(function() {
console.log('Mongoose default connection disconnected through app termination');
process.exit(0);
});
};
mongoose.connect(process.env.MONGO_URI);