Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisallenlane committed Oct 16, 2019
0 parents commit 04c0b99
Show file tree
Hide file tree
Showing 196 changed files with 5,720 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cheatsheets
===========
This repository contains community-sourced cheatsheets to be used with
[cheat][] and similar applications.

### Format ###
Cheatsheets are plain-text files that begin with an optional "front matter"
header in YAML format. The header may be used to assign "tags" to a sheet, and
to specify the sheet's syntax (`bash`, `python`, `go`, etc).

When possible, cheatsheets should conform to this format:

```sh
---
syntax: bash
tags: [ vcs, development ]
---
# To stage all changes in the current directory:
git add --all

# To commit staged changes:
git commit -m "chore: updated the README"
```


[cheat]: https://github.com/cheat/cheat
29 changes: 29 additions & 0 deletions 7z
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
7z
A file archiver with highest compression ratio

Args:
a add
d delete
e extract
l list
t test
u update
x extract with full paths

Example:
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1

-t7z 7z archive
-m0=lzma lzma method
-mx=9 level of compression = 9 (ultra)
-mfb=64 number of fast bytes for lzma = 64
-md=32m dictionary size = 32 Mb
-ms=on solid archive = on

7z exit codes:
0 normal (no errors or warnings)
1 warning (non-fatal errors)
2 fatal error
7 bad cli arguments
8 not enough memory for operation
255 process was interrupted
5 changes: 5 additions & 0 deletions ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# send 100 requests with a concurency of 50 requests to an URL
ab -n 100 -c 50 http://www.example.com/

# send requests during 30 seconds with a concurency of 50 requests to an URL
ab -t 30 -c 50 URL http://www.example.com/
5 changes: 5 additions & 0 deletions alias
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Show a list of your current shell aliases
alias

# Map `ll` to `ls -l` (Can be used per session or put inside a shell config file)
alias ll='ls -l'
72 changes: 72 additions & 0 deletions ansi
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Reset
Color_Off='\e[0m' # Text Reset

# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White

# Bold
BBlack='\e[1;30m' # Black
BRed='\e[1;31m' # Red
BGreen='\e[1;32m' # Green
BYellow='\e[1;33m' # Yellow
BBlue='\e[1;34m' # Blue
BPurple='\e[1;35m' # Purple
BCyan='\e[1;36m' # Cyan
BWhite='\e[1;37m' # White

# Underline
UBlack='\e[4;30m' # Black
URed='\e[4;31m' # Red
UGreen='\e[4;32m' # Green
UYellow='\e[4;33m' # Yellow
UBlue='\e[4;34m' # Blue
UPurple='\e[4;35m' # Purple
UCyan='\e[4;36m' # Cyan
UWhite='\e[4;37m' # White

# Background
On_Black='\e[40m' # Black
On_Red='\e[41m' # Red
On_Green='\e[42m' # Green
On_Yellow='\e[43m' # Yellow
On_Blue='\e[44m' # Blue
On_Purple='\e[45m' # Purple
On_Cyan='\e[46m' # Cyan
On_White='\e[47m' # White

# High Intensity
IBlack='\e[0;90m' # Black
IRed='\e[0;91m' # Red
IGreen='\e[0;92m' # Green
IYellow='\e[0;93m' # Yellow
IBlue='\e[0;94m' # Blue
IPurple='\e[0;95m' # Purple
ICyan='\e[0;96m' # Cyan
IWhite='\e[0;97m' # White

# Bold High Intensity
BIBlack='\e[1;90m' # Black
BIRed='\e[1;91m' # Red
BIGreen='\e[1;92m' # Green
BIYellow='\e[1;93m' # Yellow
BIBlue='\e[1;94m' # Blue
BIPurple='\e[1;95m' # Purple
BICyan='\e[1;96m' # Cyan
BIWhite='\e[1;97m' # White

# High Intensity backgrounds
On_IBlack='\e[0;100m' # Black
On_IRed='\e[0;101m' # Red
On_IGreen='\e[0;102m' # Green
On_IYellow='\e[0;103m' # Yellow
On_IBlue='\e[0;104m' # Blue
On_IPurple='\e[0;105m' # Purple
On_ICyan='\e[0;106m' # Cyan
On_IWhite='\e[0;107m' # White
14 changes: 14 additions & 0 deletions apk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Install a package
apk add $package

# Remove a package
apk del $package

# Update repos
apk update

# Upgrade all packages
apk upgrade

# Find a package
apk search $package
18 changes: 18 additions & 0 deletions apparmor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Desc: Apparmor will protect the system by confining programs to a limited set of resources.

# To activate a profile:
sudo aa-enforce usr.bin.firefox
# OR
export _PROFILE_='usr.bin.firefox' sudo $(rm /etc/apparmor.d/disable/$_PROFILE_ ; cat /etc/apparmor.d/$_PROFILE_ | apparmor_parser -a )

# TO disable a profile:
sudo aa-disable usr.bin.firefox
# OR
export _PROFILE_='usr.bin.firefox' sudo $(ln -s /etc/apparmor.d/$_PROFILE_ /etc/apparmor.d/disable/ && apparmor_parser -R /etc/apparmor.d/$_PROFILE_)

# To list profiles loaded:
sudo aa-status
# OR
sudo apparmor_status

