Last active
August 6, 2020 13:27
-
-
Save Alhadis/593260567938e41ab063b83435d3090a to your computer and use it in GitHub Desktop.
Self-reminders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tell a program to completely shut the fuck up | |
(npm install get-options) >/dev/null 2>&1 | |
# Repeat a character a certain number of times | |
printf %100s | tr ' ' '=' | |
# Hide/show files or directories in Finder | |
chflags hidden /path/to | |
chflags nohidden /path/to | |
# Print a progress bar | |
printf %s"\r" "####-----(33%)" | |
# Compare lines of two different files | |
comm $FILE1 $FILE2 | |
# Delete empty lines | |
sed '/^\s*$/d' file.txt | |
sed -n $'/[^ \t]/,$p' # Empty lines at start-of-file only | |
sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' # Empty lines at end-of-file only | |
# Recursively delete shit | |
find /path/to/dir -name "*.DS_Store" -type f -delete # Delete files | |
find /path/to/dir -name "*.git" -type d -delete # Delete directories | |
# Recursively execute something on shit | |
find /path/to/thing -type d -exec sudo chmod 2775 {} + | |
# Retrieve modification time in Epoch/“Unix Timestamp” format | |
stat -f %m $FILE | |
# Retrieve timestamp in English | |
stat -f '%Sm -> %N' | |
# Get permission bits of file/directory in octal format | |
gstat -c %a # Darwin/macOS | |
stat -c %a # Linux | |
# Restore git repo to last committed state, verbatim | |
git reset --hard HEAD; git clean -fd | |
# Undo last commit (as long as it's not been pushed) | |
git reset --soft HEAD~1 | |
# Compress folder without .DS_Store junk | |
zip -r archive.zip directory/path/ -x "*.DS_Store" | |
# Remove suffix from multiple filenames | |
for i in *; do mv $i $(echo $i | sed -E 's/_[SMLH]\.(jpe?g|png)$/.\1/g'); done | |
# Echo to STDERR | |
>&2 echo 'ERROR: Message.'; | |
# Shell file loop | |
for i in $@; do; done; | |
# Less often used | |
# =============== | |
# Extract tarball on OpenBSD | |
# http://www.linuxmisc.com/27-openbsd/e954bddfdade667e.htm | |
tar xvfz filename.tar.gz | |
# Upgrade NodeJS Package Manager (NPM) | |
npm install -g npm@latest | |
# Reset permissions on files for WordPress on AWS | |
find . -type d -exec sudo chmod 2775 {} + | |
# Pull contents of a subdirectory into current directory | |
for i in wordpress/*; do mv "$i" $(basename "$i"); done; | |
# Restart Apache (after changing vhosts file) | |
sudo apachectl -k graceful | |
# Trash stupid local commits and revert repo state from remote | |
git reset --hard origin/master | |
# Fix an incorrect commit message | |
git commit --amend # Yes, that’s really all | |
# Show what file modifications are staged in Git | |
git diff --cached # Yep, that’s really all, too. | |
# Squash-merge a topic branch into master | |
git merge --squash branch-name | |
# Show all hidden files | |
defaults write com.apple.finder AppleShowAllFiles 1 | |
killall Finder | |
# Enable local file access in Chrome | |
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files | |
# Disable “Opening Downloaded File” warning in macOS | |
defaults write com.apple.LaunchServices LSQuarantine -bool NO | |
# Reset position of window in macOS | |
osascript -e 'tell application "System Events" to tell process "FileZilla" | |
set position of windows to {0, 0} | |
end'; | |
# Reset size of window in macOS | |
osascript -e 'tell first window of application "Google Chrome" to set bounds to {0, 0, 1440, 820}' | |
# Rsync example | |
rsync -e "ssh -i $HOME/.ssh/khq.pem" -rt ./tim-test/ ec2-user@khqapproved.com.au:/var/www/html/tim-test | |
# Remove com.apple.quarantine attribute recursively | |
find . -print0 -type f -o -type d | xargs -0 xattr -d com.apple.quarantine | |
# Create and mount a case-sensitive filesystem on macOS | |
hdiutil create -size 1g -fs 'Case-sensitive APFS' -type UDIF -nospotlight -attach | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Data::Dumper; | |
print Dumper($data); | |
\K - Keep out # Lowercase \k is \k<group> | |
# ARGV | |
for (@ARGV) { | |
} | |
$first_arg = $ARGV[0]; | |
# Functions | |
sub name { | |
@_ # Arguments. Mnemonic: "@rgs" | |
$_[0] # First argument | |
} | |
# for-loop | |
for my $value ("a", "b", "c") { | |
say $value; | |
} | |
# Heredoc | |
print <<"EOF"; | |
sdgdsgsdg | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mirror locally | |
rsync -avzH --inplace --delete \ | |
rsync://mirror.internode.on.net/openbsd/6.7/amd64 6.7 | |
# Sorted option-summary | |
-@, --modify-window NUM # Set the accuracy for mod-time comparisons | |
-0, --from0 # All *-from/filter files are delimited by 0s | |
-4, --ipv4 # Prefer IPv4 | |
-6, --ipv6 # Prefer IPv6 | |
-8, --8-bit-output # Leave high-bit chars unescaped in output | |
-A, --acls # Preserve ACLs (implies --perms) | |
-a, --archive # Archive mode; equals -rlptgoD (no -H,-A,-X) | |
--address ADDRESS # Bind to the specified address | |
--append # Append data onto shorter files | |
--append-verify # --append w/old data in file checksum | |
-b, --backup # Make backups (see --suffix & --backup-dir) | |
-B, --block-size SIZE # Force a fixed checksum block-size | |
--backup-dir DIR # Make backups into hierarchy based in DIR | |
--blocking-io # Use blocking I/O for the remote shell | |
--bwlimit RATE # Limit socket I/O bandwidth | |
-c, --checksum # Skip based on checksum, not mod-time & size | |
-C, --cvs-exclude # Auto-ignore files in the same way CVS does | |
--checksum-choice STR # Choose the checksum algorithm (aka --cc) | |
--checksum-seed NUM # Set block/file checksum seed (advanced) | |
--chmod CHMOD # Affect file and/or directory permissions | |
--chown USER:GROUP # Simple username/groupname mapping | |
--compare-dest DIR # Also compare destination files relative to DIR | |
--compress-choice STR # Choose the compression algorithm (aka --zc) | |
--compress-level NUM # Explicitly set compression level (aka --zl) | |
--config FILE # Specify alternate rsyncd.conf file | |
--contimeout SECONDS # Set daemon connection timeout in seconds | |
--copy-as USER[:GROUP] # Specify user & optional group for the copy | |
--copy-dest DIR # ... and include copies of unchanged files | |
--copy-unsafe-links # Only "unsafe" symlinks are transformed | |
-D # Same as --devices --specials | |
-d, --dirs # Transfer directories without recursing | |
--daemon # Run as an rsync daemon | |
--debug FLAGS # Fine-grained debug verbosity | |
--del # An alias for --delete-during | |
--delay-updates # Put all updated files into place at end | |
--delete # Delete extraneous files from dest dirs | |
--delete-after # Receiver deletes after transfer, not during | |
--delete-before # Receiver deletes before xfer, not during | |
--delete-delay # Find deletions during, delete after | |
--delete-during # Receiver deletes during the transfer | |
--delete-excluded # Also delete excluded files from dest dirs | |
--delete-missing-args # Delete missing source args from destination | |
--devices # Preserve device files (super-user only) | |
-E, --executability # Preserve executability | |
-e, --rsh COMMAND # Specify the remote shell to use | |
--early-input FILE # Use FILE for daemon's early exec input | |
--exclude PATTERN # Exclude files matching PATTERN | |
--exclude-from FILE # Read exclude patterns from FILE | |
--existing # Skip creating new files on receiver | |
-F # Same as --filter='dir-merge /.rsync-filter', repeated: --filter='- .rsync-filter' | |
-f, --filter RULE # Add a file-filtering RULE | |
--fake-super # Store/recover privileged attrs using xattrs | |
--fileflags # Preserve file-flags (aka chflags) | |
--files-from FILE # Read list of source-file names from FILE | |
--force-change # Affect user-/system-immutable files/dirs | |
--force-delete # Force deletion of directories even if not empty | |
--force-schange # Affect system-immutable files/dirs | |
--force-uchange # Affect user-immutable files/dirs | |
-g, --group # Preserve group | |
--groupmap STRING # Custom groupname mapping | |
-H, --hard-links # Preserve hard links | |
-h, --help (*) # Show this help (* -h is help only on its own) | |
-h, --human-readable # Output numbers in a human-readable format | |
-i, --itemize-changes # Output a change-summary for all updates | |
--iconv CONVERT_SPEC # Request charset conversion of filenames | |
--ignore-errors # Delete even if there are I/O errors | |
--ignore-existing # Skip updating files that exist on receiver | |
--ignore-missing-args # Ignore missing source args without error | |
--ignore-times, -I # Don't skip files that match size and time | |
--include PATTERN # Don't exclude files matching PATTERN | |
--include-from FILE # Read include patterns from FILE | |
--info FLAGS # Fine-grained informational verbosity | |
--inplace # Update destination files in-place | |
-J, --omit-link-times # Omit symlinks from --times | |
-k, --copy-dirlinks # Transform symlink to dir into referent dir | |
-K, --keep-dirlinks # Treat symlinked dir on receiver as dir | |
-L, --copy-links # Transform symlink into referent file/dir | |
-l, --links # Copy symlinks as symlinks | |
--link-dest DIR # Hardlink to files in DIR when unchanged | |
--list-only # List the files instead of copying them | |
--log-file FILE # Override the "log file" setting | |
--log-file-format FMT # Log updates using the specified FMT | |
-M, --dparam OVERRIDE # Override global daemon config parameter | |
-m, --prune-empty-dirs # Prune empty directory chains from file-list | |
-M, --remote-option OPT # Send OPTION to the remote side only | |
--max-alloc SIZE # Change a limit relating to memory alloc | |
--max-delete NUM # Don't delete more than NUM files | |
--max-size SIZE # Don't transfer any file larger than SIZE | |
--min-size SIZE # Don't transfer any file smaller than SIZE | |
--msgs2stderr # Output messages directly to stderr | |
--munge-links # Munge symlinks to make them safe & unusable | |
-N, --crtimes # Preserve create times (newness) | |
-n, --dry-run # Perform a trial run with no changes made | |
--no-detach # Do not detach from the parent | |
--no-implied-dirs # Don't send implied dirs with --relative | |
--no-motd # Suppress daemon-mode MOTD | |
--no-OPTION # Turn off an implied OPTION (e.g. --no-D) | |
--numeric-ids # Don't map uid/gid values by user/group name | |
-O, --omit-dir-times # Omit directories from --times | |
-o, --owner # Preserve owner (super-user only) | |
--only-write-batch FILE # Like --write-batch but w/o updating dest | |
--open-noatime # Avoid changing the atime on opened files | |
--out-format FORMAT # Output updates using the specified FORMAT | |
--outbuf N|L|B # Set out buffering to None, Line, or Block | |
-P # Same as --partial --progress | |
-p, --perms # Preserve permissions | |
--partial # Keep partially transferred files | |
--partial-dir DIR # Put a partially transferred file into DIR | |
--password-file FILE # Read daemon-access password from FILE | |
--port PORT # Specify double-colon alternate port number | |
--preallocate # Allocate dest files before writing them | |
--progress # Show progress during transfer | |
--protocol NUM # Force an older protocol version to be used | |
-q, --quiet # Suppress non-error messages | |
-r, --recursive # Recurse into directories | |
-R, --relative # Use relative path names | |
--read-batch FILE # Read a batched update from FILE | |
--remove-source-files # Sender removes synchronized files (non-dir) | |
--rsync-path PROGRAM # Specify the rsync to run on remote machine | |
-s, --protect-args # No space-splitting; wildcard chars only | |
-S, --sparse # Turn sequences of nulls into sparse blocks | |
--safe-links # Ignore symlinks that point outside the tree | |
--size-only # Skip files that match in size | |
--skip-compress LIST # Skip compressing files with suffix in LIST | |
--sockopts OPTIONS # Specify custom TCP options | |
--specials # Preserve special files | |
--stats # Give some file-transfer stats | |
--suffix SUFFIX # Backup suffix (default ~ w/o --backup-dir) | |
--super # Receiver attempts super-user activities | |
-T, --temp-dir DIR # Create temporary files in directory DIR | |
-t, --times # Preserve modification times | |
--timeout SECONDS # Set I/O timeout in seconds | |
-U, --atimes # Preserve access (use) times | |
-u, --update # Skip files that are newer on the receiver | |
--usermap STRING # Custom username mapping | |
-v, --verbose # Increase verbosity | |
-V, --version # Print the version + other info and exit | |
-W, --whole-file # Copy files whole (w/o delta-xfer algorithm) | |
--write-batch FILE # Write a batched update to FILE | |
--write-devices # Write to devices as files (implies --inplace) | |
-x, --one-file-system # Don't cross filesystem boundaries | |
-X, --xattrs # Preserve extended attributes | |
-y, --fuzzy # Find similar file for basis if no dest file | |
-z, --compress # Compress file data during the transfer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
″ inches | |
× °… ﹤﹥ | |
Line separator / U+2028 | |
✗ ✓█ | |
⸻ | |
‾ | |
꞉ “” ‘ ’ A ∕ B ⁇ ⁈ ․ … | |
[ㅤ] Hangul filler (between braces) | |
€ (or ALT + SHIFT + 2) | |
↑↓←→⋮♥≡≢ λ ⇒ ⇐ ⇑ ⇓ | |
😂👌 | |
™ : Typed by holding opt+2 | |
^ Control | |
⌥ Option | |
⌘ Command | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment