Skip to content

Instantly share code, notes, and snippets.

View garettmd's full-sized avatar
🌩️
Cloudy with a chance of automation 🤖

Garett Dunn garettmd

🌩️
Cloudy with a chance of automation 🤖
View GitHub Profile
@garettmd
garettmd / web-servers.md
Created May 13, 2021 14:29 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@garettmd
garettmd / script-template.sh
Created December 15, 2020 18:27 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var styleEl = document.getElementById('css-layout-hack');
if (styleEl) {
styleEl.remove();
return;
}
styleEl = document.createElement('style');
styleEl.id = 'css-layout-hack';
@garettmd
garettmd / html-languages.txt
Created October 9, 2018 14:50 — forked from JamieMason/html-languages.txt
HTML lang attribute / ISO language code reference / Culture names
CULTURE SPEC.CULTURE ENGLISH NAME
--------------------------------------------------------------
Invariant Language (Invariant Country)
af af-ZA Afrikaans
af-ZA af-ZA Afrikaans (South Africa)
ar ar-SA Arabic
ar-AE ar-AE Arabic (U.A.E.)
ar-BH ar-BH Arabic (Bahrain)
ar-DZ ar-DZ Arabic (Algeria)
ar-EG ar-EG Arabic (Egypt)
@garettmd
garettmd / git-backup-to-Backblaze-B2.sh
Created June 1, 2018 17:42 — forked from nilayp/git-backup-to-Backblaze-B2.sh
Complete git repository backup script to Backblaze B2
#!/bin/bash
# Script to backup git repo to Backblaze B2
# Set bucket, dir, password and account to use for the backup. I keep mine in local env vars
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc
# Ensure you have authorized the B2 command line tool with the correct account AND added your SSH
# public key to your github account, if you need to backup private repositories.
# To restore this repo in the future, download it from B2, extract it and then use this command:
# cd old-repository.git
@garettmd
garettmd / http_get.go
Created May 14, 2018 13:43 — forked from ijt/http_get.go
Example of using http.Get in go (golang)
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
@garettmd
garettmd / values_pointers.go
Created May 14, 2018 13:37 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@garettmd
garettmd / parse_json.go
Created May 11, 2018 20:37 — forked from mjohnsullivan/parse_json.go
Parse JSON objects with arbitrary key names in Go using interfaces and type assertions
// Parsing arbitrary JSON using interfaces in Go
// Demonstrates how to parse JSON with abritrary key names
// See https://blog.golang.org/json-and-go for more info on generic JSON parsing
package main
import (
"encoding/json"
"fmt"
)
@garettmd
garettmd / gist:e3931591023dae4c9a89eeaa4b879ba2
Created April 4, 2018 18:49 — forked from kfriend/gist:0c81cd0b0bcd5dec2b9f
OS X: Create El Capitan ISO compatible with VirtualBox
#!/usr/bin/env bash
# All credit goes to http://apple.stackexchange.com/a/211722, and thanks to Jesse Web
# for posting the article at http://apple.stackexchange.com/questions/198737/install-el-capitan-in-virtual-box-for-testing-purposes
hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/esd
hdiutil create -o elcapitan.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach elcapitan.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/iso
asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/iso -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
@garettmd
garettmd / README.md
Created December 13, 2017 15:29 — forked from ewenchou/README.md
Run Python script as systemd service
  1. Create a service file like dash_sniffer.service
  2. Put it in /lib/systemd/system/
  3. Reload systemd using command: systemctl daemon-reload
  4. Enable auto start using command: systemctl enable dash_sniffer.service