Skip to content

Instantly share code, notes, and snippets.

Avatar

Shane Lawrence tehshane

View GitHub Profile
@tehshane
tehshane / flattenObject.js
Created May 25, 2019
Flatten an object to a single depth
View flattenObject.js
/*
* @fileoverview Flatten an object to a single layer deep
* @author Muthukrishnan (https://stackoverflow.com/users/1173436/muthukrishnan)
* @url https://stackoverflow.com/a/53739792
*/
function flattenObject (ob) {
const toReturn = {};
for (const i in ob) {
if (!ob.hasOwnProperty(i)) continue;
@tehshane
tehshane / pre-commit
Last active May 29, 2019 — forked from kuy/pre-commit
git: pre-commit hook script to prevent committing FIXME code
View pre-commit
#!/bin/sh
matches=$(git diff --cached | grep -E '\+.*?\/\/\s?(DEBUG|FIXME|debugger\;)')
if [ "$matches" != "" ]
then
echo "Detected possible debug-only code."
echo "Are you sure you want to commit it?"
echo " ${matches}"
exit 1
@tehshane
tehshane / keybase.md
Created Dec 14, 2018
Keybase Proof (2hat_shane)
View keybase.md

Keybase proof

I hereby claim:

  • I am tehshane on github.
  • I am 2hat_shane (https://keybase.io/2hat_shane) on keybase.
  • I have a public key whose fingerprint is AF78 AA96 E324 067D C831 781A 9F24 5988 B913 FF05

To claim this, I am signing this object:

@tehshane
tehshane / check-password.js
Created Apr 28, 2018
Snippet to check a password against the Have I Been Pwned API
View check-password.js
const PASSWORD = '';
const crypto = require('crypto')
const shasum = crypto.createHash('sha1')
const http = require('https');
shasum.update(PASSWORD);
const hash = shasum.digest('hex').toUpperCase();
http.get('https://api.pwnedpasswords.com/range/' + hash.substr(0,5), res => {
View gist:627b15cc925dbc329dea5cee09e1c1b9
### Keybase proof
I hereby claim:
* I am tehshane on github.
* I am tehshane (https://keybase.io/tehshane) on keybase.
* I have a public key ASBIl08dZCRG-AkeruDLkSHaMAMv5VEMUYWPptZ9Hi_MpQo
To claim this, I am signing this object:
@tehshane
tehshane / Microsoft Sculpt Mobile Keyboard Remap
Last active Mar 29, 2021
AutoHotKey script that remaps the F1-F12 function keys on the Microsoft Sculpt Mobile keyboard to be pressed without having to use the Fn key. Disables some of the Windows 8 shortcuts, but leaves media keys intact.
View Microsoft Sculpt Mobile Keyboard Remap
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#InstallKeybdHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; OPTIONAL: For those who use Home/End more than PgUp/PgDown, this flips their use with the Fn key.
; If you want the buttons to function as they are, add a semicolon (;) to the beginning of each line below.
Home::PgUp
End::PgDn
PgUp::Home