Skip to content

Instantly share code, notes, and snippets.

View TravisMullen's full-sized avatar

Travis Mullen TravisMullen

View GitHub Profile
[
"Dasher",
"Dancer",
"Prancer",
"Vixen",
"Comet",
"Cupid",
"Donner",
"Bliksem",
"Rudolph"
@TravisMullen
TravisMullen / nonce.js
Created March 14, 2019 02:26
Unique Nonce Generator
const {
randomFill
} = require('crypto')
const dirtyNonce = {}
const _nonce = () => {
const buf = Buffer.alloc(16)
return new Promise((resolve, reject) => {
randomFill(buf, (err, buf) => {
@TravisMullen
TravisMullen / add-new-user.sh
Created February 27, 2019 16:46
Add new sudo user.
sudo adduser $NEW_USER
sudo usermod -aG sudo $NEW_USER
@TravisMullen
TravisMullen / rpi-default-user.sh
Last active March 9, 2019 19:27
Change Raspi Pi default username.
echo "What is your new username?"
read $USER
# Close putty and connect again this time with the following credentials
# Username: root
# Password: <new password you created>
# Now we will change the pi username to something different, replace $NAME with whatever you pick
sudo usermod -l $NAME -d /home/$NAME -m pi
sudo chown $NAME /home/$NAME
# Close putty and connect again this time with your new username
@TravisMullen
TravisMullen / secure-erase-osx.sh
Last active January 17, 2022 17:32
Secure Erase
#!/bin/sh
echo "empty ~/.Trash"
rm -rf ~/.Trash/*
echo "Secure Erase Freespace /dev/disk1"
diskutil secureErase freespace 2 /dev/disk1
@TravisMullen
TravisMullen / check-file.js
Last active October 16, 2018 19:11
Check file and delete file.
import { statSync } from 'fs'
import { spawnSync } from 'child_process'
/**
* Does file exist.
*
* @public
* @param {string} filePath Path to file.
* @return {boolean} File is found. <true>
@TravisMullen
TravisMullen / getCharactersUnicodeValue.js
Created August 11, 2018 20:21
get Unicode values of character
// get Unicode values of character items in an array
function getCharactersUnicodeValue(characters) {
const unicodeChart = new Map();
characters.forEach(character => {
unicodeChart.set(
character,
character.charCodeAt(character.indexOf(character))
);
});
console.table(unicodeChart);
@TravisMullen
TravisMullen / hexGenerator.js
Created August 5, 2018 13:15
Generate a random hex value.
const hexGenerator = function(length = 16) {
let text = "";
const possible = "ABCDEFabcdef0123456789";
for(let i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
// convert to random with parseInt(`0x${hexGenerator()}`, 16)
@TravisMullen
TravisMullen / lit-element-repeat.html
Created June 8, 2018 22:04
Example: Lit Element's Repeat Method
<html>
<head>
<!-- Polyfills only needed for Firefox and Edge. -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@next/webcomponents-loader.js"></script>
</head>
<body>
<!-- Works only on browsers that support Javascript modules like
Chrome, Safari, Firefox 60, Edge 17 -->
<script type="module">
import { LitElement, html } from 'https://unpkg.com/@polymer/lit-element@latest/lit-element.js?module';
@TravisMullen
TravisMullen / sortJawn.mjs
Last active June 3, 2018 07:12
The Good Sort.
/**
* The Good Sort. When your object attribute [values] are shady AF.
* @param {any} valueA
* @param {any} valueB
* @param {Boolean} descending - True for descending. Default is [false] ascending.
*/
export default function sortJawn (valueA, valueB, descending = false) {
// the same... carry on
if (valueA === valueB) {
return 0