Last active
May 6, 2024 05:35
-
-
Save cdwilson/899029 to your computer and use it in GitHub Desktop.
Helpful commands
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
# Find "text" in some /path/to/search | |
find /path/to/search -type f -print0 | xargs -0 grep -l "text" | |
# Restore the deleted files in a git repository | |
git ls-files -d | xargs git checkout -- | |
# Move all files in a directory including .files | |
# http://superuser.com/questions/62141/linux-how-to-move-all-files-from-current-directory-to-upper-directory | |
(shopt -s dotglob; mv -- * /path/to/destination) | |
# Calculate checksum for EEPROM bin file | |
# same as checksum-16 on HxD in Windows | |
cksum -o 2 filename.bin | awk '{ print $1 }' | xargs printf "%x\n" | |
# tell git to prune loose objects now | |
# http://www.kernel.org/pub/software/scm/git/docs/git-gc.html | |
git gc --prune=now | |
# reconfigure shell in ubuntu (i.e. change from dash to bash) | |
sudo dpkg-reconfigure dash | |
# How to use > in an xargs command | |
# http://stackoverflow.com/questions/845863/how-to-use-in-an-xargs-command | |
# find tag on commit | |
git describe --tags --exact-match | |
# find ubuntu version | |
cat /etc/issue | |
# override shell variables | |
$ cat override.sh | |
#!/bin/bash | |
: ${var1:=foo} # var1 will take on the value "foo" if not overridden | |
var2=${var2:-foo} # same thing but more typing | |
echo "var1 is $var1 | var2 is $var2" | |
# push an existing repo to github | |
# http://help.github.com/move-a-repo/ | |
git clone --bare url/for/my-old-repo.git | |
cd my-old-repo.git | |
git push --mirror git@github.com:mycompany/my-new-repo.git | |
cd .. | |
rm -rf my-old-repo.git | |
# then checkout the old repo | |
git clone url/for/my-old-repo.git | |
# and add github as a remote | |
git remote add github git@github.com:mycompany/my-new-repo.git | |
# checkout a branch | |
git checkout -b branch origin/branch | |
# make changes and then push to github | |
git push github branch | |
# delete tags on remote | |
git tag -d 12345 | |
git push origin :refs/tags/12345 | |
# change remote url | |
git remote set-url origin ssh://remote@host:port/repo.git | |
# set var from command output in batch script | |
for /f [options] %%a in ('CMD') do @set var=%%a | |
# bazar colordiff | |
bzr cdiff | less -r | |
# show Ubuntu version | |
cat /etc/issue | |
# diff binary files | |
vbindiff file1 file2 | |
# SHA-1 digest | |
openssl sha1 file | |
# create a PKZip archive similarly to the Finder's Compress functionality | |
# http://stackoverflow.com/questions/107903/how-to-create-a-zip-file-in-the-same-format-as-the-finders-compress-menu-item | |
ditto -c -k --rsrc --sequesterRsrc --keepParent src_directory archive.zip | |
# apply a Macports patch file | |
patch -p0 < ~/Downloads/Portfile-postfix.diff | |
# clear out apt-get cached lists | |
sudo rm -rf /var/lib/apt/lists/ | |
# time machine diagnostic utility for bug reports to apple | |
sudo tmdiagnose | |
# print $PATH on separate lines | |
echo "$PATH" | tr ':' '\n' | |
# shutdown ESXi host | |
/sbin/shutdown.sh && /sbin/poweroff | |
# check maintenance mode | |
vim-cmd hostsvc/hostsummary | grep -i maintenance | |
# put ESXi host into maintenance mode | |
vim-cmd hostsvc/maintenance_mode_enter | |
# exit maintenance mode | |
vim-cmd /hostsvc/maintenance_mode_enter | |
# squash branch onto current branch but don't commit | |
git merge --squash branch | |
# rebase on branch but resolving all merge conflicts by selecting the changes in branch over the ones in the current branch | |
git rebase -s recursive -X theirs branch | |
# create pdf from markdown | |
pandoc --latex-engine=xelatex --variable mainfont="Lucida Grande" --variable sansfont="Lucida Grande" --variable monofont="Menlo" -o Welcome.pdf Welcome.text | |
# exclude ports from "port upgrade outdated" | |
sudo port upgrade outdated and not gcc45* | |
# amend commit author | |
git commit --amend --reset-author | |
# list non-apple kernel extensions | |
kextstat | grep -v com.apple | |
system_profiler SPUSBDataType | grep -C 7 FTDI | |
# flash drive mark partition active on OSX before using unetbootin | |
fdisk -e /dev/rdisk1 | |
f 1 | |
write | |
exit | |
# git print short rev for ref | |
git rev-parse --short <ref> | |
# eject disk mac | |
drutil tray eject | |
# copy a disk image to a physical disk with progress status output | |
diskutil list | |
diskutil unmountDisk /dev/diskX | |
pv -pterb source.img | sudo dd of=/dev/diskX bs=1m | |
# recursively remove .DS_Store files | |
find . -name '.DS_Store' -type f -delete | |
# delete Time Machine backups without "Operation not permitted" errors | |
sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass rm -rf /Volumes/Time\ Machine/Backups.backupdb/<backup> | |
# Fix permissions to what git thinks they should be | |
# https://stackoverflow.com/questions/2517339/how-to-recover-the-file-permissions-to-what-git-thinks-the-file-should-be | |
git diff -p -R --no-color \ | |
| grep -E "^(diff|(old|new) mode)" --color=never \ | |
| git apply | |
# connect to a serial --> IP server | |
# https://stackoverflow.com/questions/26373006/using-socat-for-raw-serial-connection | |
stty raw ; socat -,escape=0x03 tcp:172.27.164.198:1001,nonblock ; stty sane | |
# Show Time Machine log messages | |
log show --predicate 'subsystem == "com.apple.TimeMachine"' --last 4h | |
# Delete Time Machine local snapshots | |
tmutil listlocalsnapshots / | |
sudo tmutil deletelocalsnapshots 2018-03-01-002010 | |
# Get VSCode to play nice with pyenv installed via anyenv | |
# https://github.com/Microsoft/vscode-python/issues/3066 | |
# Add the following to $HOME/Library/Application Support/Code/User/settings.json | |
# "python.terminal.activateEnvironment": false | |
# Disable two finger swipe to go back in Chrome on MacOS | |
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE | |
xattr -r -d com.apple.quarantine /Applications/KiCad | |
/usr/bin/chflags nohidden ~/Library | |
xattr -d com.apple.FinderInfo ~/Library | |
defaults write com.apple.Finder AppleShowAllFiles true | |
killall Finder | |
#open-vm-tools | |
# https://gist.github.com/darrenpmeyer/b69242a45197901f17bfe06e78f4dee3 | |
# add to /etc/fstab | |
.host:/ /mnt/hgfs fuse.vmhgfs-fuse auto,allow_other 0 0 | |
# remove CR from line endings in a git repo | |
find . -type f -not -path '*/\.git/*' -print0 | xargs -0 dos2unix | |
# disable Google Chrome swipe navigate with scrolls | |
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE | |
# run this when sign out of iCloud is not working | |
defaults delete MobileMeAccounts | |
# don't write .DS_Store to SMB shares | |
# https://support.apple.com/en-us/HT208209 | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE | |
# Warning: A newer Command Line Tools release is available. | |
# Update them from Software Update in System Preferences or run: | |
softwareupdate --all --install --force | |
# If that doesn't show you an update run: | |
sudo rm -rf /Library/Developer/CommandLineTools | |
sudo xcode-select --install | |
# Alternatively, manually download them from: | |
# https://developer.apple.com/download/more/. | |
# checkout a github PR locally | |
git fetch origin pull/ID/head:BRANCHNAME | |
git checkout BRANCHNAME | |
# install python with updated tkinter | |
# https://medium.com/@xogk39/install-tkinter-on-mac-pyenv-f112bd3f4663 | |
brew install tcl-tk | |
pyenv uninstall 3.9.1 | |
env \ | |
PATH="$(brew --prefix tcl-tk)/bin:$PATH" \ | |
LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \ | |
CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \ | |
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \ | |
CFLAGS="-I$(brew --prefix tcl-tk)/include" \ | |
PYTHON_CONFIGURE_OPTS="--enable-framework --with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \ | |
pyenv install 3.9.1 | |
import tkinter | |
tkinter.TclVersion, tkinter.TkVersion | |
tkinter._test() | |
# install python 2.7.18 with updated tkinter | |
CPPFLAGS="-I$(brew --prefix tcl-tk)/include/tcl-tk" \ | |
LDFLAGS="-L$(brew --prefix tcl-tk)/lib -ltk8.6 -ltkstub8.6 -ltcl8.6 -ltclstub8.6" \ | |
pyenv install 2.7.18 | |
# disable Chrome invalid certificate check for localhost | |
chrome://flags/#allow-insecure-localhost | |
# print kicad plugin path | |
import pcbnew | |
print pcbnew.PLUGIN_DIRECTORIES_SEARCH | |
# sign off previous commit | |
git commit --amend --signoff | |
# install python 3.8.2 on Monterey | |
pyenv install 3.8.2 --patch < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch) | |
# uninstall all packages installed by pip | |
pip uninstall -y -r <(pip freeze) | |
# compile all python files in a directory | |
python -m compileall . | |
# view non-printable characters | |
# https://www.soscisurvey.de/tools/view-chars.php | |
# fix git submodules gon crazy | |
git submodule deinit --all -f | |
git submodule sync | |
rm -rf .git/modules/* | |
git submodule update --init | |
# Fix snagit crash on startup | |
cd ~/Library/Group Containers/7TQL462TU8.com.techsmith.snagit/Snagit 2022/PendingCaptures | |
rm * | |
# date a file in git repo was last modified | |
git log -1 --format="%as" -- <file> | |
# short rev a file in git repo was last modified | |
git rev-list --abbrev-commit -1 HEAD -- <file> | |
https://kaanlabs.com/ubuntu-set-scaling-factor-to-200-percent/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment