From e8d32102cb3ce649f8062acef1ef86c2b9204497 Mon Sep 17 00:00:00 2001 From: "Francis T. O'Donovan" Date: Thu, 25 Aug 2016 20:31:13 -0400 Subject: [PATCH 01/29] Create MANIFEST.in I'm working on submitting this package to conda-forge. As part of this, I would like to include the license files in the MANIFEST.in for this project. --- MANIFEST.in | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b3192f1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include CHANGELOG +include CONTRIBUTING.md +include LICENSE +include README.md +include licenses/gpl-3.txt +include licenses/mit.txt From 5121fece91a8198d5bae72b5d0041945b0b16767 Mon Sep 17 00:00:00 2001 From: rahul Date: Sun, 28 Aug 2016 08:13:08 +0530 Subject: [PATCH 02/29] Add git stash cheat --- cheat/cheatsheets/git | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 2a814b0..01657fc 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -11,6 +11,24 @@ git config --global color.ui true # To stage all changes for commit: git add --all +# To stash changes locally, this will keep the changes in a separate changelist +# called stash and the working directory is cleaned. You can apply changes +# from the stash anytime +git stash + +# To stash changes with a message +git stash save "message" + +# To list all the stashed changes +git stash list + +# To apply the most recent change and remove the stash from the stash list +git stash pop + +# To apply any stash from the list of stashes. This does not remove the stash +# from the stash list +git stash apply stash@{6} + # To commit staged changes git commit -m "Your commit message" From 80d2a09456e7786e178a389da4b3520105158812 Mon Sep 17 00:00:00 2001 From: rahul Date: Sun, 28 Aug 2016 08:19:20 +0530 Subject: [PATCH 03/29] Add revert in git cheat --- cheat/cheatsheets/git | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 01657fc..5b809cb 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -142,3 +142,6 @@ git show :/cool # Undo parts of last commit in a specific file git checkout -p HEAD^ -- /path/to/file + +# Revert a commit and keep the history of the reverted change as a separate revert commit +git revert From 6a1742984c1ed47b1c5d0293a1fb8fa2c63150e5 Mon Sep 17 00:00:00 2001 From: rahul Date: Sun, 28 Aug 2016 08:24:02 +0530 Subject: [PATCH 04/29] Add cheery-pick to git cheat --- cheat/cheatsheets/git | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 5b809cb..56a8ab7 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -145,3 +145,7 @@ git checkout -p HEAD^ -- /path/to/file # Revert a commit and keep the history of the reverted change as a separate revert commit git revert + +# Pich a commit from a branch to current branch. This is different than merge as +# this just applies a single commit from a branch to current branch +git cherry-pick From 0a54b2a2ff3959d7df1b4de174bd4dd0e19eb4f8 Mon Sep 17 00:00:00 2001 From: Klaatu Date: Thu, 1 Sep 2016 12:10:21 +1200 Subject: [PATCH 05/29] updated emacs, ffmpeg. branched org-mode. added slack. --- cheat/cheatsheets/deb | 3 +++ cheat/cheatsheets/emacs | 29 +++--------------------- cheat/cheatsheets/ffmpeg | 10 ++++++++- cheat/cheatsheets/org-mode | 46 ++++++++++++++++++++++++++++++++++++++ cheat/cheatsheets/pkgtools | 27 ++++++++++++++++++++++ cheat/cheatsheets/rpm2cpio | 5 +++++ cheat/cheatsheets/sport | 32 ++++++++++++++++++++++++++ cheat/cheatsheets/trashy | 14 ++++++++++++ 8 files changed, 139 insertions(+), 27 deletions(-) create mode 100644 cheat/cheatsheets/deb create mode 100644 cheat/cheatsheets/org-mode create mode 100644 cheat/cheatsheets/pkgtools create mode 100644 cheat/cheatsheets/rpm2cpio create mode 100644 cheat/cheatsheets/sport create mode 100644 cheat/cheatsheets/trashy diff --git a/cheat/cheatsheets/deb b/cheat/cheatsheets/deb new file mode 100644 index 0000000..7e4c761 --- /dev/null +++ b/cheat/cheatsheets/deb @@ -0,0 +1,3 @@ +# Extract contents of a .deb file +$ ar vx foo.deb # -> data.tar.gz +$ tar xf data.tar.gz diff --git a/cheat/cheatsheets/emacs b/cheat/cheatsheets/emacs index 57b76e9..c33889f 100644 --- a/cheat/cheatsheets/emacs +++ b/cheat/cheatsheets/emacs @@ -3,7 +3,7 @@ Indent Select text then press TAB Cut CTRL-w Copy ALT-w - Paste CTRL-y + Paste ("yank") CTRL-y Search/Find CTRL-s Replace ALT-% (ALT-SHIFT-5) Save CTRL-x CTRL-s @@ -11,7 +11,7 @@ Undo CTRL-x u Highlight all text CTRL-x h Directory listing CTRL-x d - Cancel a command ESC ESC ESC + Cancel a command CTRL-g Font size bigger CTRL-x CTRL-+ Font size smaller CTRL-x CTRL-- @@ -30,7 +30,7 @@ # Other stuff - Open a shell ALT-x eshell + Open a shell ALT-x shell Goto a line number ALT-x goto-line Word wrap ALT-x toggle-word-wrap Spell checking ALT-x flyspell-mode @@ -39,32 +39,9 @@ Compile some code ALT-x compile List packages ALT-x package-list-packages -# Sudoing within eshell - - By default when using the sudo command within eshell you'll just - get "permission denied" messages. To overcome that type: - - alias sudo '*sudo $*' - # Line numbers To add line numbers and enable moving to a line with CTRL-l: (global-set-key "\C-l" 'goto-line) (add-hook 'find-file-hook (lambda () (linum-mode 1))) - -# Org-mode - - To begin org-mode ALT-x org-mode - Table column separator Vertical/pipe character - Reorganize table TAB - Section heading * - Open/collapse section TAB - Open/collapse All CTRL-TAB - Export in other file formats (eg HTML,PDF) CTRL-c CTRL-e - - To make org-mode automatically wrap lines: - - (add-hook 'org-mode-hook - '(lambda () - (visual-line-mode 1))) diff --git a/cheat/cheatsheets/ffmpeg b/cheat/cheatsheets/ffmpeg index 952c45b..2d8fec6 100644 --- a/cheat/cheatsheets/ffmpeg +++ b/cheat/cheatsheets/ffmpeg @@ -2,7 +2,14 @@ ffmpeg -i path/to/file.ext # Convert all m4a files to mp3 -for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 320k "${f%.m4a}.mp3"; done +for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -vn -b:a 320k "${f%.m4a}.mp3"; done + +# Convert video +# -g : GOP, for searchability +ffmpeg -i input.ext -vcodec vp9 -acodec libopus -b:v 21000k -b:a 320k -g 150 -threads 4 output.ext + +# Convert image sequence to video +ffmpeg -r 18 -pattern_type glob -i '*.png' -b:v 21000k -s hd1080 -vcodec vp9 -an -pix_fmt yuv420p -deinterlace output.ext # Listen to 10 seconds of audio from a video file # @@ -10,3 +17,4 @@ for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 320k "${f%.m4a}.mp3"; d # -t : seconds to cut # -autoexit : closes ffplay as soon as the audio finishes ffmpeg -ss 00:34:24.85 -t 10 -i path/to/file.mp4 -f mp3 pipe:play | ffplay -i pipe:play -autoexit + diff --git a/cheat/cheatsheets/org-mode b/cheat/cheatsheets/org-mode new file mode 100644 index 0000000..fe47540 --- /dev/null +++ b/cheat/cheatsheets/org-mode @@ -0,0 +1,46 @@ + Begin org-mode ALT-x org-mode + Save CTRL-x CTRL-s + Export in other file formats (eg HTML,PDF) CTRL-c CTRL-e + +# Outline + + Section heading * + New headline ALT-return + Move headline up or down ALT-up_arrow/down_arrow + Adjust indent depth of headline ALT-left_arrow/right_arrow + Open/collapse section TAB + Open/collapse All CTRL-TAB + +# To-Do Lists + + Mark list item as TODO ** TODO + Cycle through workflow SHIFT-left_arrow/right_arrow + Show only outstanding TODO items CTRL-c CTRL-v + +# Tables + + Table column separator Vertical/pipe character + Reorganize table TAB + Move column ALT-left_arrow/right_arrow + Move row ALT-up_arrow/down_arrow + +# Styles + + *bold* + /italic/ + _underlined_ + =code= + ~verbatim~ + +strike-through+ + +# Heading + + Header -*- mode: org -*- + +# .emacs + + To make org-mode automatically wrap lines: + + (add-hook 'org-mode-hook + '(lambda () + (visual-line-mode 1))) diff --git a/cheat/cheatsheets/pkgtools b/cheat/cheatsheets/pkgtools new file mode 100644 index 0000000..d130750 --- /dev/null +++ b/cheat/cheatsheets/pkgtools @@ -0,0 +1,27 @@ +# Create a Slackware package from a structured directory and sub-tree +$ cd /path/to/pkg/dir +$ su - c 'makepkg --linkadd y --chown n $foo-1.0.3-x86_64-1_tag.tgz' + + +# Install a Slackware package +installpkg foo-1.0.3-x86_64-1.tgz + +# Install a Slackware package to non-standard location +ROOT=/path/to/dir installpkg foo-1.0.4-noarch-1.tgz + +# Create backup of files that will be overwritten when installing +tar czvf /tmp/backup.tar.gz $(installpkg --warn foo-1.0.4-noarch-1.tgz) + + +# Upgrade a Slackware package including files only in new version +upgradepkg --install-new foo-1.0.6-noarch-1.tgz + +# Upgrade a Slackware package even if version is the same +upgradepkg --reinstall foo-1.0.4-noarch-1.tgz + + +# Remove a Slackware package +removepkg foo-0.2.8-x86_64-1 + +# Remove a Slackware package, retaining a backup (uninstalled) copy +removepkg -copy foo-0.2.8-x86_64-1 # -> /var/log/setup/tmp/preserved_packages/foo... \ No newline at end of file diff --git a/cheat/cheatsheets/rpm2cpio b/cheat/cheatsheets/rpm2cpio new file mode 100644 index 0000000..c1ec783 --- /dev/null +++ b/cheat/cheatsheets/rpm2cpio @@ -0,0 +1,5 @@ +# List contents of RPM +rpm2cpio foo.rpm | cpio -vt + +# Extract contents of RPM +rpm2cpio foo.rpm | cpio -vid \ No newline at end of file diff --git a/cheat/cheatsheets/sport b/cheat/cheatsheets/sport new file mode 100644 index 0000000..f3963cd --- /dev/null +++ b/cheat/cheatsheets/sport @@ -0,0 +1,32 @@ +# Sync to newest SlackBuild.org tree +sport r + +# Search (fuzzy) SlackBuild tree for packages foo and BaR +sport s foo bar + +# Operate from alternate build tree +SBOPATH=/path/to/tree sport s foo + +# View info and README of BaR (not fuzzy) +sport c foo BaR + +# Build a package +sport i --build-only foo + +# Build and install package foo and BaR +sport i foo BaR + +# Build and install package from current directory +sport i . + +# Upgrade instead of install +INSTALLER=upgradepkg sport i foo + +# Build dependency list for baz +echo "foo BaR" >> /tmp/baz.list + +# Install list of packages from file +sport i $(< /tmp/baz.list) + +# Check if package is installed +sport k foo diff --git a/cheat/cheatsheets/trashy b/cheat/cheatsheets/trashy new file mode 100644 index 0000000..edc6d2b --- /dev/null +++ b/cheat/cheatsheets/trashy @@ -0,0 +1,14 @@ +# Trash foo and bar +trash foo bar + +# Trash "foo bar" +trash foo\ bar + +# List files in trash +trash -v --list + +# Restore foo from trash +trash --restore foo + +# Empty trash +trash --empty From 76fa9cfc230ac8d7445209ebdcae369a63c0749b Mon Sep 17 00:00:00 2001 From: Klaatu Date: Thu, 1 Sep 2016 22:01:01 +1200 Subject: [PATCH 06/29] urpm* mageia open mandriva --- cheat/cheatsheets/urpm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cheat/cheatsheets/urpm diff --git a/cheat/cheatsheets/urpm b/cheat/cheatsheets/urpm new file mode 100644 index 0000000..3cb93f2 --- /dev/null +++ b/cheat/cheatsheets/urpm @@ -0,0 +1,14 @@ +# search (fuzzy) for package foo +urpmq -Y foo + +# check if foo is installed +rpm -q foo + +# install package foo +urpmi foo + +# download but don't install foo +urpmi --no-install foo + +# uninstall package foo +urpme foo From f1253031f28ff98e0618a4123efdf141d6a43161 Mon Sep 17 00:00:00 2001 From: Klaatu Date: Thu, 1 Sep 2016 22:28:28 +1200 Subject: [PATCH 07/29] bzip2 --- cheat/cheatsheets/bzip2 | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cheat/cheatsheets/bzip2 diff --git a/cheat/cheatsheets/bzip2 b/cheat/cheatsheets/bzip2 new file mode 100644 index 0000000..fe6935a --- /dev/null +++ b/cheat/cheatsheets/bzip2 @@ -0,0 +1,11 @@ +# compress foo -> foo.bz2 +bzip2 -z foo + +# decompress foo.bz2 -> foo +bzip2 -d foo.bz2 + +# compress foo to stdout +bzip2 -zc foo > foo.bz2 + +# decompress foo.bz2 to stdout +bzip2 -dc foo.bz2 From 2a6d34de3594db5b914b476e13259d3591275584 Mon Sep 17 00:00:00 2001 From: Klaatu Date: Fri, 2 Sep 2016 09:44:19 +1200 Subject: [PATCH 08/29] diff addition --- cheat/cheatsheets/diff | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/diff b/cheat/cheatsheets/diff index f9f2b3e..d8266e5 100644 --- a/cheat/cheatsheets/diff +++ b/cheat/cheatsheets/diff @@ -21,3 +21,6 @@ diff -s version1 version2 # To diff the output of two commands or scripts: diff <(command1) <(command2) + +# Generate a patch file from two files +diff -Naur version1 version2 > version.patch \ No newline at end of file From 32802c2907812226c6b88d7d8a48655242280e6a Mon Sep 17 00:00:00 2001 From: Klaatu Date: Sun, 4 Sep 2016 09:48:01 +1200 Subject: [PATCH 09/29] patch cheat --- cheat/cheatsheets/patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cheat/cheatsheets/patch diff --git a/cheat/cheatsheets/patch b/cheat/cheatsheets/patch new file mode 100644 index 0000000..a3485c6 --- /dev/null +++ b/cheat/cheatsheets/patch @@ -0,0 +1,13 @@ +# Patch one file +patch version1 < version.patch + +# Reverse a patch +patch -R version1 < version.patch + +# Patch all files in a directory, adding any missing new files +# -p strips leading slashes +$ cd dir +$ patch -p1 -i ../big.patch + +# Patch files in a directory, with one level (/) offset +patch -p1 -r version1/ < version.patch From 9a23458a2d0b879e96ede0b94beb4f8c547bed16 Mon Sep 17 00:00:00 2001 From: Klaatu Date: Fri, 9 Sep 2016 12:05:08 +1200 Subject: [PATCH 10/29] ffmpeg combine, add sqlite3 --- cheat/cheatsheets/ffmpeg | 7 +++++-- cheat/cheatsheets/sqlite3 | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 cheat/cheatsheets/sqlite3 diff --git a/cheat/cheatsheets/ffmpeg b/cheat/cheatsheets/ffmpeg index 2d8fec6..daa7a68 100644 --- a/cheat/cheatsheets/ffmpeg +++ b/cheat/cheatsheets/ffmpeg @@ -4,13 +4,16 @@ ffmpeg -i path/to/file.ext # Convert all m4a files to mp3 for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -vn -b:a 320k "${f%.m4a}.mp3"; done -# Convert video +# Convert video from .foo to .bar # -g : GOP, for searchability -ffmpeg -i input.ext -vcodec vp9 -acodec libopus -b:v 21000k -b:a 320k -g 150 -threads 4 output.ext +ffmpeg -i input.foo -vcodec bar -acodec baz -b:v 21000k -b:a 320k -g 150 -threads 4 output.bar # Convert image sequence to video ffmpeg -r 18 -pattern_type glob -i '*.png' -b:v 21000k -s hd1080 -vcodec vp9 -an -pix_fmt yuv420p -deinterlace output.ext +# Combine video and audio into one file +ffmpeg -i video.ext -i audio.ext -c:v copy -c:a copy output.ext + # Listen to 10 seconds of audio from a video file # # -ss : start time diff --git a/cheat/cheatsheets/sqlite3 b/cheat/cheatsheets/sqlite3 new file mode 100644 index 0000000..a3215b9 --- /dev/null +++ b/cheat/cheatsheets/sqlite3 @@ -0,0 +1,20 @@ +# create database and launch interactive shell +sqlite3 example.db + +# create table +sqlite3 example.db "CREATE TABLE Os(ID INTEGER PRIMARY KEY, Name TEXT, Year INTEGER);" + +# insert data +sqlite3 example.db "INSERT INTO 'Os' VALUES(1,'Linux',1991);" + +# list tables +sqlite3 example.db ".tables" + +# view records in table +sqlite3 example.db "SELECT * FROM 'Os';" + +# view records in table conditionally +sqlite example.db "SELECT * FROM 'Os' WHERE Year='1991';" + +# view records with fuzzy matching +sqlite3 ~/example.db "SELECT * FROM 'Os' WHERE Year like '19%';" \ No newline at end of file From d82eee726cb893f7ba6cc1b66d86c99579974af1 Mon Sep 17 00:00:00 2001 From: Morgan Courbet Date: Fri, 9 Sep 2016 10:05:22 +0200 Subject: [PATCH 11/29] Add npm cheatsheet --- cheat/cheatsheets/npm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cheat/cheatsheets/npm diff --git a/cheat/cheatsheets/npm b/cheat/cheatsheets/npm new file mode 100644 index 0000000..73c9b3d --- /dev/null +++ b/cheat/cheatsheets/npm @@ -0,0 +1,22 @@ +# Every command shown here can be used with the `-g` switch for global scope + +# Install a package in the current directory +npm install + +# Install a package, and save it in the `dependencies` section of `package.json` +npm install --save + +# Install a package, and save it in the `devDependencies` section of `package.json` +npm install --save-dev + +# Show outdated packages in the current directory +npm outdated + +# Update outdated packages +npm update + +# Update `npm` (will override the one shipped with Node.js) +npm install -g npm + +# Uninstall a package +npm unintall From 354376340feee31b0dc9f2fcc6b4ca2b79abd1da Mon Sep 17 00:00:00 2001 From: Klaatu Date: Sat, 10 Sep 2016 14:17:01 +1200 Subject: [PATCH 12/29] Missing man page #272 --- man1/cheat.1.gz | Bin 0 -> 975 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 man1/cheat.1.gz diff --git a/man1/cheat.1.gz b/man1/cheat.1.gz new file mode 100644 index 0000000000000000000000000000000000000000..65bc32f34dc82e05efacd90a976d58dc35c0da7f GIT binary patch literal 975 zcmV;=12Fs_iwFo_Y|~c&17m1qVRSAr0BuxVkK#5Ieb2ABLY2BJL0DR~4>vNH4*Jv+JAxUx$3nqacbT(9j%fj+MHEXY$A?<2U+W4zG zVr}YuN!}z#+tL}31z>jPCvm70kI-0e zWtP&DsY$W0x(#<>%F(VN$1L?eQeME^Hqb2q#$KcoO#fmjsbx#bT6cm1?>bpHSBHT?kS^ZMxhH*Xg)#9i z#QQ;SFvNQYp_3(M6{5*3v%X|qMJ;dIGcu>QG(wT1(Rn~6yJQLV(bWaw(A|7C-L9wG zdGE%-jdSVgxt+gQ&TBFYS7;5N5GMAvueJA8!B^qE%>`nvbC>}bVESA!paHY+tkcw{tf;RI- zSAUE#w?9x4S~C3x-X4>?(t^&ZQmknyG*jt) Date: Wed, 21 Sep 2016 22:24:47 +1200 Subject: [PATCH 13/29] xmlto cheatsheet --- cheat/cheatsheets/xmlto | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cheat/cheatsheets/xmlto diff --git a/cheat/cheatsheets/xmlto b/cheat/cheatsheets/xmlto new file mode 100644 index 0000000..6b087c0 --- /dev/null +++ b/cheat/cheatsheets/xmlto @@ -0,0 +1,15 @@ +# DocBook XML to PDF +xmlto pdf mydoc.xml + +# DocBook XML to HTML +xmlto -o html-dir html mydoc.xml + +# DocBook XML to single HTML file +xmlto html-nochunks mydoc.xml + +# modify output with XSL override +xmlto -m ulink.xsl pdf mydoc.xml + +# use non-default xsl +xmlto -x mystylesheet.xsl pdf mydoc.xml + From 809c6d77bc36d234af94822e8ce981a2e02d61b7 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Tue, 27 Sep 2016 21:23:39 +0530 Subject: [PATCH 14/29] Update lsof sheet --- cheat/cheatsheets/lsof | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cheat/cheatsheets/lsof b/cheat/cheatsheets/lsof index cc19485..5e54960 100644 --- a/cheat/cheatsheets/lsof +++ b/cheat/cheatsheets/lsof @@ -4,20 +4,34 @@ sudo lsof -i4 # List all IPv6 network files sudo lsof -i6 -# To find listening ports: +# To find listening ports lsof -Pnl +M -i4 -# To find which program is using the port 80: +# To list all open sockets +lsof -i + +# To find which program is using the port 80 lsof -i TCP:80 +# To show connections to a specific host +lsof -i@192.168.1.5 + # List all processes accessing a particular file/directory lsof # List all files open for a particular user lsof -u -# List all files/network connections a given process is using +# List all files/network connections a command is using lsof -c +# List all files a process has open +lsof -p + +# Lists all files open mounted at /mount/point. +# Particularly useful for finding which process(es) are using a +# mounted USB stick or CD/DVD. +lsof +f -- + # See this primer: http://www.danielmiessler.com/study/lsof/ # for a number of other useful lsof tips From cdf240b70e39e579a5daba1dc3c0593e54f76aea Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Tue, 27 Sep 2016 22:43:54 +0530 Subject: [PATCH 15/29] Fix grammar of lsof --- cheat/cheatsheets/lsof | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cheat/cheatsheets/lsof b/cheat/cheatsheets/lsof index 5e54960..8d11e3f 100644 --- a/cheat/cheatsheets/lsof +++ b/cheat/cheatsheets/lsof @@ -4,16 +4,16 @@ sudo lsof -i4 # List all IPv6 network files sudo lsof -i6 -# To find listening ports -lsof -Pnl +M -i4 - -# To list all open sockets +# List all open sockets lsof -i -# To find which program is using the port 80 +# List all listening ports +lsof -Pnl +M -i4 + +# Find which program is using the port 80 lsof -i TCP:80 -# To show connections to a specific host +# List all connections to a specific host lsof -i@192.168.1.5 # List all processes accessing a particular file/directory @@ -28,7 +28,7 @@ lsof -c # List all files a process has open lsof -p -# Lists all files open mounted at /mount/point. +# List all files open mounted at /mount/point. # Particularly useful for finding which process(es) are using a # mounted USB stick or CD/DVD. lsof +f -- From dab8645394134f72f170bfc65fdb91201a92de1f Mon Sep 17 00:00:00 2001 From: Jon LaBelle Date: Sun, 2 Oct 2016 16:23:42 -0500 Subject: [PATCH 16/29] Fix uninstall type. --- cheat/cheatsheets/npm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/npm b/cheat/cheatsheets/npm index 73c9b3d..ba85087 100644 --- a/cheat/cheatsheets/npm +++ b/cheat/cheatsheets/npm @@ -19,4 +19,4 @@ npm update npm install -g npm # Uninstall a package -npm unintall +npm uninstall From 034c1a24159ce290c562bc3b948995e5b7f5c710 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Sat, 15 Oct 2016 00:02:45 +0530 Subject: [PATCH 17/29] Add aria2c sheet --- cheat/cheatsheets/aria2c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cheat/cheatsheets/aria2c diff --git a/cheat/cheatsheets/aria2c b/cheat/cheatsheets/aria2c new file mode 100644 index 0000000..265e0b3 --- /dev/null +++ b/cheat/cheatsheets/aria2c @@ -0,0 +1,12 @@ +# Just download a file +# The url can be a http(s), ftp, .torrent file or even a magnet link +aria2c + +# To prevent downloading the .torrent file +aria2c --follow-torrent=mem + +# 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 From 05400a92ede5cd69546bd63bef07fbb14d9e523a Mon Sep 17 00:00:00 2001 From: Brutus Date: Thu, 24 Nov 2016 16:14:37 +0100 Subject: [PATCH 18/29] Added support for `~` and environment variables in `DEFAULT_CHEAT_DIR` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the `DEFAULT_CHEAT_DIR` environment variable contains the `~` — as shortcut for the users home directory — or environment variables like `$HOME`, the program bails. This change allows the usage of both. --- cheat/sheets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cheat/sheets.py b/cheat/sheets.py index 4e09143..1a0b28e 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -7,7 +7,8 @@ def default_path(): """ Returns the default cheatsheet path """ # determine the default cheatsheet dir - default_sheets_dir = os.environ.get('DEFAULT_CHEAT_DIR') or os.path.join(os.path.expanduser('~'), '.cheat') + default_sheets_dir = os.environ.get('DEFAULT_CHEAT_DIR') or os.path.join('~', '.cheat') + default_sheets_dir = os.path.expanduser(os.path.expandvars(default_sheets_dir)) # create the DEFAULT_CHEAT_DIR if it does not exist if not os.path.isdir(default_sheets_dir): From 597acec6ac042d3ab377b76fa5faac5438796014 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sat, 1 Oct 2016 13:55:50 -0400 Subject: [PATCH 19/29] `cheat` now honors `CHEAT_EDITOR` and `VISUAL` environment variables in addition to `EDITOR`. --- cheat/utils.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cheat/utils.py b/cheat/utils.py index cf9a787..98195ab 100644 --- a/cheat/utils.py +++ b/cheat/utils.py @@ -30,20 +30,21 @@ def die(message): def editor(): """ Determines the user's preferred editor """ - if 'EDITOR' not in os.environ: + + # determine which editor to use + editor = os.environ.get('CHEAT_EDITOR') \ + or os.environ.get('VISUAL') \ + or os.environ.get('EDITOR') \ + or False + + # assert that the editor is set + if editor == False: die( - 'In order to create/edit a cheatsheet you must set your EDITOR ' - 'environment variable to your editor\'s path.' + 'You must set a CHEAT_EDITOR, VISUAL, or EDITOR environment ' + 'variable in order to create/edit a cheatsheet.' ) - elif os.environ['EDITOR'] == "": - die( - 'Your EDITOR environment variable is set to an empty string. It must ' - 'be set to your editor\'s path.' - ) - - else: - return os.environ['EDITOR'] + return editor def warn(message): """ Prints a message to stderr """ From 8d65424ffb6a87fa052b6f9c412b0a51ac8d8290 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sat, 1 Oct 2016 14:08:58 -0400 Subject: [PATCH 20/29] README edit Modified the README with regards to the environment variable changes made in #294. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aedcfd8..5c476a4 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,8 @@ Cheatsheets are stored in the `~/.cheat/` directory, and are named on a per-keyphrase basis. In other words, the content for the `tar` cheatsheet lives in the `~/.cheat/tar` file. -Provided that you have an `EDITOR` environment variable set, you may edit -cheatsheets with: +Provided that you have a `CHEAT_EDITOR`, `VISUAL`, or `EDITOR` environment +variable set, you may edit cheatsheets with: ```sh cheat -e foo From 208dd24a0ccb7b66eb8a6e751617d2aac36ffa04 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 27 Nov 2016 10:31:49 -0500 Subject: [PATCH 21/29] Minor cheatsheet edits. --- cheat/cheatsheets/bzip2 | 2 +- cheat/cheatsheets/diff | 2 +- cheat/cheatsheets/emacs | 2 +- cheat/cheatsheets/org-mode | 22 +++++++++++----------- cheat/cheatsheets/xmlto | 1 - 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cheat/cheatsheets/bzip2 b/cheat/cheatsheets/bzip2 index fe6935a..4003a50 100644 --- a/cheat/cheatsheets/bzip2 +++ b/cheat/cheatsheets/bzip2 @@ -2,7 +2,7 @@ bzip2 -z foo # decompress foo.bz2 -> foo -bzip2 -d foo.bz2 +bzip2 -d foo.bz2 # compress foo to stdout bzip2 -zc foo > foo.bz2 diff --git a/cheat/cheatsheets/diff b/cheat/cheatsheets/diff index d8266e5..f998808 100644 --- a/cheat/cheatsheets/diff +++ b/cheat/cheatsheets/diff @@ -23,4 +23,4 @@ diff -s version1 version2 diff <(command1) <(command2) # Generate a patch file from two files -diff -Naur version1 version2 > version.patch \ No newline at end of file +diff -Naur version1 version2 > version.patch diff --git a/cheat/cheatsheets/emacs b/cheat/cheatsheets/emacs index c33889f..4201c0a 100644 --- a/cheat/cheatsheets/emacs +++ b/cheat/cheatsheets/emacs @@ -30,7 +30,7 @@ # Other stuff - Open a shell ALT-x shell + Open a shell ALT-x eshell Goto a line number ALT-x goto-line Word wrap ALT-x toggle-word-wrap Spell checking ALT-x flyspell-mode diff --git a/cheat/cheatsheets/org-mode b/cheat/cheatsheets/org-mode index fe47540..785cdb8 100644 --- a/cheat/cheatsheets/org-mode +++ b/cheat/cheatsheets/org-mode @@ -1,28 +1,28 @@ Begin org-mode ALT-x org-mode - Save CTRL-x CTRL-s + Save CTRL-x CTRL-s Export in other file formats (eg HTML,PDF) CTRL-c CTRL-e - + # Outline Section heading * - New headline ALT-return - Move headline up or down ALT-up_arrow/down_arrow - Adjust indent depth of headline ALT-left_arrow/right_arrow + New headline ALT-return + Move headline up or down ALT-up_arrow/down_arrow + Adjust indent depth of headline ALT-left_arrow/right_arrow Open/collapse section TAB Open/collapse All CTRL-TAB # To-Do Lists - Mark list item as TODO ** TODO - Cycle through workflow SHIFT-left_arrow/right_arrow - Show only outstanding TODO items CTRL-c CTRL-v + Mark list item as TODO ** TODO + Cycle through workflow SHIFT-left_arrow/right_arrow + Show only outstanding TODO items CTRL-c CTRL-v # Tables Table column separator Vertical/pipe character Reorganize table TAB - Move column ALT-left_arrow/right_arrow - Move row ALT-up_arrow/down_arrow + Move column ALT-left_arrow/right_arrow + Move row ALT-up_arrow/down_arrow # Styles @@ -35,7 +35,7 @@ # Heading - Header -*- mode: org -*- + Header -*- mode: org -*- # .emacs diff --git a/cheat/cheatsheets/xmlto b/cheat/cheatsheets/xmlto index 6b087c0..51a67f0 100644 --- a/cheat/cheatsheets/xmlto +++ b/cheat/cheatsheets/xmlto @@ -12,4 +12,3 @@ xmlto -m ulink.xsl pdf mydoc.xml # use non-default xsl xmlto -x mystylesheet.xsl pdf mydoc.xml - From a6ec02c2963735d5589c14124950fa34c502bd46 Mon Sep 17 00:00:00 2001 From: Romanos Skiadas Date: Wed, 12 Oct 2016 23:16:26 +0300 Subject: [PATCH 22/29] Support multi-word EDITOR values When the value of EDITOR was more than one words (e.g. emacsclient -c), it wasn't properly split in an array for subprocess.call and cheat would fail to launch it. This commit fixes that. Closes #301 --- cheat/sheet.py | 17 +++-------------- cheat/utils.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cheat/sheet.py b/cheat/sheet.py index 7f62405..ff1ce27 100644 --- a/cheat/sheet.py +++ b/cheat/sheet.py @@ -1,9 +1,8 @@ import os import shutil -import subprocess from cheat import sheets -from cheat.utils import die, editor +from cheat.utils import die, open_with_editor def copy(current_sheet_path, new_sheet_path): """ Copies a sheet to a new path """ @@ -39,22 +38,12 @@ def create_or_edit(sheet): def create(sheet): """ Creates a cheatsheet """ new_sheet_path = os.path.join(sheets.default_path(), sheet) - - try: - subprocess.call([editor(), new_sheet_path]) - - except OSError: - die('Could not launch ' + editor()) + open_with_editor(new_sheet_path) def edit(sheet): """ Opens a cheatsheet for editing """ - - try: - subprocess.call([editor(), path(sheet)]) - - except OSError: - die('Could not launch ' + editor()) + open_with_editor(path(sheet)) def exists(sheet): diff --git a/cheat/utils.py b/cheat/utils.py index 98195ab..58c27c4 100644 --- a/cheat/utils.py +++ b/cheat/utils.py @@ -1,6 +1,7 @@ from __future__ import print_function import os import sys +import subprocess def colorize(sheet_content): @@ -46,6 +47,16 @@ def editor(): return editor + +def open_with_editor(filepath): + """ Open `filepath` using the EDITOR specified by the environment variables """ + editor_cmd = editor().split() + try: + subprocess.call(editor_cmd + [filepath]) + except OSError: + die('Could not launch ' + editor()) + + def warn(message): """ Prints a message to stderr """ print((message), file=sys.stderr) From 8cad76943aec7f67a68521ad500a3f33f5733068 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 27 Nov 2016 11:10:05 -0500 Subject: [PATCH 23/29] v2.1.27 `patch` version bump. --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 19ad97d..5d5aec0 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.26') + options = docopt(__doc__, version='cheat 2.1.27') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index abd32c4..7587b27 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.26', + version = '2.1.27', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 1baa6d39c066ea3501c9f2a458ad20ebc545cc74 Mon Sep 17 00:00:00 2001 From: shanahanjrs Date: Sun, 1 Jan 2017 22:44:48 -0500 Subject: [PATCH 24/29] Added a cheatsheet for cheat itself --- cheat/cheatsheets/cheat | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cheat/cheatsheets/cheat diff --git a/cheat/cheatsheets/cheat b/cheat/cheatsheets/cheat new file mode 100644 index 0000000..0bfb78d --- /dev/null +++ b/cheat/cheatsheets/cheat @@ -0,0 +1,14 @@ +# To see example usage of a program: +cheat + +# To edit a cheatsheet +cheat -e + +# To list available cheatsheets +cheat -l + +# To search available cheatsheets +cheat -s + +# To get the current `cheat' version +cheat -v From 632da2024a458b75e9b3094e8a00a32d957cf0df Mon Sep 17 00:00:00 2001 From: shanahanjrs Date: Sun, 8 Jan 2017 17:11:51 -0500 Subject: [PATCH 25/29] Added cheatsheets for pushd and popd commands --- cheat/cheatsheets/popd | 2 ++ cheat/cheatsheets/pushd | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 cheat/cheatsheets/popd create mode 100644 cheat/cheatsheets/pushd diff --git a/cheat/cheatsheets/popd b/cheat/cheatsheets/popd new file mode 100644 index 0000000..a913b2f --- /dev/null +++ b/cheat/cheatsheets/popd @@ -0,0 +1,2 @@ +# Returns to the directory at the top of the `pushd' stack +popd diff --git a/cheat/cheatsheets/pushd b/cheat/cheatsheets/pushd new file mode 100644 index 0000000..5202960 --- /dev/null +++ b/cheat/cheatsheets/pushd @@ -0,0 +1,5 @@ +# Pushes your current directory to the top of a stack while changing to the specified directory +pushd + +# To return use popd +popd From 75b25557107d40e5d916376b42ee751dd0cc8ccd Mon Sep 17 00:00:00 2001 From: shanahanjrs Date: Wed, 25 Jan 2017 18:52:25 -0500 Subject: [PATCH 26/29] Fixed typo in 7z cheatsheet --- cheat/cheatsheets/7z | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/7z b/cheat/cheatsheets/7z index 86b55d5..26321c0 100644 --- a/cheat/cheatsheets/7z +++ b/cheat/cheatsheets/7z @@ -11,7 +11,7 @@ u update x extract with full paths Example: -7z a -t7z -m0-lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1 +7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1 -t7z 7z archive -m0=lzma lzma method From d06e5bab6f96d70f4d5201f0241aea5d50b656a6 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Thu, 16 Feb 2017 00:04:18 -0200 Subject: [PATCH 27/29] Add cheatsheet for hg Mercurial is extensively used as a version control system, as an option to Git, so I'm adding its cheatsheet. --- cheat/cheatsheets/hg | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cheat/cheatsheets/hg diff --git a/cheat/cheatsheets/hg b/cheat/cheatsheets/hg new file mode 100644 index 0000000..8cfbaf2 --- /dev/null +++ b/cheat/cheatsheets/hg @@ -0,0 +1,20 @@ +# Clone a directory +hg clone + +# Add files to hg tracker +hg add filename + +# Add all files in a folder to hg tracker +hg add folder/ + +# Create a commit with all tracked changes and a message +hg commit -m "message" + +# Push commits to source repository +hg push + +# Pull changes from source repository +hg pull + +# Rebase local commits to disambiguate with remote repository +hg pull --rebase From 10dd0e9a8b92dac792a7416ae1bc7196e7cf3cbb Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Thu, 16 Feb 2017 01:22:45 -0200 Subject: [PATCH 28/29] Add cheatsheet for shutdown Adding help for shutdown, useful for rebooting the system, --- cheat/cheatsheets/shutdown | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 cheat/cheatsheets/shutdown diff --git a/cheat/cheatsheets/shutdown b/cheat/cheatsheets/shutdown new file mode 100644 index 0000000..52e914e --- /dev/null +++ b/cheat/cheatsheets/shutdown @@ -0,0 +1,8 @@ +# Reboot the system immediately +shutdown -r now + +# Shut system down immediately +shutdown -h now + +# Reboot system after 5 minutes +shutdown -r +5 From f495a4dfd90d60504b395f3f687a68a706eefbf4 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Thu, 16 Feb 2017 01:25:24 -0200 Subject: [PATCH 29/29] Add cheatsheet for su Useful for running commands as another user. --- cheat/cheatsheets/su | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cheat/cheatsheets/su diff --git a/cheat/cheatsheets/su b/cheat/cheatsheets/su new file mode 100644 index 0000000..dec7bcc --- /dev/null +++ b/cheat/cheatsheets/su @@ -0,0 +1,2 @@ +# Switch to another user account +su USERNAME