Skip to content

Instantly share code, notes, and snippets.

View pwpearson's full-sized avatar
🏠
Working from home

Patrick (Rick) Pearson pwpearson

🏠
Working from home
View GitHub Profile
@pwpearson
pwpearson / random_hash.sh
Created August 23, 2021 20:29 — forked from rietta/random_hash.sh
Easy command line random hash generator for Mac OS X, Linux, and FreeBSD.
#!/bin/sh
head -n 4096 /dev/urandom | openssl sha1
@pwpearson
pwpearson / sha256.sh
Created August 23, 2021 20:28 — forked from HassenIO/sha256.sh
Get SHA256 of a text in Mac OSX terminal
# Get SHA256 of a text
# Usage: sha256 password
# output: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
function sha256() {
echo -n $1 | shasum -a 256
# Source: http://albertech.blogspot.fr/2015/02/generate-sha-256-hash-from-command-line.html
}
@pwpearson
pwpearson / pre-commit
Created January 12, 2020 20:06 — forked from akaleeroy/pre-commit
OpenSCAD Export git pre-commit hook
#!/usr/bin/sh
# Requires OpenSCAD on $PATH
# Automatically re-exports all changed .scad files pre-commit
git diff --cached --name-only | grep ".scad$" | while read -r file; do
basename="${file%.*}"
echo "Exporting $file to $basename.stl..."
openscad -o "$basename.stl" "$file"
done
@pwpearson
pwpearson / Data Dictionary.md
Last active December 13, 2019 12:55
Data Dictionary a Toolbox Approach

Add to .bashrc or .bash_profile

function git_undelete_file () {
  if [ $# -eq 0 ]; then
        echo "Usage: git_undelete_file <filepath>";
        exit 1;
  fi

 git checkout $(git rev-list -n 1 HEAD -- "$1")^ -- "$1"
@pwpearson
pwpearson / makeImage.sh
Created September 30, 2019 13:45 — forked from bitboxer/makeImage.sh
create a sparsebundle for mac os backups
#!/bin/bash
# A bash script to create a time machine disk image suitable for
# backups with OS X 10.6 (Snow Leopard)
# This script probably only works for me, so try it at your own peril!
# Use, distribute, and modify as you see fit but leave this header intact.
# (R) sunkid - September 5, 2009
#
# This will create a time machine ready disk image named with your
# computer's name with a maximum size of 600GB and copy it to
# /Volumes/backup. The image "file" (it's a directory, really) will
@pwpearson
pwpearson / Macdown Table of Contents (TOC).md
Created September 23, 2019 14:09
How to create TOC in Macdown

Add [toc] to md file to generate table of contents

###Mount HFS & HFSPLUS (Apple Filesystem Types)

First thing first, you have to install kmod-hfs & kmod-hfsplus and hfsplus-tools.

Step 1: Import GPG Key

rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org

To install ELRepo for CentOS-7:

1. Create new container
a) docker run -i -t ubuntu /bin/bash
b) docker run --name rails_dev_container -i -t ubuntu ubuntu /bin/bash
The command line flags - i -t provide an interactive shell in the new container
2. Show running docker containers ==> docker ps
3. Show list of current containers ==>
a) docker ps -a (Show all containers, both stopped and running)
b) docker ps -n x (shows the last x containers, running or stopped, ex: docker ps -n 5)

Months

SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0) -- First day of previous month

SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), -1) -- Last Day of previous month

SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) -- First day of this month

SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, -1) -- Last day of this month