mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 09:38:29 +02:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
2d7fdb5425 | |||
4512a61086 | |||
8096ca7f90 | |||
511c57f582 | |||
6ca4b6c8e7 | |||
9c696cc430 | |||
001fdb0eda | |||
af354ba6a3 | |||
196875a828 | |||
6cf69bc190 | |||
6b736083c3 | |||
b477df20b2 | |||
6304a65399 | |||
bc40ced2c1 | |||
74dfd51601 | |||
51b0b12663 | |||
ae45265317 | |||
97dd037538 | |||
402d15e8d8 |
@ -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.14')
|
||||
|
||||
# list directories
|
||||
if options['--directories']:
|
||||
|
5
cheat/cheatsheets/csplit
Normal file
5
cheat/cheatsheets/csplit
Normal 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/' '{*}'
|
@ -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
|
||||
|
@ -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
12
cheat/cheatsheets/ffmpeg
Normal 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
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
5
cheat/cheatsheets/man
Normal 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
2
cheat/cheatsheets/numfmt
Normal file
@ -0,0 +1,2 @@
|
||||
# Convert bytes to Human readable format
|
||||
numfmt --to=iec --suffix=B --padding=7 1048576
|
@ -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 -
|
||||
|
33
cheat/cheatsheets/vagrant
Normal file
33
cheat/cheatsheets/vagrant
Normal file
@ -0,0 +1,33 @@
|
||||
# Initate Vagrant
|
||||
mkdir vag-vm; cd vag-vm
|
||||
vagrant init
|
||||
|
||||
# Add a box to vagrant repo
|
||||
vagrant box add hashicorp/precise32
|
||||
|
||||
# Add a box Vagrant file
|
||||
config.vm.box = "hashicorp/precise32"
|
||||
|
||||
# Add vm to public network as host
|
||||
config.vm.network "public_network"
|
||||
|
||||
# Add provision script to vagrant file
|
||||
config.vm.provision :shell, path: "provision.sh"
|
||||
|
||||
# Start vm
|
||||
vagrant up
|
||||
|
||||
# Connect to started instance
|
||||
vagrant ssh
|
||||
|
||||
# Shutdown vm
|
||||
vagrant halt
|
||||
|
||||
# Hibernate vm
|
||||
vagrant suspend
|
||||
|
||||
# Set vm to initial state by cleaning all data
|
||||
vagrant destroy
|
||||
|
||||
# Restart vm with new provision script
|
||||
vagran reload --provision
|
Reference in New Issue
Block a user