Skip to content

Instantly share code, notes, and snippets.

View bmcminn's full-sized avatar

Brandtley McMinn bmcminn

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / String.stripMoneyFormat.js
Created August 18, 2015 21:49
My custom String object methods
function stripMoneyFormat(string, currency) {
currency = currency || '$';
var regex = {
moneys: new RegExp('[\\'+currency+'\,]', 'g')
}
;
if (typeof(string) == "string") {
return parseFloat(string.replace(regex.moneys, ''))toFixed(2);
@bmcminn
bmcminn / sample.cpp
Last active August 29, 2015 14:09
Gist Source Samples
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
std::cin.get();
return 0;
}
@bmcminn
bmcminn / README.md
Last active May 27, 2020 21:05
Bookmarklets
@bmcminn
bmcminn / BASH: node-webkit.bash
Last active December 30, 2015 08:19
A bunch of helper functions and short hand methods that I find useful in developing Node-Webkit applications.
#!/bin/sh
#
#
# _____ _ _ _ _ _ _ _ _
# | | |___ _| |___ ___| | | |___| |_| |_|_| |_
# | | | | . | . | -_|___| | | | -_| . | '_| | _|
# |_|___|___|___|___| |_____|___|___|_,_|_|_|
#
# _____ _ _____ _
# | __ |___ ___| |_ | | |___| |___ ___ ___ ___
@bmcminn
bmcminn / cURL.php
Last active December 25, 2015 20:39 — forked from dfreerksen/Curl.php
<?php
class cURL {
/**
* cURL request method
*
* @var string
*/
protected $_method = 'GET';