Compare commits

...

9 Commits

Author SHA1 Message Date
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
9 changed files with 56 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.11')
# 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,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,17 @@ 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 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 +43,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 +68,21 @@ 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

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

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