This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $(networksetup -getairportpower en0) == *On ]] | |
then | |
networksetup -setairportpower en0 off | |
else | |
networksetup -setairportpower en0 on | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var r, l, s, a, v, i; // (1) | |
r = /(?:97[89])?[-\s]?[0-9]{1}[-\s]?[0-9]{3}[-\s]?[0-9]{3}[-\s]?[0-9]{2}[-\s]?[0-9X]{1/; // (2) | |
l = window.location.href.match(r); // (3) | |
s = window.getSelection().toString().match(r); // (4) | |
a = document.activeElement; | |
if (a.value) { v = a.value.slice(a.selectionStart, a.selectionEnd).match(r) } // (5) | |
i = ""; // (6) | |
if (l) { i = l[0] } | |
if (s) { i = s[0] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compstring () { | |
STR_A_IN=$1 | |
STR_B_IN=$2 | |
STR_A_OUT="" | |
STR_B_OUT="" | |
POINTER="" | |
LENGTH=${#STR_A_IN} | |
if [ $# -lt 2 ] || [ -z $1 ]|| [ -z $2 ]; then | |
echo "You must provide two strings to compare" | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const specialKey = navigator.userAgent.indexOf('Macintosh') != -1 ? "metaKey" : "ctrlKey"; | |
const otherKeys = ['altGraphKey','altKey','ctrlKey','metaKey','shiftKey'].filter(k => k !== specialKey); | |
document.addEventListener('keydown', event => { | |
if (event.code === key && event[specialKey] === true && !otherKeys.some(k => event[k] === true)) { | |
// Do something | |
event.preventDefault(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL := /bin/zsh | |
DEST ?= print | |
PORT ?= 8888 | |
WATCH ?= *.pug, *.less | |
BUILD ?= pug --out $(DEST) [^_]*.pug | |
includes := $(shell cat _include) | |
build: copy convert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function romanise (number, upper=true) { | |
if (number > 1999999) { | |
console.warn('WARN: attempted to convert number over 1,999,999 to roman numeral'); | |
return number; | |
} | |
const letters = upper ? [ | |
['X', 'V', 'I'], | |
['C', 'L', 'X'], | |
['M', 'D', 'C'], | |
['X̅', 'V̅', 'M'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace "version" do | |
path = 'lib/gem-name/version.rb' | |
content = File.read(path) | |
regex = /(VERSION\s*=\s*['"])([0-9.]+)(['"])/ | |
match = content.match(regex) | |
version = match[2] | |
vparts = version.split('.') | |
major = vparts[0] ? Integer(vparts[0]) : 0 | |
minor = vparts[1] ? Integer(vparts[1]) : 0 | |
patch = vparts[2] ? Integer(vparts[2]) : 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isoTimeStamp(date, options = {}) { | |
console.log(options) | |
let defaults = { | |
date_time: 'T', | |
time_offset: '' | |
} | |
Object.assign(options, Object.assign(defaults, options)); | |
console.log(options) | |
const year = date.getFullYear(); | |
const month = String(date.getMonth()).padStart(2, '0'); |