Skip to content

Instantly share code, notes, and snippets.

View bmcminn's full-sized avatar

Brandtley McMinn bmcminn

View GitHub Profile
@bmcminn
bmcminn / leap-day-check.php
Last active April 2, 2020 06:20
Testing date parsing in regards to leap year 2020
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Date Parsing</title>
</head>
<body>
<?php
// dumb helpers functions
/**
* Generates a random integer between a min and max value
* @sauce https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#getting_a_random_integer_between_two_values
* @param number min
* @param number max
* @return number
*/
function randomInt(min, max) {
@bmcminn
bmcminn / defaults.styl
Created January 17, 2020 17:27
Some default styles I like to include on most projects
// @sauce: https://getbootstrap.com/docs/4.4/getting-started/accessibility/#visually-hidden-content
.sr-only
position: absolute
width: 1px
height: 1px
padding: 0
margin: -1px
overflow: hidden
clip: rect(0,0,0,0)
<script>
import Container from './Container.svelte'
</script>
<h1>App Name</h1>
<Container>
<div class:col-xs-3 class:col-md-2 class:col-lg-1>...</div>
<div class:col-xs-3 class:col-md-2 class:col-lg-1 class:hidden class:visible-md>...</div>
<div class:col-xs-3 class:col-md-2 class:col-lg-1>...</div>
@bmcminn
bmcminn / sortCollection.js
Last active January 13, 2020 22:07
Allows you to sort a colleciton of objects by any given property within those objects.
/**
* Sorts a collection of objects based on a pipe-delimited list of sorting parameter config strings
* @param {array} collection Collection of objects
* @param {string} sortKeys Pipe separated string of sortable properties within the collection model and it's sort priorities:
* @param {string} invertCollection invert collection sort
*
* @schema sortKeys: '(string)keyName:(string)keyType:(string)invert|...'
@bmcminn
bmcminn / generic-uwuizer.js
Last active December 27, 2019 21:32
Website uwuizer script, enter in your browser console or make a browser extension with it :P Define custom selectors to uwuize in the `URIs` object by matching the key as the page URL hostname
var SELECTOR = 'span, p, b, a'
document.querySelectorAll(SELECTOR)
.forEach(el => {
el.innerText = el.innerText.replace(/l|r/gm, 'w');
return el
})
@bmcminn
bmcminn / memoize.php
Created September 4, 2019 15:20
initial attempt at a memoization mechanism
<?php
/**
* Memoizes a given set of data and returns if a result has been cached or not
* @param array $params Config for what to memoize
* @param (any) $data (optional) Data we wish to memoize
* @return any [description]
*/
function memoize($key, $data=null) {
$db = null;
@bmcminn
bmcminn / game.js
Last active May 23, 2019 21:46
Demo p5.js game idea
// keycode constants
const SPACE = 32
const PAGE_UP = 33
const PAGE_DOWN = 34
const NUM_PLUS = 107
const NUM_MINUS = 109
// UI constants
const RATIO = { w: 4, h:3 }
const SCREEN = { w: 0, h: 0 }
@bmcminn
bmcminn / zip-distance.js
Created March 26, 2019 22:54
Playing around with zip code distance algorithms and radius search
const ZIPCODES = require('./zipcodes.js')
const sqlite = require('sqlite')
const Promise = require('bluebird')
// http://www.zipcodeapi.com/API
/**
* Calculates distance between two ZIPCODES
@bmcminn
bmcminn / storage.helpers.js
Last active January 6, 2020 23:14
A set of Javascript helper functions that trivialize a lot of tedious things, like cacheing and cache busting :P
/**
* Storage API helper method that sets a key/value in specified storage API with
* an optional cache duration in minutes
* @private
* @sauce https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem
*
* @param {object} StorageAPI Storage API object to use for .getItem() calls
* @param {string} key A DOMString containing the name of the key you want to create/update
* @param {any} value The value you want to give the key you are creating/updating
* @param {integer} durationInMinutes The time in minutes the item should be valid for, used for passively expiring cache