Skip to content

Instantly share code, notes, and snippets.

View auwsom's full-sized avatar

auwsom

View GitHub Profile
This is an old version. See the new one in my dotfiles repo: https://raw.githubusercontent.com/auwsom/dotfiles/main/.bash_aliases
## These lines for importing these command aliases and functions into .bash_aliases (or .bashrc), the settings file for bash
# `wget https://gist.github.com/auwsom/57c4f7c9db585b3f67065f13055986cc/raw -O ~/.bash_aliases && source ~/.bashrc`
# `wget https://bit.ly/3o2fy8S -O ~/.bash_aliases && source ~/.bashrc`
# `cp -f ~/.bash_aliases /home/user/.bash_aliases && chown user:user /home/user/.bash_aliases`
#shellcheck "$0" # `apt install shellcheck` to check any script for any errors. uncomment line to check this one.
# see further down for more general Linux tips and learning sites
# unalias a
HISTCONTROL=ignoreboth:erasedups
alias rm='rm -I'
shopt -s histverify
alias h='history'
alias hh='history | tail -30'
alias rb='source ~/.bashrc'
@auwsom
auwsom / vim basics
Last active June 6, 2022 04:40
vim basics
https://spin.atomicobject.com/2016/04/19/vim-commands-cheat-sheet/
http://i.imgur.com/YLInLlY.png
https://vim.rtorr.com/
:q, :wq, :q!, ZZ # quit, write quit, quit force, write quit
i, Esc, v # insert mode, exit mode, visual mode
dd, dw, x, u, U, ctrl+r # cut line, cut word, delete char, undo, undo line, redo (:redo)
yy, pp, Y, o # copy line, paste line, open line
a, A, # insert at end, or after end
H, M, L, gg, G, 1G, 0, $, ^, {, }, # move to: top, mid, bottom, start/end doc, line 1, start/end line, start non-empty line, paragraph
# wget https://gist.github.com/auwsom/df90768bd9ef29bde3ea47e464f0d549/raw
# https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage
#!/bin/bash
threshold=1
count=0
while true
do
load=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 1000 / (t-t1); }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat))
@auwsom
auwsom / .bashrc echo - old
Last active November 28, 2021 21:40
bash config
# wget https://gist.github.com/auwsom/804b4470d22ae00d113cbf5b4eaba73c/raw or https://bit.ly/3rdK8hL
echo HISTCONTROL=ignorespace:ignoredups:erasedups >>~/.bashrc # no duplicate entries
echo shopt -s histverify >>~/.bashrc # confirm !number commands
echo set -o noclobber >>~/.bashrc ## use >| to force redirection even with noclobber
echo "bind '\",,\": \"\$\"'">>~/.bashrc
echo "bind '\",l\": \"\$_\"'">>~/.bashrc
echo "bind '\",h\": \"--help\"'">>~/.bashrc
echo "alias vimbash='vim ~/.bashrc'">>~/.bashrc
echo "alias rebash='source ~/.bashrc'">>~/.bashrc
@auwsom
auwsom / bash setup for docker
Last active December 17, 2020 00:25
bash setup for docker
# wget https://gist.github.com/auwsom/fbeb8bfd36af91bb482529ee499f1058/raw -O bashsetup_docker ; bash !$
set +o history && sleep 1
sed -i /^'alias d'/d ~/.bashrc; sed -i /^'function d'/d ~/.bashrc ## remove old
source ~/.bashrc ; exec bash ## have to restart shell to enter the bindings without recursion
#echo "HISTIGNORE=''" >>~/.bashrc
# sudo cp /usr/share/zoneinfo/US/Pacific /etc/localtime # cant set, read only
echo "alias d='docker'">>~/.bashrc
echo "alias dcm='docker commit'">>~/.bashrc # CONTAINER IMAGE_REPO:TAG <- have to specify or creates new image
echo "alias del='docker exec -it \$(docker ps -q -l) bash'">>~/.bashrc
echo "alias di='docker images'">>~/.bashrc
mv ~/DockerfileLeanFoundation.txt Dockerfile
docker build -t myimage .
docker exec -it 6dd923c8f0fe ls /data/
sudo vim Dockerfile
docker exec -it $(docker ps -q) apt list
docker rmi qc123
docker rm 2b25cfd0a98b
docker ps -a
docker info
docker system df
**emacs bash
ctl-e end
ctl-u clear to beg
ctl-w delete word backward
alt-d delete word forward
**history
*! susbtitution
!$ last word
@auwsom
auwsom / gist:f8f1c84aa0af9647fd3efca835b61262
Created October 24, 2018 17:11
CategoryId for YouTube dictionary
var dict1 = {1 :'Film & Animation', 2 :'Autos & Vehicles', 10 :'Music', 15 :'Pets & Animals', 17 :'Sports', 18 :'Short Movies', 19 :'Travel & Events', 20 :'Gaming', 21 :'Videoblogging', 22 :'People & Blogs', 23 :'Comedy', 24 :'Entertainment',
25 :'News & Politics', 26 :'Howto & Style', 27 :'Education', 28 :'Science & Technology', 29 :'Nonprofits & Activism', 30 :'Movies', 31 :'Anime/Animation', 32 :'Action/Adventure', 33 :'Classics', 34 :'Comedy', 35 :'Documentary',
36 :'Drama', 37 :'Family', 38 :'Foreign', 39 :'Horror', 40 :'Sci-Fi/Fantasy', 41 :'Thriller', 42 :'Shorts', 43 :'Shows', 44 :'Trailers'}