Skip to content

Instantly share code, notes, and snippets.

View mbutler's full-sized avatar
🇦🇶
Exploring

Matthew Butler mbutler

🇦🇶
Exploring
View GitHub Profile
@mbutler
mbutler / battlesim
Created February 18, 2012 03:58
Simulate a battle between three 12th level 4e D&D characters and an Abyssal Spitter. Written in a messy, non-OO way because it wasn't planned and got out of hand fast.
<?php
/*
Our group wasn't able to finish this delve, so I wrote this script to simulate the rest with our available stats.
*/
// number of simulations
$sims = 1;
// form data
@mbutler
mbutler / slowsauce.php
Created February 22, 2012 22:41
A password hashing function. Covering the standard bases. Slow paced, long hashes, individual salt. Avoiding brute force, collisions and rainbowtables.
<?php
//http://endrerudsorensen.com/~f/slowsauce/
class slowsauce
{
private static $algo = "ripemd256";
private static $rounds = 10000;
@mbutler
mbutler / hex
Created February 26, 2012 23:09
Hex map generator
<?php
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// :: HEX.PHP
// ::
// :: Author:
// :: Tim Holt, tim.m.holt@gmail.com
// :: Description:
// :: Generates a random hex map from a set of terrain types, then
// :: outputs HTML to display the map. Also outputs Javascript
// :: to handle mouse clicks on the map. When a mouse click is
@mbutler
mbutler / hex
Created February 26, 2012 23:21
Scrollable hex map demo
/* A scrollable hexagonal map with dynamic loading and unloading of tiles, implemented using JQuery and CraftyJS.
*
* by Lynna Merrill, http://www.lynnamerrill.com
*
* Credit for some ideas and/or code snippets goes to the isometric map implementation at http://craftyjs.com/demos/isometric
and the game tutorial at https://github.com/starmelt/craftyjstut/wiki/A-first-game.
*
* All graphics used for this demo are copyrighted and cannot be distributed or reproduced in any way without permission. You may download the graphics if you want to test this demo on your own computer, but please use your own images for any posts or projects of yours.
*
@mbutler
mbutler / Lucàn
Created April 11, 2012 14:37
11th level half-elf warlock
====== Created Using Wizards of the Coast D&D Character Builder ======
Lucàn, level 11
Half-Elf, Warlock (Binder), Master Binder
Pact: Gloom Pact (Binder)
Half-Elf Power Selection Option: Knack for Success
Inherent Bonuses
Birth - Omen (+2 to Arcana)
FINAL ABILITY SCORES
STR 12, CON 13, DEX 15, INT 17, WIS 11, CHA 21
@mbutler
mbutler / kalturaCDM.php
Last active October 12, 2015 21:27
export all Kaltura videos in a category to a directory of files containing embed code. Suitable for CONTENTdm .url files in collection image folder to point at. Requires Kaltura's PHP5 library.
<?php
//number of videos in the collection
$num_of_items = ;
//collection name
$category_name = '';
//kaltura admin (email) for this account
$userId = '';
@mbutler
mbutler / iro-oai-harvester.php
Created July 31, 2013 22:01
OAI-PMH harvester for IRO.
<?php
for ($i=0; $i<=137; $i++) {
$t = $i*100;
$url = "http://ir.uiowa.edu/do/oai/?verb=ListRecords&resumptionToken=3961284/document-export/".$t."//";
$returned_content = get_data($url);
print_r($returned_content);
$target_file = 'iro.xml';
file_put_contents($target_file, $returned_content, FILE_APPEND);
}
@mbutler
mbutler / perlin-map.js
Created August 27, 2013 12:21
js perlin noise map generator
/* HTML and CSS
<canvas id="city" width="50" height="50">
<h1>No Canvas Support</h1>
</canvas>
body { background-color: #DDDDDD; font: 30px sans-serif; }
*/
//neuroMAPgen
var Dungeon = {
map: null,
map_size: 64,
rooms: [],
Generate: function () {
this.map = [];
for (var x = 0; x < this.map_size; x++) {
this.map[x] = [];
for (var y = 0; y < this.map_size; y++) {
this.map[x][y] = 0;
@mbutler
mbutler / defineClass.js
Created October 26, 2013 13:39
the defineClass code from Javascript: the definitive guide 5th edtion
/**
* defineClass( ) -- a utility function for defining JavaScript classes.
*
* This function expects a single object as its only argument. It defines
* a new JavaScript class based on the data in that object and returns the
* constructor function of the new class. This function handles the repetitive
* tasks of defining classes: setting up the prototype object for correct
* inheritance, copying methods from other types, and so on.
*
* The object passed as an argument should have some or all of the