Compare commits

...

17 Commits

Author SHA1 Message Date
8096ca7f90 Version bump
2.1.13
2015-08-06 21:15:26 -04:00
511c57f582 [DOCUMENTATION] Cmd 'ssh' copy files with gzipped on the fly 2015-08-06 14:46:21 +02:00
6ca4b6c8e7 [DOCUMENTATION] Cmd 'du' cumulative size cheat 2015-08-06 14:39:22 +02:00
9c696cc430 v2.1.12 2015-08-04 20:56:23 -04:00
001fdb0eda Merge branch 'sheets' of https://github.com/dufferzafar/chris-cheat into dufferzafar-sheets
* 'sheets' of https://github.com/dufferzafar/chris-cheat:
  New Sheet: ffmpeg - fast audio video encoder
  Git cheats: Shallow clones & Submodule update
  Git cheats: Change date of existing commit
2015-08-04 20:55:33 -04:00
af354ba6a3 New Sheet: ffmpeg - fast audio video encoder 2015-08-03 17:51:52 +05:30
196875a828 Git cheats: Shallow clones & Submodule update 2015-08-03 17:50:23 +05:30
6cf69bc190 Git cheats: Change date of existing commit 2015-08-03 17:50:12 +05:30
6b736083c3 v2.1.11
- Merged PR #227

- Patch version bump
2015-07-31 15:19:22 -04:00
b477df20b2 New Sheet: man - an interface to reference manuals 2015-07-24 18:54:41 +05:30
6304a65399 New Sheet: numfmt - convert numbers from/to human-readable strings 2015-07-24 18:53:50 +05:30
bc40ced2c1 New Sheet: csplit - used to split a file into parts 2015-07-24 18:51:55 +05:30
74dfd51601 Version bump 2015-07-09 18:42:00 -04:00
51b0b12663 Minor addition to git cheatsheet 2015-07-09 18:41:00 -04:00
ae45265317 Two new cheats in date and ln sheets 2015-06-19 23:18:59 +05:30
97dd037538 Fixup grammar in grep cheatsheet 2015-06-19 23:18:27 +05:30
402d15e8d8 More git cheats 2015-06-19 23:11:48 +05:30
12 changed files with 93 additions and 9 deletions

View File

@ -38,7 +38,7 @@ from docopt import docopt
if __name__ == '__main__':
# parse the command-line options
options = docopt(__doc__, version='cheat 2.1.9')
options = docopt(__doc__, version='cheat 2.1.13')
# list directories
if options['--directories']:

5
cheat/cheatsheets/csplit Normal file
View File

@ -0,0 +1,5 @@
# Split a file based on pattern
csplit input.file '/PATTERN/'
# Use prefix/suffix to improve resulting file names
csplit -f 'prefix-' -b '%d.extension' input.file '/PATTERN/' '{*}'

View File

@ -1,2 +1,5 @@
# Printout date in format suitable for affixing to file names
# Print date in format suitable for affixing to file names
date +"%Y%m%d_%H%M%S"
# Convert Unix timestamp to Date
date -d @1440359821

View File

@ -1,2 +1,5 @@
# To sort directories/files by size
du -sk *| sort -rn
# To show cumulative humanreadable size
du -sh

12
cheat/cheatsheets/ffmpeg Normal file
View File

@ -0,0 +1,12 @@
# Print file metadata etc.
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
# Listen to 10 seconds of audio from a video file
#
# -ss : start time
# -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

View File

@ -1,4 +1,4 @@
# To set your identify:
# To set your identity:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
@ -17,9 +17,25 @@ git commit -m "Your commit message"
# To edit previous commit message
git commit --amend
# Git commit in the past
git commit --date="`date --date='2 day ago'`"
git commit --date="Jun 13 18:30:25 IST 2015"
# more recent versions of Git also support --date="2 days ago" directly
# To change the date of an existing commit
git filter-branch --env-filter \
'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
then
export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
fi'
# To removed staged and working directory changes
git reset --hard
# To go 2 commits back
git reset --hard HEAD~2
# To remove untracked files
git clean -f -d
@ -35,6 +51,9 @@ git push git@github.com:username/project.git
# To delete the branch "branch_name"
git branch -D branch_name
# To make an exisiting branch track a remote branch
git branch -u upstream/foo
# To see who commited which line in a file
git blame filename
@ -57,3 +76,31 @@ git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py >
# Import commits from another repo
git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
# View commits that will be pushed
git log @{u}..
# View changes that are new on a feature branch
git log -p feature --not master
git diff master...feature
# Interactive rebase for the last 7 commits
git rebase -i @~7
# Diff files WITHOUT considering them a part of git
# This can be used to diff files that are not in a git repo!
git diff --no-index path/to/file/A path/to/file/B
# To pull changes while overwriting any local commits
git fetch --all
git reset --hard origin/master
# Update all your submodules
git submodule update --init --recursive
# Perform a shallow clone to only get latest commits
# (helps save data when cloning large repos)
git clone --depth 1 <remote-url>
# To unshallow a clone
git pull --unshallow

View File

@ -1,13 +1,13 @@
# Basic:
# Search a file for a pattern
grep pattern file
# case nonsensitive research:
grep -i pattern file
# Case insensitive search (with line numbers)
grep -in pattern file
# Recursively grep for string <pattern> in folder:
grep -R pattern folder
# Getting pattern from file (one by line):
# Read search patterns from a file (one per line)
grep -f pattern_file file
# Find lines NOT containing pattern
@ -17,7 +17,7 @@ grep -v pattern file
grep "^00" file #Match lines starting with 00
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file #Find IP add
# Find all files who contain {pattern} in the directory {directory}.
# Find all files which match {pattern} in {directory}
# This will show: "file:line my research"
grep -rnw 'directory' -e "pattern"

View File

@ -1,2 +1,5 @@
# To create a symlink:
ln -s path/to/the/target/directory name-of-symlink
# Symlink, while overwriting existing destination files
ln -sf /some/dir/exec /usr/bin/exec

5
cheat/cheatsheets/man Normal file
View File

@ -0,0 +1,5 @@
# Convert a man page to pdf
man -t bash | ps2pdf - bash.pdf
# View the ascii chart
man 7 ascii

2
cheat/cheatsheets/numfmt Normal file
View File

@ -0,0 +1,2 @@
# Convert bytes to Human readable format
numfmt --to=iec --suffix=B --padding=7 1048576

View File

@ -28,3 +28,7 @@ ssh user@example.com -C -c blowfish -X
# For more information, see:
# http://unix.stackexchange.com/q/12755/44856
# Copy files and folders through ssh from remote host to pwd with tar.gz compression
# when there is no rsync command available
ssh user@example.com "cd /var/www/Shared/; tar zcf - asset1 asset2" | tar zxf -

View File

@ -3,7 +3,7 @@ import os
setup(
name = 'cheat',
version = '2.1.9',
version = '2.1.13',
author = 'Chris Lane',
author_email = 'chris@chris-allen-lane.com',
license = 'GPL3',