Skip to content

Instantly share code, notes, and snippets.

View shannonwells's full-sized avatar
🦞
Not being hasty

Shannon Wells shannonwells

🦞
Not being hasty
View GitHub Profile
@shannonwells
shannonwells / writeones-instructions.sh
Last active June 30, 2021 21:15
How to write a bunch of ones to disk
# Lifted from Stack Overflow. This worked for me, it's fast, yes but it still takes awhile to write to a 500 GB
# disk - about 3-4 hours. Instead of just filling up the disk I routed it to an output file and included a count.
# Also I have replaced seq with
# echo {1..65536}
# as being part of coreutils, seq is unavailable in restore mode on OS X.
# So the command I used to run the script was:
# sh /tmp/writeones.sh | dd of=/Volumes/Machintosh\ HD/output.txt bs=65536 count=500000000
# --sew
# HOWEVER, if you think of it first, use the shred tool.
@shannonwells
shannonwells / app.js
Last active August 17, 2020 17:24
Toy websocket client
const express = require('express');
const app = express();
const WebSocket = require("ws");
app.get('/', function (req, res) {
res.send('This is not really a web page.');
});
const port = 3997
@shannonwells
shannonwells / nup.bash
Created July 17, 2020 16:24
A git update script for a nodejs project
#!/bin/bash
# emojis help instantly recognize something went wrong and where
function exit_err() { echo "❌ 💔" ; exit 1; }
set -Euo pipefail
echo "Updating your repo."
echo "☕️ Take a break - this might take a few minutes."
git stash
git co master -q
git pull origin master --ff-only -q
@shannonwells
shannonwells / pre-commit
Created July 17, 2020 16:20
pre-commit for a go project
#!/bin/bash
export GO_NAMES='\.(go)$'
export GO_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $GO_NAMES)
function exit_err() { echo "❌ 💔" ; exit 1; }
if [[ ! -z $GO_FILES ]]
then
echo "Examining $GO_FILES"
echo $GO_FILES | xargs gofmt -s -w || exit_err
@shannonwells
shannonwells / pre-commit
Created July 17, 2020 16:14
pre-commit hook for nodejs projects in Typescript and Javascript.
#!/bin/bash
export JSNAMES='\.(js|ts)$'
export JSNAMES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $JSNAMES)
function exit_err() { echo "❌ 💔" ; exit 1; }
if [[ ! -z $JSNAMES ]]
then
echo "Examining $JSNAMES"
echo $JSNAMES | xargs npm run format || exit_err
@shannonwells
shannonwells / reflections_cats_test.go
Last active May 19, 2021 17:27
Reflections in Go, For Cats
package reflect_cats_test
import (
"encoding/json"
"net/url"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@shannonwells
shannonwells / 00_bootstrap.sh
Last active October 5, 2024 00:11
Install scripts for use with a USB key, for setting up a new Mac for development.
#!/usr/bin/env bash
PWD=`pwd`
FILES="AllApps casks formulas"
source ./utils.sh
for file in ${FILES} ; do
if [ ! -f ${file} ] ; then
exit_err "${file} is missing. Ensure the following files are all present, then rerun: ${FILES}"
@shannonwells
shannonwells / pre-commit
Created January 12, 2019 00:15
Pre commit hook for a rails project that uses yarn
#!/bin/sh
RUBOCOP_NAMES='\.(rb|rake)$'
ESLINT_NAMES='\.(es6|jsx|js)$'
PRETTIER_NAMES='\.(es6|jsx|js|scss|json)$'
RUBOCOP_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $RUBOCOP_NAMES)
ESLINT_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $ESLINT_NAMES)
PRETTIER_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $PRETTIER_NAMES)
@shannonwells
shannonwells / gup.bash
Last active June 18, 2019 17:20
Go repo helpers
#!/bin/bash
# This is specifically for the go-filecoin repo but a subset of this can apply to any go project with git
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Euo pipefail
echo "Updating your repo."
echo "☕️ Take a break - this might take a few minutes."
git stash
git co master -q
@shannonwells
shannonwells / uprepo.sh
Last active January 12, 2019 00:11
Script to do all the updating and whatnot to prepare for rebasing or creating a new git branch -- for a Rails project with yarn
#!/bin/bash
THISDIR="dirname ${BASH_SOURCE}"
echo "Updating your repo."
echo "☕️ Take a break - this might take a few minutes."
git co development -q
git pull origin development --ff-only -q
git fetch --prune -q
bundle install --quiet
yarn install -s