Skip to content

Instantly share code, notes, and snippets.

View duncanmcdougall's full-sized avatar

Duncan McDougall duncanmcdougall

View GitHub Profile
Infrequently ran command line apps
npx speed-test -b
npx wifi-password-cli [your-wifi-network-name]
npx http-server -o [path]
@duncanmcdougall
duncanmcdougall / settings.json
Last active September 28, 2019 20:01
VSCode Personal Settings
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"breadcrumbs.enabled": true,
"editor.fontFamily": "Fira Code, Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
@duncanmcdougall
duncanmcdougall / ClearItAllBookmarklet.js
Created July 27, 2017 08:43
Bookmarklet to Clear Cookies, LocalStorage and Session Storage
javascript:(function(){ localStorage.clear(); sessionStorage.clear(); var c = document.cookie.split("; "); for (i in c) { document.cookie =/^[^=]+/.exec(c[i])[0]+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; }; })();
@duncanmcdougall
duncanmcdougall / AutotabOnMaxLength.js
Created March 9, 2017 12:18
Angular 1 Autotab On Maxlength Directive
myApp.directive("autotabOnMaxlength", function () {
return {
restrict: "A",
require: "ngModel",
link: function ($scope, element, attr, ctrl) {
ctrl.$viewChangeListeners.push(function () {
if (element.val().length == element.attr("maxlength")) {
var elems = Array.prototype.filter.call(document.querySelectorAll('input, select, textarea, button, [tabindex]'), function(elem) {
return (elem.offsetParent != null) && !elem.disabled;
});
@duncanmcdougall
duncanmcdougall / FlattenJavascriptObject.js
Created September 7, 2015 06:55
Flattens a nested javascript object into a flat object with long keys with .'s and [0]'s
/* Flattens a nested javascript object into a flat object with long keys with .'s and [0]'s */
function FlattenJavaScriptObject(toFlatten, prefix) {
var result = {};
var traveseObject = function (theObject, path) {
if (!(typeof theObject === 'string') && theObject instanceof Array) {
for (var i = 0; i < theObject.length; i++) {
var key = path + "[" + i + "]";
if (typeof theObject[i] === 'string') {
var Utils = (function () {
var M = {};
var _somethingPrivate = function () {
return "pears";
};
M.apples = function () {
return "apples";
@duncanmcdougall
duncanmcdougall / number-of-lines.js
Created October 22, 2013 10:46
jQuery function to get the number of lines in a **basic** block of text. Only for use on basic blocks of text, no internal elements fuckin with the line-height.
function numberOfLines(selector) {
return $(selector).height()/parseInt($(selector).css('lineHeight'));
}
@duncanmcdougall
duncanmcdougall / 1-too-much-nesting-fixed.less
Last active December 25, 2015 10:39
code for a blogpost
.main-header {
.nav {
background-color: black;
li {
display: inline-block;
}
a {
color: white;
@duncanmcdougall
duncanmcdougall / 1-too-much-nesting.less
Last active December 25, 2015 10:39
Code for a new blog post
.main-header {
.nav {
background-color: black;
ul {
li {
display: inline-block;
a {