forked from amarshall/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuseful_commands.txt
54 lines (39 loc) · 2.27 KB
/
useful_commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Here lies some useful commands that are awesome but are usually too
# rarely used to remember. They are useful for...
# ...validating a binary's code signature
codesign -v /Applications/Example.app
# ...determining DNS info
dig @8.8.8.8 example.com any
# ...determining the architectures within a universal binary
file
# ...finding C/C++ standard libraries
`clang -print-prog-name=cc1` -v
`clang -print-prog-name=cc1plus` -v
# ...updating all git submodules
git submodule foreach git pull origin master
# ...finding what package installed a binary (Ubuntu/Debian)
dpkg -S `which examplebinary`
# ...searching for a string/regex in git diff history
git -Sstringtosearchfor --since=2012.2.17 --until=2012.3.14 -- pathname
git --pickaxe-regex "regextosearchfor" --since=2012.2.17 --until=2012.3.14 --pathname
# ...configuring, compiling, and installing latest Ruby in OS X without fault
brew install gdbm libyaml readline
brew link readline
VERSION="version" ./configure --without-gcc --prefix="/Users/$(whoami)/.rbenv/versions/$VERSION" --with-opt-dir=/usr/local/ --enable-shared && make && make test && make install
brew unlink readline
# ...compiling Ruby with ruby-install and optimizations
CC=clang CFLAGS='-march=native -O2 -pipe' ruby-install RUBY_PLATFORM RUBY_VERSION
# ...getting a key's fingerprint
ssh-keygen -lf /path/to/keyfile
# ...removing excessive trailing newlines from files
find . -type f -print0 | xargs -0 perl -pi -w -e 'BEGIN{$/=undef}; s/(\n)+\Z/\n/'
# ...removing (more than two) consecutive blank lines from files
find . -type f -print0 | xargs -0 perl -pi -w -e 'BEGIN{$/=undef}; s/\n\n+/\n\n/'
# ...removing excess padding in Ruby class/def/end blocks
find app lib spec config -type f -iname '*.rb' -print0 | xargs -0 perl -pi -w -e 'BEGIN{$/=undef}; s/(\n *end\n)\n+( *end\n)/$1$2/'
find app lib spec config -type f -iname '*.rb' -print0 | xargs -0 perl -pi -w -e 'BEGIN{$/=undef}; s/(\n *(class|def) [^\n]*\n)\n+/$1/'
find app lib spec config -type f -iname '*.rb' -print0 | xargs -0 perl -pi -w -e 'BEGIN{$/=undef}; s/( do(\n|(\|[^|\n]+)?)\n)\n+/$1/'
# ...finding the MTU used between two machines (test from boths ends)
route get <machine name>
# ...finding hosts on your LAN (best with sudo, change subnet accordingly)
nmap -sn -oG - 192.168.1.0/24 | egrep '^Host:' | column -t