Skip to content

Instantly share code, notes, and snippets.


Mike mikebarnhardt

View GitHub Profile
mikebarnhardt / commands.txt
Last active Apr 15, 2020
Reinstall Xcode Command Line Tools
View commands.txt
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
mikebarnhardt / router.js
Last active Feb 29, 2020
Basic API request with Express
View router.js
// Axios is a third-party request lib.
const axios = require('axios');
const Router = require('express').Router;
const router = new Router();
// Router handler that when you go to '/api' will run.
router.get('/api', function(req, res, next) {
// What do we want to do when this URL is visited?
View git.txt
# Force Git to track case changes in filenames.
git config --unset-all core.ignorecase && git config --system core.ignorecase false
View move-itunes-corner.txt
osascript <<EOF
tell application "System Events" to tell process "iTunes"
set position of window 1 to {64, 896}
set size of window 1 to {410, 480}
end tell
mikebarnhardt /
Created Feb 7, 2018
Generate and Add SSH Key to a Server


Generate a key if needed:

ssh-keygen -t rsa

It should now be located in: ~/.ssh/ as id_rsa and

mikebarnhardt / render.js
Created Jan 16, 2018
PDF.js with text selection
View render.js
// Taken from
var page_num = 1;
var scale = 1.5;
var viewport = page.getViewport(scale);
var canvas = $('#the-canvas')[0];
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
mikebarnhardt / treeify.js
Created Jan 16, 2018
Hierarchy tree from flat list
View treeify.js
// Taken from
function treeify(list, idAttr, parentAttr, childrenAttr) {
if (!idAttr) idAttr = 'id';
if (!parentAttr) parentAttr = 'parent';
if (!childrenAttr) childrenAttr = 'children';
var treeList = [];
var lookup = {};
list.forEach(function(obj) {
lookup[obj[idAttr]] = obj;
mikebarnhardt / shuffle.js
Created Jan 16, 2018
Fisher-Yates Shuffle
View shuffle.js
// Taken from
function shuffle(array) {
var m = array.length, t, i;
// While there remain elements to shuffle…
while (m) {
// Pick a remaining element…
i = Math.floor(Math.random() * m--);
mikebarnhardt /
Created Jan 2, 2018
Give www folder to group permissions.

Add your Node user. If Apache or something else this could be www-data.

sudo adduser nodejs

Add users to that group to allow access to the www directory.

sudo usermod -aG nodejs <username>
mikebarnhardt /
Created Jan 2, 2018
Rename local and remote Github branch
  1. Rename your local branch. If you are on the branch you want to rename:
git branch -m new-name

If you are on a different branch:

You can’t perform that action at this time.