# List of profiles aviables: /etc/apparmor.d/
23 changes: 23 additions & 0 deletions apt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# To search a package:
apt search package

# To show package informations:
apt show package

# To fetch package list:
apt update

# To download and install updates without installing new package:
apt upgrade

# To download and install the updates AND install new necessary packages:
apt dist-upgrade

# Full command:
apt update && apt dist-upgrade

# To install a new package(s):
apt install package(s)

# To uninstall package(s)
apt remove package(s)
12 changes: 12 additions & 0 deletions apt-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To search for apt packages:
apt-cache search "whatever"

# To display package records for the named package(s):
apt-cache show pkg(s)

# To display reverse dependencies of a package
apt-cache rdepends package_name

# To display package versions, reverse dependencies and forward dependencies
# of a package
apt-cache showpkg package_name
28 changes: 28 additions & 0 deletions apt-get
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Desc: Allows to update the operating system

# To fetch package list
apt-get update

# To download and install updates without installing new package.
apt-get upgrade

# To download and install the updates AND install new necessary packages
apt-get dist-upgrade

# Full command:
apt-get update && apt-get dist-upgrade

# To install a new package(s)
apt-get install package(s)

# Download a package without installing it. (The package will be downloaded in your current working dir)
apt-get download modsecurity-crs

# Change Cache dir and archive dir (where .deb are stored).
apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ...

# Show apt-get installed packages.
grep 'install ' /var/log/dpkg.log

# Silently keep old configuration during batch updates
apt-get update -o DPkg::Options::='--force-confold' ...
15 changes: 15 additions & 0 deletions aptitude
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To search for packages:
aptitude search "whatever"

# To display package records for the named package(s):
aptitude show pkg(s)

# To install a package:
aptitude install package

# To remove a package:
aptitude remove package

# To remove unnecessary package:
aptitude autoclean

12 changes: 12 additions & 0 deletions aria2c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Just download a file
# The url can be a http(s), ftp, .torrent file or even a magnet link
aria2c <url>

# To prevent downloading the .torrent file
aria2c --follow-torrent=mem <url>

# Download 1 file at a time (-j)
# continuing (-c) any partially downloaded ones
# to the directory specified (-d)
# reading urls from the file (-i)
aria2c -j 1 -c -d ~/Downloads -i /path/to/file
22 changes: 22 additions & 0 deletions asciiart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To show some text in ASCII Art:

figlet Cheat
# ____ _ _
# / ___| |__ ___ __ _| |_
#| | | '_ \ / _ \/ _` | __|
#| |___| | | | __/ (_| | |_
# \____|_| |_|\___|\__,_|\__|
#


# To have some text with color and other options:
# Show with a border
toilet -F border Cheat
# Basic show (filled)
toilet Cheat
# mmm # m
# m" " # mm mmm mmm mm#mm
# # #" # #" # " # #
# # # # #"""" m"""# #
# "mmm" # # "#mm" "mm"# "mm
#
17 changes: 17 additions & 0 deletions asterisk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To connect to a running Asterisk session:
asterisk -rvvv

# To issue a command to Asterisk from the shell:
asterisk -rx "<command>"

# To originate an echo call from a SIP trunk on an Asterisk server, to a specified number:
asterisk -rx "channel originate SIP/<trunk>/<number> application echo"

# To print out the details of SIP accounts:
asterisk -rx "sip show peers"

# To print out the passwords of SIP accounts:
asterisk -rx "sip show users"

# To print out the current active channels:
asterisk -rx "core show channels"
17 changes: 17 additions & 0 deletions at
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To schedule a one time task
at {time}
{command 0}
{command 1}
Ctrl-d

# {time} can be either
now | midnight | noon | teatime (4pm)
HH:MM
now + N {minutes | hours | days | weeks}
MM/DD/YY

# To list pending jobs
atq

# To remove a job (use id from atq)
atrm {id}
11 changes: 11 additions & 0 deletions awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# sum integers from a file or stdin, one integer per line:
printf '1\n2\n3\n' | awk '{ sum += $1} END {print sum}'

# using specific character as separator to sum integers from a file or stdin
printf '1:2:3' | awk -F ":" '{print $1+$2+$3}'

# print a multiplication table
seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'

# Specify output separator character
printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'
27 changes: 27 additions & 0 deletions bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# To implement a for loop:
for file in *;
do
echo $file found;
done

# To implement a case command:
case "$1"
in
0) echo "zero found";;
1) echo "one found";;
2) echo "two found";;
3*) echo "something beginning with 3 found";;
esac

# Turn on debugging:
set -x

# Turn off debugging:
set +x

# Retrieve N-th piped command exit status
printf 'foo' | fgrep 'foo' | sed 's/foo/bar/'
echo ${PIPESTATUS[0]} # replace 0 with N

# Lock file:
( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file'
26 changes: 26 additions & 0 deletions bower
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Install a package locally
bower install <package-name>

# Install a package locally directly from github
bower install <user>/<repo>

# Install a specific package locally
bower install <package-name>#<version>

# Install a package locally and save installed package into bower.json
bower install <package-name> --save

# Retrieve info of a particular package
bower info <package-name>

# List local packages
bower list

# Search for a package by name
bower search <package-name>

# Update a package to their newest version
bower update <package-name>

# Remove a local package
bower uninstall <package-name>
Loading

0 comments on commit 04c0b99

Please sign in to comment.