Skip to content

Instantly share code, notes, and snippets.

View mlms13's full-sized avatar
⚗️

Michael Martin mlms13

⚗️
View GitHub Profile
@mlms13
mlms13 / Ferble.js
Last active August 29, 2015 14:25
It's a ferble.
function splitIntoGroups(chunks, str) {
var splitAt = str.charAt(0) === '"' ?
// if the string starts with a quote at this point,
// find the next quote or the end of the string
str.indexOf('"', 1) > -1 ? str.indexOf('"', 1) : str.length :
// otherwise, break at the next space
str.indexOf(' ', 1) > -1 ? str.indexOf(' ', 1) : str.length,
word = str.substring(0, splitAt).replace('"', '').trim();
@mlms13
mlms13 / riskroll.js
Last active August 29, 2015 14:26
Attacker vs Defender with big armies in risk
function roll() {
return Math.ceil(Math.random() * 6);
}
function compare() {
var one = [roll(), roll(), roll()].sort(function (a, b) { return b-a }).slice(0,2);
var two = [roll(), roll()].sort(function (a, b) { return b-a });
var score = 0;
one.forEach(function (item, index) {
@mlms13
mlms13 / uphxlib.fish
Last active August 29, 2015 14:26
Update haxelib dev repos in fish-shell
function uphxlib
# upgrade normal haxe repositories
echo 'a' | haxelib upgrade
# keep track of the current directory
set current_dir (pwd)
# update all 'dev' repo git repositories
for lib in (haxelib list | cut -d: -f2- | grep 'dev:')
set dev_dir (echo $lib | rev | cut -c 2- | rev | cut -d '[' -f2- | cut -c5-)
@mlms13
mlms13 / index.html
Created October 4, 2012 13:34
A grid of buttons for the USF College of Nursing program to deliver Teddy Bears to children in hospitals.
<section class="tan two-line">
<a href="#" class="simple">Order your<br /> B.E.A.R.S. Today</a>
<a href="#" class="round">Order your<br /> B.E.A.R.S. Today</a>
<a href="#" class="square">Order your<br /> B.E.A.R.S. Today</a>
</section>
<section class="gold two-line">
<a href="#" class="simple">Order your<br /> B.E.A.R.S. Today</a>
<a href="#" class="round">Order your<br /> B.E.A.R.S. Today</a>
// get names and ratings for BFZ cards from ChannelFireball
function getRatings() {
var list = [].slice.apply($('.postContent h1').not(":first").not(":last"));
return list.map(function(el) {
var rating = $(el).next().next().clone().find("b").remove().end().text()
return {
name: el.textContent,
rating: parseFloat(rating)
};
});
@mlms13
mlms13 / lovefield.d.ts
Created November 22, 2015 05:41
Typescript definition file for Lovefield. I didn't make this.
// Type definitions for Lovefield v2.0.62
// Project: http://google.github.io/lovefield/
// Definitions by: freshp86 <https://github.com/freshp86>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../es6-promise/es6-promise.d.ts"/>
declare module lf {
export enum Order { ASC, DESC }
@mlms13
mlms13 / gulpfile.js
Last active December 3, 2015 21:31
Conditionally switch between source maps and minification based on a gulp flag.
// `gulp stylus --prod` will enable "production mode"
// `gulp stylus` will leave the prod flag undefined, so it will do a dev build
var gulp = require('gulp'),
gutil = require('gulp-util'),
prod = gulp.env.prod;
gulp.task('stylus', ['cleancss'], function () {
var stylus = require('gulp-stylus'),
prefix = require('gulp-autoprefixer'),
minify = require('gulp-minify-css');
var sections = [{
id: "A",
flag: false,
subsections: [{
id: "A1",
subsections: [{
id: "A1a",
flag: true
}, {
id: "A1b"
@mlms13
mlms13 / flat-to-tree.js
Last active April 29, 2016 17:17
Collect a flat array of objects as nested map
var flat = [
{ id: "A", name: "A", parent: "" },
{ id: "B", name: "B", parent: "" },
{ id: "C", name: "C", parent: "D" },
{ id: "D", name: "D", parent: "B" },
{ id: "E", name: "E", parent: "A" }
];
function unflatten(list) {
return; //...
@mlms13
mlms13 / upgrades.js
Last active January 24, 2017 21:32
List unpurchased upgrades in Cookie Clicker
// I rewrite these way too often, so here they are:
// upgrades
Game.UpgradesById
.filter(function (up) {
return !up.bought && up.pool != "prestige" && up.pool != "toggle" && up.pool != "debug";
})
.map(_ => _.name);
// achievements