This is a collection of all kinds of tips that I found to be useful over the years as most of them reflect repetative tasks but that are seldom applied. As a human... I forget. This list will soon be merge with a much longer and older list and then, I guess, I will publish it maybe as gist on Github or part of my dot-files Git repository.
Solution:
$ dot
dyld: Library not loaded: /usr/lib/libltdl.7.dylib
Referenced from: /usr/local/bin/dot
Reason: image not found
Fix:
$ brew link libtool
⌃ ⌘ ⏏ Restart ⌥ ⌘ ⏏ Sleep ⌃ ⇧ ⏏ Put display to sleep (then also lock screen) ⇧ ⌘ Q Logout
/System/Library/CoreServices/SystemFolderLocalizations/de.lproj/SystemFolderLocalizations.strings
$ launchctl load foobar.plist
ablegen in: ~/Library/LaunchAgents
http://osx.realmacmark.de/osx_launchd.php
$ sqlite3 ~/Library/Mail/Envelope\ Index vacuum
$ /etc/motd
Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Resources/German.lproj/Localized.strings
Folder = "Ordner" umbenennen in: Folder = " Ordner"
⌃ ⌘ ⌥ ⇧ ⎋ ⏏ ⌫ ⇥ ⏎
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Toolbar*.icns
$ export CFLAGS="-I/opt/local/include -L/opt/local/lib"
$ xdpyinfo | egrep 'dimens|resolut'
$ for i in `ls -1 *.html` ; do \
$ wkpdf -m 0 -y print -n -p tabloid -c -e -s /Users/uwe/$i -o /Users/uwe/pdf/$i.pdf \
$ done
http://www.devdaily.com/apple/mac/java-mac-native-look/
$ defaults read com.apple.AddressBook NSUserKeyEquivalents
$ defaults write com.apple.AddressBook NSUserKeyEquivalents -dict-add "Nächste Visitenkarte öffnen" "@~→"
$ defaults write com.apple.Finder NSUserKeyEquivalents '{"Open" = "\r";}'
$ defaults write -globalDomain com.apple.mouse.scaling -float 0.8
$ defaults write org.chromium.Chromium NSUserKeyEquivalents '{"Forward" = "\177"; "Back" = "\010";}'
http://sourceforge.net/projects/rudix/files/
$ file /path/to/file.ext
$ [/usr/local/bin/]gcc [-m32|-m64|-arch i386|-arch x86_64|-arch universal] -O0 -Wall -fopenmp -o test path/to/test.c
$ sudo port -d selfupdate
$ sudo port upgrade outdated
$ port list installed
http://trac.macports.org/wiki/FAQ#uninstall
$ sudo defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture "/path/to/replacement/image/file.jpg"
$ defaults write com.apple.dock persistent-others -array-add \
'{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'
$ killall Dock
$ defaults write com.apple.dock no-glass -boolean YES
$ killall Dock
(finger) (rock) (drunk) (smoking) (fubar) (swear) (tmi) (bug) (bandit) (headbang) (toivo) (mooning) (poolparty) (bow)
http://aurelio.net/doc/as4pp.html
\renewcommand*{\lstlistlistingname}{List of Listings}
\newlistof{lstlistoflistings}{lol}{\lstlistlistingname}
:
\lstlistoflistings*
$ sudo fs_usage # or
$ sudo fslogger
Either fn+F2 or fn+ctrl+F2
IFS=$a'\n' ; for i in $(find $HOME/Library/Mail/RSS/ -name "Info.plist") ; do grep "http://" $i | sed "s/.*\(http[^<]*\).*/\1/" | grep -v "PropertyList-1.0.dtd" ; done
$ sudo lsof -i :80 | grep LISTEN
$ cd /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/
$ ./lsregister -kill -r -domain local -domain system -domain user
$ killall Finder
tell application "Contacts"
repeat with contact in every person
try -- catch missing values
delete title of contact
end try
end repeat
save
end tell
$ mp4box -chap chap_file file.m4a -out file.m4b
$ cat chap_fie
CHAPTER01=00:00:00
CHAPTER01NAME=The Quarrel between Achilles and Agamemnon
CHAPTER02=00:32:41
CHAPTER02NAME=Agammemnon's Dream
CHAPTER03=01:16:57
$ brew install mp3info
$ ls | xargs -I {} mp3info -p "%S\n" "{}" | awk '{s+=$1} END {print s / 60 / 60}'
$ java -version
$ cd /System/Library/Frameworks/JavaVM.framework/Versions/
$ sudo rm CurrentJDK
$ sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/ CurrentJDK
$ java -version
To only get notified about changes:
$ brew install fswatch
$ fswatch --help
$ fswatch ~/path/to/watch
To execute commands on changes:
$ sudo gem install filewatcher
$ filewatcher --help
$ filewatcher ~/path/to/watch "scp $FILENAME my-machine:."
$ curl ifconfig.me
$ M-.
$ ^foo^bar^
$ !!:s/foo/bar
$ cp filename{,.bak}
$ sudo !!
$ cd -
$ python -m SimpleHTTPServer
$ tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock |
GREP_COLOR="1;32" grep --color "[^ ]"
$ !*
$ diff <(sort file1) <(sort file2)
$ disown -a && exit
$ /usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2 http://www.google.com/
$ !:- http://www.commandlinefu.com/
This can happen when detaching from and reattaching to tmux. Then the
environment variable for SSH_AUTH_SOCK
gets lost. To re-add it, test:
$ env
...and search for SSH_AUTH_SOCK
. If you found it, run:
$ SSH_AUTH_SOCK=/tmp/launch-rKCENX/Listeners ssh-add -l
- Generate pub/priv key (rsa)
- Put pub key in ~/.ssh/authorized_keys
$ ssh-keygen -t rsa -b 2048 -f $HOME/.ssh/foobar_rsa_2048
$ ssh-keygen -t ecdsa -b 521 -f $HOME/.ssh/foobar_ecdsa_521
$ ssh-copy-id -i ~/.ssh/id_rsa.pub $HOSTNAME
That usually means that your clients is randomly trying more unlocked public keys than your server is patient enough to accept. There are multiple evasive actions: Delete all the current keys with "ssh-add -D" and see if you can log in successfully.
$ tmux set-option default-path "$HOME/dev"
or
: set-option default-path "$HOME/dev"
$ sudo emacs -nw /etc/hostname
$ sudo emacs -nw /etc/hosts
$ sudo /etc/init.d/networking restart
$ nmcli con up id VPNNAME
$ nmcli con [status [id VPNNAME]]
$ xinput set-prop "Djui's Mouse" "Device Accel Adaptive Deceleration" 1.0
$ xinput set-prop "Djui's Mouse" "Device Accel Constant Deceleration" 3.0
$ apt-get install openjdk-6-jre-headless
$ wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
$ dpkg -i elasticsearch-0.90.7.deb
$ /usr/share/elasticsearch/bin/elasticsearch # or...
$ sudo /etc/init.d/elasticsearch start
$ brew install moreutils
or
$ brew install parallel
Then:
$ cat bigfile | parallel --pipe --block 2M grep foo
or
$ < bigfile parallel --pipe --block 2M grep foo
or (as file)
#!/usr/local/bin/parallel --shebang -r --line-buffer youtube-dl -i -w -q
https://www.youtube.com/playlist?list=PLBXmeocYXDfCFnkCoxkSpFChle3gmidEn
https://www.youtube.com/playlist?list=PLBXmeocYXDfDp1j3aBZVVNFp4xW9zU3h-
https://www.youtube.com/playlist?list=PLOcrXzpA0W81LOjuTp8XZ2cjD4rjcTIET
https://www.youtube.com/playlist?list=PLOcrXzpA0W82rsJJKrmeBlY3_MS0uQv3h
$ sudo strace -e open,access /etc/init.d elasticsearch
C-x (’ Start recording a keyboard macro
C-x )’ Stop recording the keyboard macro
C-x e Execute macro 1 time
C-u N C-x e Execute macro N time
C-u 0 C-x e Execute macro until reaching EOF
In emacs:
C-x RET c utf-8 RET C-x C-w NEW_FILENAME
or shell:
$ iconv -f ORIGINAL_CHARSET -t utf-8 ORIGINAL_FILE > NEW_FILE
In emacs:
M-x set-buffer-file-coding-system utf-8-unix
C-x + : M-x balance-windows
emacs --eval '(byte-compile-file "xxx.el")'
M-x set-buffer-encoding-system RET iso-latin-1 or utf8
M-x list-faces-display
M-x list-colors-display
http://www.gnu.org/software/emacs/manual/html_node/emacs/Standard-Faces.html
C-u C-x = describe-char
C-c C-Space
apropos (search Emacs function and variable descriptions)
describe-key-briefly (describe a keystroke command)
describe-bindings (list all current commands which have keystrokes)
toggle-read-only (toggle a buffer between read-only and read-write)
C-h u Let's you type a key binding and see what is connected to it
M-x global-set-key Let's you bind keys directly
diff-buffer-with-file
M-/
C-c C-SPACE
C-x r t
$ brew install --use-gcc emacs --cocoa --with-x --use-git-head
add:
(modify-syntax-entry ?# "< b" awk-mode-syntax-table)
(modify-syntax-entry ?\n "> b" awk-mode-syntax-table)
to the awk-mode.el and reload the file + awk-mode when opening a file.
C-q <TAB>
C-h v package-activated-list
(ac-nrepl auto-complete auto-highlight-symbol autopair clojure-project-mode
clojure-test-mode dash diff-git erlang expand-region github-theme
gitty go-mode highlight-parentheses ibuffer-vc ido-ubiquitous iedit
indent-guide lua-mode magit-simple-keys magithub magit markdown-mode
move-text multiple-cursors nrepl clojure-mode paredit popup project-mode
levenshtein rainbow-delimiters ruby-mode rust-mode cm-mode s scala-mode
smart-tab smex yasnippet)
In tilebottom view, press "Mod4+shift+h/j" 2 or 3 times
See: http://aperiodic.net/screen/title_examples
$ echo -ne '\ekcommand-line\e\\'
for d in ls -1
; do
if [ -e "$d/.git" ] ; then
pushd "$d" > /dev/null
pwd
git status -s
popd > /dev/null
fi
done
You have myfile
and myFile
and git/OSX get confused.
$ git mv myFile myFile2
$ git mv myFile2 myfile
$ git log --diff-filter=D --summary | grep <file_path>
$ git rev-list -n 1 HEAD -- <file_path>
$ git checkout <deleting_commit>^ -- <file_path>
git remote add origin [email protected]:Kreisquadratur/circle_packing.git
...
git clone [email protected]:Kreisquadratur/circle_packing.git
...
git add .
git commit
git push origin master
(git push origin newbranch)
(git branch -r)
...
git pull origin
...
git checkout -b newbranch
...
$ git log origin/master.. --no-merges
$ git cherry -v origin
$ git diff --stat origin/master
$ git diff --name-status [BRANCH1]..[BRANCH2]
C^ == C~
C^ == C^1
C~ == C~1
C^^ == C^1^1
C^1 \
C^2 - C -
C^3 /
C~3 C~2 C~1 \
C^2 - C -
C^3 /
$ git submodule foreach git pull origin master
http://andyjeffries.co.uk/articles/25-tips-for-intermediate-git-users
http://airto.hosted.ats.ucla.edu/wiki/index.php/Setting_Up_and_Using_Git
$ git diff -p FILENAME
$ git add -u
$ git push origin :BRANCH
or locally:
$ git branch -d BRANCH
$ git merge-base master HEAD
or:
$ git merge-base master BRANCH
or:
$ cat .git/logs/refs/heads/BRANCH
and look for: "branch: Created from HEAD"
$ git push --tags
See ehf_string:format/1
$ erl +U
$ brew install --use-gcc erlang b
or
$ ./otp_build autoconf
$ CFLAGS=-O0 ./configure --disable-hipe --enable-darwin-64bit
$ ./otp_build boot
or just
$ CFLAGS=-O0 ./otp_build setup --disable-hipe --enable-darwin-64bit
/Users/uwe/dev/OTP/src/otp_r14b01_klarna/erts/emulator/beam/erl_bif_info.c Change static char erts_system_version[]
LD often stands for Loop Data in Erlang code
1> Fun = fun() -> io:format("ok~n", []) end.
2> erlang:fun_info(Fun, env).
2> erl_pp:function(Fun).
> erlang:check_process_code(Pid, Module) -> bool()
> erlang:delete_module(Module) -> true | undefined.
> [{P,case I of
{proc_lib,init_p,5} -> proc_lib:translate_initial_call(P);
_ -> I
end} || {P,{initial_call,I}} <- [{P),process_info(P), initial_call)} || P0 <- processes()]]).
As in mnesia_lib.erl defined: .DAT %% DETS files .DMP %% Dumped ets tables .DCD %% Disc copies data .DCL %% Disc copies log .TMP
Compile with MACRO:
> c("path/to/src/module.erl", [{d,'TEST'}]).
help() %% @doc List all commands
e(N, T) %% @doc Get the nth element either of a list or tuple
p(X) | long(X) %% @doc io format a variable
cl(M, F, A) %% @doc Call a non exported function
export(M, F, A) %% @doc Export an unexported function
export_all(M) %% @doc Export all functions of a module
c(M) %% @doc Compile a module with debug_info
src(Module) %% @doc Path to the erl file of a module
beam(Module) %% @doc Path to the beam file of a module
mm() %% @doc List modified modules
lm() %% @doc Load modified modules
lrm() %% @doc Reload modified modules and purge-delete removed modules
nl() %% @doc Load modified modules on all known nodes
r(M, F) %% @doc Debug a module's function call using Redbug
rbugon(M, [F]) %% @doc Longterm Debug a module's function call using Redbug
m(M) | '?'(M) %% @doc Lookup macro definition
pid(X) %% @doc Get a valid Pid representation out of anything
bt(Pid) %% @doc Backtrace a process
pi() %% @doc List open ports (tcp, efile, ...)
fullsweep(Pid) %% @doc Garbage collection on all processes
pid_diff(Sleep) %% @doc Show change in reductions and heap_size of a pid over time
redbug:start("module:fun/arity -> stack;return", [ {time, s*1000}
, {msgs, 2000}
, {print_re, ""}
, {target, nonode@nohost}
]).
redbug:start("my_module", [ {arity, true}
, {print_form, "~s"},
, {print_re, ""}
, ...
]).
$ cd lib/yaws
$ make clean
$ autoconf
$ ./configure --disable-sendfile
$ make
$ latexmk -pvc -pdf foo.tex
- CMU Serif
- Latin Modern Roman
http://www.tex.ac.uk/ctan/macros/latex/contrib/classicthesis/
$ ffmpeg -i input.mp4 -vn -acodec copy output.m4a
$ ffmpeg -i input.webm -vn -acodec copy output.ogg
$ ffmpeg -i input.flv -vn -acodec copy output.m4a
$ ffmpeg -i input.mov -s 640x480 -b 600k -r 24 -ar 22050 -ab 96k -vcodec h264 -acodec aac output.mp4
$ sudo port install mp4v2
$ mp4chaps
$ ffmpeg -i input.mov -pix_fmt rgb24 output.gif
$ convert -layers Optimize output.gif output_optimized.gif
For local mining:
echo "rpcuser=djui" > ~/Library/Application\ Support/Bitcoin/bitcoin.conf
echo "rpcpassword=12345678" >> ~/Library/Application\ Support/Bitcoin/bitcoin.conf
/Applications/Bitcoin.app/Contents/MacOS/bitcoin -server &
./poclbm.py --user=djui --pass=12345678 --device=1
$ sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 2
$ sudo cp ~/Downloads/*.ttf /usr/share/fonts/croscore/
$ ssh-keygen
$ cat /home/chronos/user/.ssh/id_rsa.pub >> /home/chronos/user/.ssh/authorized_keys
$ chmod 600 /home/chronos/user/.ssh/authorized_keys
$ sudo bash
# mkdir -p /mnt/stateful_partition/etc/ssh
# ssh-keygen -t rsa -f /mnt/stateful_partition/etc/ssh/ssh_host_rsa_key
# ssh-keygen -t dsa -f /mnt/stateful_partition/etc/ssh/ssh_host_dsa_key
# /usr/sbin/sshd
# exit
http://www.4clojure.com/problem/solutions/19
(defn last [x] (reduce #(-> %2) x))
(->>(read)(eval)(prn)(while :t))
> not=
> (comp set filter)
The following are all equal:
> (cons x (lazy-seq (...)))
> (lazy-seq (cons x (...)))
> (lazy-cat [x] (...))
(defn gapmap
"Returns a lazy sequence consisting of the result of applying f to all
adjacent values of coll. f should be a function of 2 arguments. If coll
contains less than 2 items, it is returned and f is not called."
{:added "1.6"}
([f coll]
(if-let [r (next coll)] ; at least two items?
(lazy-seq (gapmap-internal f (first coll) r))
coll)))
(defn- gapmap-internal
[f x coll]
(if-let [y (first coll)]
(cons (f x y) (gapmap-internal f y (next coll)))))
#(= % ((fn m [[v l r]] (if v [v (m r) (m l)])) %))
or
(letfn [(m [[v l r]] (if v [v (m r) (m l)]))] #(= % (m %)))
The function compares the original binary tree (%
) with a temporary binary
tree ((m %)
) which has all its left and right anchestors swapped (m
means
mirror).
The trick is to use a classic functional approach: Express what should be done, not how. Instead of implementing the comparison of every anchestor yourself, let the system do the comparison.
The trade-off is readability vs memory space (2x size of btree).
Mine:
(fn sbt? [[_ [lv ll lr :as l] [rv rl rr :as r]]]
(or (= nil l r)
(and (= lv rv)
(sbt? [_ ll rr])
(sbt? [_ lr rl]))))
$ defaults write scalaide.product.id AppleAntiAliasingThreshold 20
$ defaults write org.eclipse.eclipse AppleAntiAliasingThreshold 20
Riak has many backend types, e.g. storage_backend
which is used by Riak
KV. Riak KV's riak_kv
initializes riak_kv_vnode
which get_env
the backend
callback module name for a specific type (e.g. storage_backend
) and calls
Mod:start
on it. The backend has to return a backend state
record which is
handed over which every api call (e.g. Mod:put(Bucket, Key, IndexSpecs, Val, ModState)
. Thus, the backend can be stateful (have servers, ets tables, etc.)
but are not linked or monitored by the user( e.g. riak_kv_vnode
) who holds the
backend name (#state.mod=Mod
) and its state (#state.modstate=ModState
).
The Squiggle tool itself doesn't allow to modify the outfile DPI, thus uses 96 DPI.
$ java -jar -Xmx1g /Applications/Squiggle.app/Contents/Resources/batik-rasterizer.jar -dpi 300 -m image/tiff -d outfile.tiff infile.svg
You have to be in a dedicated directory. Vagrant images are under ~/.vagrant.d
$ vagrant init "Ubuntu 12.10 x64" http://files.vagrantup.com/precise64.box
$ vagrant init "Debian 6 Squeeze x64" http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box
$ vagrant up