Skip to content

Instantly share code, notes, and snippets.

⛑️
solving problems

steve withington stevewithington

⛑️
solving problems
View GitHub Profile
@stevewithington
stevewithington / getRandomPassword.cfm
Created Jul 2, 2020
ColdFusion / CFML Random Password Method / Function
View getRandomPassword.cfm
<cfscript>
public string function getRandomPassword(numeric length=10, string charSet='special') {
var charLower = 'a|c|e|g|i|k|m|o|q|s|u|w|y|b|d|f|h|j|l|n|p|r|t|v|x|z'
var charUpper = 'A|C|E|G|I|K|M|O|Q|S|U|W|Y|B|D|F|H|J|L|N|P|R|T|V|X|Z';
var charNumbers = '0|2|4|6|8|9|7|5|3|1';
var charSpecial = "@|!|$|%|^|&|+|=|,'";
var charList = '';
var thisChar = '';
var randomPassword = '';
View git-log-pretty.sh
git log --graph --decorate --pretty=oneline --abbrev-commit
@stevewithington
stevewithington / find-replace-sed.md
Last active Jun 13, 2019
Find & Replace within an Entire Directory or Git Repo with sed
View find-replace-sed.md

Find & Replace within an Entire Directory or Git Repo with sed

If replacing within a directory:

grep -rl 'apples' /dir_to_search_under | xargs sed -i 's/apples/oranges/g'

Or, within an entire git repository:

@stevewithington
stevewithington / fancy-tabs-demo.html
Created Jun 4, 2019 — forked from ebidel/fancy-tabs-demo.html
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
View fancy-tabs-demo.html
<script>
function execPolyfill() {
(function(){
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1.
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
@stevewithington
stevewithington / useful-git-commands.md
Last active Jun 3, 2019
Useful Git Commands I Don't Use Every Day
View useful-git-commands.md

Useful Git Commands I Don't Use Every Day

Get the Size of a Git Repo, Excluding Ignored Files

git count-objects -vH

Produces something similar to:

View compare.js
compare(a: number, b: number): number {
return a > b
? 1
: a < b
? -1
: 0;
}
@stevewithington
stevewithington / prettify-json.js
Last active May 10, 2019
Prettify JSON, the easy way!
View prettify-json.js
// arbitrary js object:
var myJsObj = {a:'foo', 'b':'bar', c:[false,2,null, 'null']};
// using JSON.stringify pretty print capability:
var str = JSON.stringify(myJsObj, undefined, 4);
// Kudos: <https://stackoverflow.com/questions/26320525/prettify-json-data-in-textarea-input/26324037>
View app-routing.module.spec.ts
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Router, RouterModule } from '@angular/router';
import { NgModuleFactoryLoader, Component, NgModule } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { routes } from './app-routing.module'
import { Location } from '@angular/common';
describe('PageNotfoundComponent', () => {
let component: AppComponent;
View 01-debug-rxjs.ts
onSelectUser(participantId:string) {
this.participantsService.findParticipantById(parseInt(participantId))
.debug("Loading participant from backend")
.subscribe(
participant => {
...
},
console.error
);
@stevewithington
stevewithington / is-mobile-device.js
Created Apr 26, 2019
Detects Mobile Device Script
View is-mobile-device.js
window.mobilecheck = function() {
var check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|j
You can’t perform that action at this time.