Skip to content

Instantly share code, notes, and snippets.

View bmcminn's full-sized avatar

Brandtley McMinn bmcminn

View GitHub Profile
@bmcminn
bmcminn / pyramid.js
Last active October 30, 2015 07:08
A simple brainteaser script that generates an "ASCII" pyramid in console
function pyramid(rows) {
var message = []
, spaces = stars = ''
;
for (var i = 1; i <= rows; i += 1) {
// The (+1) and (*2) in both equations account for Array.join() omitting the
// first (0) index when it concatenates our string
@bmcminn
bmcminn / regexes.js
Created March 4, 2016 22:55
Some of my favorite/most useful regexes. NOTE: these are not meant for validating, mostly just capturing whole strings or partials.
{
cComments: /\/\*[\s\S]*?\*\/|\/\/[\s\S]*?(?=\n)/g
, emails: /[\S]+@[\S]+/gi
/* EMAIL TEST
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
*/
@bmcminn
bmcminn / wtf-regex-non-alpha-numerica-range.js
Last active March 9, 2020 16:56
JS WTF?! Unsuspecting Regex range selector captures numbers and certain punctuation? Assuming it's due to a unicode/ascii coercion in the JS interpreter. Works in Node 5+ and in Browser console.
"testing, waffles 1234567+=-_^@,./;:[]\/".replace(/[+-_]/g, '')
// > "testing waffles "
@bmcminn
bmcminn / String.pad.js
Last active January 19, 2017 18:17
Attempt at a Global String.pad method set:
/**
* Pads the left side of a string to `length` with N `char` characters
* @note If the string.length is greater than length, the method will not truncate to length
* @param {int} length The length of the desired string result
* @param {str} char Character to pad the string with
* @return {string} The padded string
*/
String.prototype.padLeft = function(length, char) {
char = char || ' ';
@bmcminn
bmcminn / keyword-estimator.js
Last active March 3, 2020 21:32
WIP: This script makes some sweeping generalizations about your page content, but gives you a good rule of thumb approach to determining prevalence of certain keywords in your writing.
var _ = require('lodash')
, chalk = require('chalk')
;
var keywordAnalysis = function keywordAnalysis(content, options) {
// configure options
@bmcminn
bmcminn / index.html
Created May 4, 2017 20:15
HTML mobile app structure
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flexbox Test</title>
<style type="text/css">
html {
box-sizing: border-box;
@bmcminn
bmcminn / fs.js
Last active January 7, 2021 03:25
This is a custom "build" of my favorite FS utility methods from `grunt.file` and the native Node `fs` object
const gruntFS = require('grunt').fs
const nodeFS = require('fs')
// init exported fs object
const fs = {}
// Map Grunt.file methods
fs.copy = gruntFs.copy
fs.delete = gruntFs.delete
// fs.exists = gruntFs.exists
@bmcminn
bmcminn / index.html
Created December 28, 2017 22:21
Example web app interface with sticky topnav and offscreen navigation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>App Shell Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></style>
@bmcminn
bmcminn / __bookmarks.js
Last active December 20, 2022 03:47
Bookmarklets for fun and profit!
// SILENCE!!!
@bmcminn
bmcminn / memoizer.php
Created January 31, 2018 19:11
A memoizer written in PHP that uses SQLite as it's persistence layer.
<?php
/**
* API Description
*
* # Memoize() utility
*
* ## Public Methods:
*
* getMemo($key)