Skip to content

Instantly share code, notes, and snippets.

View cjohnson496's full-sized avatar

Charles Johnson cjohnson496

View GitHub Profile

Found here by Stephan Farestam

Here is a bash-only YAML parser that leverages sed and awk to parse simple yaml files:

function parse_yaml {
   local prefix=$2
   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|^\($s\):|\1|" \
        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \

-e "s|^($s)($w)$s:$s(.*)$s$|\1$fs\2$fs\3|p" $1 |

@cjohnson496
cjohnson496 / Documentation.md
Created October 6, 2020 20:33 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@cjohnson496
cjohnson496 / newscript.sh
Created April 29, 2020 19:33 — forked from aaronNGi/newscript.sh
Boilerplate for new POSIX shell scripts
#!/bin/sh
prog_name=${0##*/}
version=1.0
version_text="Boilerplate for new scripts v$version"
options="h o: q v V"
help_text="Usage: $prog_name [-o <text>] [-hqvV] [<file>]...
Boilerplate for new scripts
# Example ssh config file. Usually located in ~/.ssh/config (user) or /etc/ssh/ssh_config (system)
# This works on both linux and MacOS
# Basic ssh commands converted to ssh/config file format
# Simplest format
# Run with: "ssh blog" => (equivalent to: "ssh ubuntu@example.com" and "ssh -i ~/.ssh/id_rsa -p 22 ubuntu@example.com")
Host blog
@cjohnson496
cjohnson496 / keystroke-toggle-linenumbers-settings.json
Created March 25, 2020 19:18 — forked from pid/keystroke-toggle-linenumbers-settings.json
Sublime Text keystroke toggle line numbers show/hide
{
"keys": ["ctrl+alt+l"],
"command": "toggle_setting",
"args": {
"setting": "line_numbers"
}
@cjohnson496
cjohnson496 / web-servers.md
Created March 24, 2020 20:40 — 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
@cjohnson496
cjohnson496 / .bash_profile
Created March 10, 2020 03:37 — forked from ethyde/.bash_profile
Bash profile load ssh-agent and add all key in ~/.ssh/id_rsa*
# SSH Agent
# Note: ~/.ssh/environment should not be used, as it
# already has a different purpose in SSH.
# source : https://www.schoonology.com/technology/ssh-agent-windows/
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
#Windows 10 Decrapifier 1803/1809
#By CSAND
#Oct 5 2018
#
#
#PURPOSE: Eliminate much of the bloat that comes with Windows 10.
#
# Change many privacy settings to be off by default. Remove
# built-in advertising, Cortana, OneDrive, Cortana stuff
# (all optional).
@cjohnson496
cjohnson496 / pull_request_checklist.md
Created January 17, 2019 22:06 — forked from namuan/pull_request_checklist.md
[Pull Request] #checklist

Ref: https://github.com/felipefarias/pull-requests-checklist/blob/master/checklist-en.md

[ ] Pull request workflow

  • Read thoroughly the feature description to check if everything is implemented.
  • Run the code and use it as the end user would. Double check requested feature’s description.

[ ] Creating the pull request

  • Create Pull Request (but don't assign it yet).
  • Describe how to test the PR: urls, environment variables and other needs.
  • Refer to issue(s)/Trello card(s) the PR solves.
@cjohnson496
cjohnson496 / wget.sh
Created January 2, 2019 02:49 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
wget \
--recursive \ # Download the whole site.
--no-clobber \ # Don't overwrite existing files.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
--restrict-file-names=windows \ # Modify filenames to work in Windows as well.
--domains yoursite.com \ # Do not follow links outside this domain.
--no-parent \ # Don't follow links outside the directory you pass in.