Skip to content

Instantly share code, notes, and snippets.

@bign8
bign8 / conway.py
Last active June 19, 2016 03:55
Conway's Game of life from 2012 Pycon
"""
Based on 2012 Pycon Talk: "Stop Writing Classes" by Jack Diederich
- https://us.pycon.org/2012/schedule/presentation/352/
Noted rules from Wikipedia: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies, as if by over-population.
4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Keybase proof

I hereby claim:

  • I am bign8 on github.
  • I am bign8 (https://keybase.io/bign8) on keybase.
  • I have a public key whose fingerprint is A7DF 2608 0EEB 2BAF 65EA 53E5 96DC 3AB3 8F42 B935

To claim this, I am signing this object:

@bign8
bign8 / .gitignore
Last active February 20, 2018 20:28
CSCI-540: Chapter 8: C code
*.so
*.o
Rplots.pdf
@bign8
bign8 / .gitignore
Last active August 29, 2015 14:19
CSCI-532 Huffman Codes Project
iliad.txt
tables.py
flashplayer.dmg
@bign8
bign8 / timeout.js
Last active August 29, 2015 14:05
Timeout redirect (js)
! function(t, i, m, e, r, s) {
var a = t.getElementById(i),
c = function() {
a.innerHTML = r, t.location = e
},
d = function() {
a.innerHTML = s.replace('{x}', m).replace('{s}', 1 == m-- ? '' : 's');
setTimeout(0 >= m ? c : d, 1e3)
};
t.addEventListener('DOMContentLoaded', d);
@bign8
bign8 / form.php
Created July 16, 2014 02:33
Mailer.php
<?php session_start(); $_SESSION['hash'] = uniqid(); ?>
<!-- ... -->
<form method="post" action="/mail.php">
<input type="hidden" name="hash" value="<?php echo $_SESSION['hash']; ?>" />
<!-- ... -->
@bign8
bign8 / gravatar-proxy-use.js
Created May 27, 2014 04:14
Gravatar Proxy with Node.js
var app = require('express')(),
gravatar_proxy = require('./gravatar-proxy.js');
app.all('/gravatar/:hash', gravatar_proxy()); // http://localhost/gravatar/example@example.com
@bign8
bign8 / example.js
Last active August 29, 2015 14:01
Angular.js and TinyMCE playing nicely (in dialogs too)
// A sample MCE_OBJ that can load on everything, then clean itself up for the directive above.
var MCE_OBJ = {
selector: 'textarea',
menubar: false,
toolbar_items_size: 'small',
plugins: 'link image code',
toolbar: "undo redo | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code",
setup: function (editor) { // cleanup for angular
delete MCE_OBJ.selector;
@bign8
bign8 / links.js
Last active August 29, 2015 14:01
@bign8
bign8 / sample.js
Created March 28, 2014 16:33
Image Pre-loader
// Note: pre-fetching all images is dumb! It wastes bandwidth on content that "might" be viewed
// Instead: Look up something called "Lazy Loading"
(function (queue, mapper) {
mapper = mapper || function (obj) { return obj; };
var image = new Image(), index = 0;
image.onload = function () {
if (index < queue.length) image.src = mapper( queue[index++] );
};
image.onerror = function (e) {