R Primus  committed d801722

add txt files from

  • Participants
  • Parent commits 463ecc3

Comments (0)

Files changed (7)

File osx/

+C-h b shows a list of keybindings
+C-h C-h shows a list of help commands
+C-h f is describe-function and C-h v is describe-variable
+C-x 4 C-h shows bindings that start with C-x 4
+C-h r opens the info node for the Emacs manual
+C-h a (apropos-command) searches for interactive functions
+C-u C-h a searches for interactive and non-interactive functions
+C-h a transpose RET shows commands whose name contains transpose
+C-u C-h a regexp RET shows all functions whose name contains regexp
+M-x apropos-variable RET ruby RET lists variables whose name contains ruby
+C-h d searches in the docstrings of functions and variables
+M-x info-apropos RET grep RET shows matches for grep in info indexes
+space scrolls down or selects the next node in a sequence
+backspace scrolls up or selects the previous node in a sequence
+n selects the next node, p selects the previous node, and u goes up
+] selects the next node in a sequence
+C-h i d m emacs RET or C-h i g(emacs) RET goes to the emacs node
+m selects a menu item
+d goes to the directory node that is shown when opening a new info buffer
+tab and C-M-i select menu items and cross-references
+mxyz selects the first menu item that starts with xyz
+fxyz follows the first cross-reference that starts with xyz
+5 selects the fifth menu item
+l goes to the last visited node and r goes back after l
+L shows a menu of visited nodes
+ixyz searches for xyz in the index and opens the first result
+, opens the next result after i
+Ixyz displays a list of nodes that contain xyz
+> goes to the final node
+C-h i d m emacs <RET> i TOPIC <RET> searches for TOPIC in the Emacs info index
+i searches in the index and s searches for in the full text of an info page
+m marks a file, u unmarks a file, and U unmarks all files
+%m marks files whose name matches a regular expression
+%m \.html$ RET marks HTML files
+C copies files and R renames files
+d flags files for deletion and x deletes flagged files
+D deletes files immediately
+M changes mode, G changes group, O changes owner, and T changes timestamps
+^ goes to a parent directory
++ creates a new directory
+g refreshes a directory listing
+! runs a shell command on the selected files
+you can use M-! to run shell commands in the current directory
+Z compresses files with gzip or uncompresses gz or tar files
+s toggles between sorting by name and date
+a opens a directory in the current buffer
+you can rename files by pressing C-x C-q and then editing the filenames
+if package-install doesn't find a package, try to run package-refresh-contents
+C-x C-s applies and saves changes and C-c C-c applies changes
+M-x custom-reset-standard removes all customizations
+M-x customize-changed RET 24.3 RET customizes settings changed in Emacs 24.3
+C-c C-i inserts > and a closing tag on the same line
+C-c C-b inserts > and a closing tag on a different line
+C-c / (nxml-finish-element) inserts a closing tag
+C-c C-v (rng-validate-mode) toggles validation
+C-M-n is nxml-forward-element
+C-c C-u IDEOGRAPHIC SPACE RET inserts &#x3000;
+C-c C-v (browse-url-of-buffer) opens the current file in a browser
+C-c C-f is sgml-skip-tag-forward and C-c C-d is sgml-delete-tag
+C-c C-n selects the next heading
+C-c C-f selects the next same level heading
+C-c C-u goes up
+<M-return> inserts a new list item below
+C-c C-s C-b is markdown-blockquote-region
+C-c C-c n is markdown-cleanup-list-numbers
+C-c C-x runs a script
+M-a is sh-beginning-of-command and M-e is sh-end-of-command
+C-M-x executes the region
+C-c C-c is comint-interrupt-subjob and C-c C-\ is comint-quit-subjob
+C-k deletes a file in ido-find-file and a kills a buffer in ido-switch-buffer
+ido uses regex matching so use .* instead of *
+C-e edits the input string
+C-p toggles between prefix matching
+C-t toggles regex matching
+and C-c toggles case sensitivity
+C-d opens a directory in dired in ido-find-file
+M-p goes to the previous working directory in ido-find-file
+M-m creates a new directory in ido-find-file
+M-x customize-create-theme creates a theme
+M-x custom-theme-visit-theme edits a theme created with customize-create-theme
+C-h f runs describe-function
+M-. jumps to a definiton
+smex-show-unbound-commands shows frequently used commands with no keybindings
+smex-major-mode-commands only shows commands relevant to the active major mode
+#OS X
+(setq ns-command-modifier 'meta) changes command to meta
+(setq ns-right-control-modifier 'super) changes the right control to super
+(setq ns-option-modifier nil) allows using option to insert non-ASCII characters
+(setq-default ns-use-native-fullscreen nil) uses custom full screen windows
+many OS X-specific features are defined in ns-win.el
+doc-view-mode and proced don't work in OS X out of the box
+#Emacs 24.4
+electric-indent-mode is enabled by default
+C-x <tab> activates a transient mode where <left> and <right> change indentation
+tab-stop-list is nil by default which means a tab stop every tab-width columns
+uniquify is enabled by default
+? describes prefix bindings
+there is a new toggle-frame-fullscreen command that is bound to F11
+there is a new toggle-frame-maximized command that is bound to M-<f1>0
+the new focus-out-hook hook is run when a frame loses focus
+the new focus-in-hook hook is run when a frame gets focus
+C-x SPC (rectangle-mark-mode) creates a rectangular region
+files like .ido.last and .emacs-places are saved to ~/.emacs.d/
+the positions of frames and windows are saved when desktop-save-mode is enabled
+M-s . searches for the next occurrence of a symbol near point
+iswitchb was made obsolete in favor of icomplete-mode
+longlines.el was made obsolete in favor of visual-line-mode
+eww is a new web browser package
+there is a new prefer-utf-8 coding system
+there is a new string-suffix-p function
+support for variadic comparisons like (= a b c) was added
+(superword-mode 1) makes for example x_y and x-y be treated as single words
+there is a new delete-duplicate-lines command
+#Emacs 23
+transient-mark-mode is enabled by default
+shift-arrows select text unless shift-select-mode is set to nil
+line-move moves the point by visual lines unless line-move-visual is nil
+visual-line-mode wraps lines at word boundaries
+linum-mode adds line numbers
+C-x b, M-x, C-h f, and ucs-insert support wildcards
+whitespace-mode visualizes whitespace characters
+whitespace-newline-mode visualizes newlines
+wdired-change-to-wdired-mode is bound to C-x C-q
+characters are encoded as utf-8-unix instead of mule-utf-8-unix
+ucs-insert is bound to C-x 8 RET
+proced is a mode like dired for managing processes
+ruby-mode is included by default
+doc-view-mode is a mode for viewing pdf, ps, and dvi files
+epa (EasyPG Assistant) is an interface to gpg
+(setq delete-by-moving-to-trash t) enables using the trash folder of the OS
+#unsorted interactive
+M-@ is mark-word, C-M-@ is mark-sexp, and C-M-h is mark-defun
+C-c C-b is help-go-back in a help buffer
+C-x C-e is eval-last-sexp
+C-h C-n (view-emacs-news) shows Emacs version history
+C-u C-x C-e inserts the result of the last sexp
+winner-mode makes C-c <left> undo changes in window configuration
+M-! is shell-command and M-| is shell-command-on-region
+C-u M-| replaces the region
+M-z is zap-to-char
+M-z " deletes up to the next " and M-- M-z " deletes up to the previous "
+C-M-k is kill-sexp
+M-k is kill-sentence and C-x DEL is backward-kill-sentence
+M-x ffap RET RET opens a URL at point in a browser
+C-M-f (forward-sexp) goes to a closing brace
+C-M-% <\([^>]+\)> RET <\,(downcase \1)> RET makes XML tags lowercase
+M-s h l is highlight-lines-matching-regexp
+M-s h l .\{81\} RET highlights long lines
+C-x n n (narrow-to-region) shows only the lines in the region
+C-x n w (widen) undoes narrowing
+C-x f is set-fill-column
+C-M-\ is indent-region
+C-x h C-M-\ reindents a buffer
+C-r views a buffer and d shows changes to a buffer after C-x C-c
+C-s C-w searches for the word after the point
+C-s C-M-y C-M-y searches for two characters after the point
+you can use C-x r t (string-rectangle) to insert text on multiple lines
+C-M-% [0-9]+ RET \,(1+ \#&) RET adds 1 to each number
+\#& is replaced with the matched string interpreted as a number
+M-x align-regexp RET = RET adds spaces before equals signs
+you can open a .info file with C-u C-h i
+M-x find-function RET global-set-key RET finds the definition of global-set-key
+M-x find-function RET RET finds the definition of the function near the point
+you can use C-h l to see escape sequences for previously pressed keys
+C-h F is Info-goto-emacs-command-node
+C-h F hippie-expand RET opens the info node for hippie-expand
+C-x v + is vc-update and C-x v = is vc-diff
+M-x auto-revert-mode enables automatically reverting the current buffer
+M-x flush-lines RET ^; RET deletes lines that start with ;
+M-x keep-lines RET ^foo RET deletes lines that don't start with foo
+M-x flyspell-prog-mode checks for spelling in comments and strings
+C-x C-n sets a goal column and C-u C-x C-n unsets a goal column
+M-m (back-to-indentation) moves the point to the first non-whitespace character
+C-x RET C-\ is set-input-method
+C-x RET C-\ TeX RET \alpha inserts an alpha character
+M-x delete-trailing-whitespace or C-x RET f unix converts CRLF line endings to LF
+C-u C-u C-x } makes a window 16 characters wider
+C-x 5 0 is delete-frame
+C-x 5 1 is delete-other-frames
+C-x 5 2 is make-frame-command
+ido-menu jumps to a definition in the current file
+C-S-backspace is kill-whole-line
+C-x r s 1 saves text to register 1 and C-x r i s inserts the text in register 1
+C-x r <SPC> 1 saves the point in register 1 and C-x r j 1 jumps to register 1
+C-x r w 1 saves window configuration and C-x r j 1 restores window configuration
+M-x view-register RET 1 shows the contents of the register 1
+C-x r s is copy-to-register
+C-x r i is insert-register
+C-x r <SPC> is point-to-register
+C-x r j is jump-to-register
+C-x r w is window-configuration-to-register
+C-x r f is frame-comfiguration-to-register
+C-x r r is copy-rectangle-to-register
+C-x * * opens calc
+C-x $ is set-selective-display
+M-6 C-x $ hides lines indented by 6 or more columns
+M-1 C-x $ only shows unindented lines
+pressing C-x $ again turns off selective display
+M-x toggle-truncate-lines toggles between folding and truncating long lines
+C-x 4 0 is kill-buffer-and-window
+C-x 4 c is clone-indirect-buffer-other-window
+M-r is previous-matching-history-element in minibuffer-local-map
+M-x list-command-history shows a list of commands typed in the minibuffer
+C-x <ESC> <ESC> (repeat-complex-command) executes commands from command history
+C-h . (display-local-help) shows tooltip text
+C-h L utf-8 describes the utf-8 language environment
+C-h d searches in the docstrings of built-in symbols
+C-u C-h d searches in all currently defined docstrings
+C-h p (finder-by-keyword) shows a list of ELPA packages grouped under categories
+C-h P yasnippet RET opens a buffer that describes yasnippet
+C-h e (view-echo-area-messages) opens the *Messages* buffer
+you can use C-<SPC> C-<SPC> to mark a position to return to later
+C-u C-<SPC> returns to a position marked with C-<SPC> C-<SPC>
+C-h v kill-ring RET shows the contents of the kill ring
+M-x append-to-buffer appends text to a buffer
+M-x copy-to-buffer replaces the contents of a buffer
+C-x r y is yank-rectangle
+C-x r M-w is copy-rectangle-as-kill
+C-x r o (open-rectangle) inserts a rectangle of spaces
+C-x r c (clear-rectangle) replaces all characters in the rectangle with spaces
+(set-register ?z '(file . "/dir/file")) makes C-x r j z open /dir/file
+C-x r m is bookmark-set and C-x r j is bookmark-jump
+M-x dired-jump shows the file of the current buffer in a dired buffer
+C-x ( is kmacro-start-macro
+C-x ) is kmacro-end-macro
+C-x e is kmacro-end-and-call-macro
+C-x r m emacs RET sets the bookmark named emacs
+C-x r j emacs RET opens the bookmark named emacs
+C-x r m is bookmark-set, C-x r j is bookmark-jump, and C-x r l is list-bookmarks
+M-x check-parens checks for unbalanced parentheses
+if there is an error parsing .emacs, try to run M-x check-parens
+C-x C-o (delete-blank-lines) replaces blank lines with a single empty line
+M, is tags-loop-continue
+C-x = is what-cursor-position
+C-u C-x = or M-x describe-char shows information about a character
+M-5 C-x e repeats a macro five times
+M-0 C-x e repeats a macro until there is an error
+M-x ff-find-other-file opens a corresponding header or source file
+C-x + is balance-windows
+M-x load-file RET ~/.emacs RET applies changes to ~/.emacs
+C-a C-o inserts a new line above
+C-M-l (reposition-window) makes a definition or comment visible
+C-x < is scroll-left and C-x > is scroll-right
+C-x n d is narrow-to-defun
+q deletes a view mode buffer and e exits view mode
+M-x list-faces-display shows currently defined faces
+M-x list-colors-display lists color names
+C-x C-+ or C-x C-= increases text scale
+M-x global-font-lock-mode toggles font lock mode in all buffers
+M-x customize-group RET font-lock-faces RET allows customizing faces
+M-x replace-regexp RET [0-9]+ RET \,(format "%04d" \#&) RET zero-pads numbers
+M-x find-library RET ido RET opens the elisp source file for ido
+C-u 0 M-t transposes the words ending after the mark and the point
+M-x compare-windows compares text in the current and next window
+C-x i (insert-file) inserts the contents of a file
+M-x write-region writes the region to a file
+M-x append-to-file appends the region to a file
+C-x 6 2 is 2C-two-columns
+C-x 6 b is 2C-associate-buffer
+C-x 6 s is 2C-split
+C-x + is balance-windows
+C-x - is shrink-window-if-larger-than-buffer
+scroll-other-window-down is bound to M-prior and C-M-S-v
+M-ESC ESC deactivates the mark
+C-M-l (reposition-window) makes a definition or comment visible
+C-u C-/ undoes changes within a region when transient mark mode is not enabled
+S-Mouse-3 is ffap-at-mouse nad C-S-Mouse-3 is ffap-menu
+M-v is shift-to-completions in hte minibuffer
+C-x = is what-cursor-position
+F10 is menu-bar-open and M-` is tmm-menubar
+C-u M-; kills a comment and whitespace before the comment
+C-\ is toggle-input-method
+M-g c (goto-char) goes to a buffer position
+url-hexify-string is URL encode and url-unhex-string is URL decode
+lexical-let has been made obsolete
+defadvice and letf are not allowed in Emacs source code
+symbols are case-insensitive in Common Lisp but case-sensitive in Emacs Lisp
+`;;; -*- lexical-binding: t -*-` has enabled lexical binding since 24.1
+point-max is (1+ (buffer-size)) unless narrowing is in effect
+before-advice, after-advice, and around-advice are advice classes
+generate-new-buffer always creates a new buffer
+get-buffer-create returns an existing buffer or creates a new buffer
+s- is super, H- is hyper, and A- is alt
+/* -*- compile-command: "gcc -Wall" -*- */ changes the command for M-x compile
+evil is a successor to vimpulse and vim-mode which are no longer maintained
+viper is a basic vi emulation mode that comes with emacs
+evil, vimpulse, and vim-mode add features like visual selection and text objects
+<right> invokes right-char in Emacs 24 and forward-char in Emacs 23
+ejacs is a JavaScript interpreter written in elisp
+(zerop (length "string")) is constant time
+(equal "string" "string") and (string-equal "string" "string") are linear time
+profile-dotemacs.el runs each sexp through benchmark-run
+the minor-mode-list variable is set to a list of of all minor mode functions
+Emacs regular expressions don't support \d, \w, or \s
+Emacs regular expressions support \` and \' but not \A or \Z
+iswitchb-mode was made obsolete in Emacs 24.4
+mark-active is t if the mark is active
+(read t) reads from the minibuffer or from standard input in batch mode
+(read nil) reads from standard input
+inactive minibuffers have the major mode minibuffer-inactive-mode
+the fifth argument to read-from-minibuffer defaults to minibuffer-history
+(eval-minibuffer "Prompt: ") is like (eval (read-minibuffer "Prompt: "))
+info-apropos searches in info indexes
+apropos-documentation shows symbols whose documentation matches a pattern
+C-h w (where-is) shows what keybindings a function has
+add-to-history removes duplicates if history-delete-duplicates is non-nil
+beginning-of-line-text moves past indentation and a fill prefix
+resize-mini-windows is set to grow-only by default
+max-mini-window-height is set to 0.25 by default
+enable-recursive-minibuffers is nil by default
+the emacs22 completion style is like basic but it ignores text after the point
+the partial-completion completion style splits words around spaces and hyphens
+the initials completion style makes for example lch match list-command-history
+completion-ignored-extensions contains for example .o and ~ by default
+kill-ring-max is 60 by default
+cider used to be called nrepl.el
+bookmarks are saved in ~/.emacs.d/bookmarks
+abnormal hooks end with -hooks or -functions
+scroll-up-command considers scroll-error-top-bottom but scroll-up doesn't
+the vertical-border face is used for the divider in text terminals
+font-lock-maximum-decoration is set to t by default
+fringe-mode affects all frames and set-fringe-style affects the selected frame
+diff-switches is -c by default
+initial-major-mode is lisp-interaction-mode by default
+electric-indent-mode indents when electric-indent-functions returns non-nil
+electric-layout-mode automatically inserts newlines around some characters
+clean-buffer-list kills buffers that have not been displayed recently
+- is no special charset, = is no conversion, and 1 is Latin-1
+C-z (suspend-display) calls iconify-or-deiconify-frame in a graphical display
+DEL is delete-backward-char and <deletechar> is delete-forward-char
+paragraphs are delimited by leading spaces in paragraph-indent-minor-mode
+a special display buffer is always displayed in a dedicated frame
+each symbol has a name, a value cell, a function cell, and a plist
+a disembodied plist is independent of any symbol
+a lambda expression is a sext that evaluates tto a cons whose car is lambda
+an atom is a Lisp entity that is not a cons
+an alist is a list where each element is a cons
+(let ((a 1) (b 3)) (+ a b)) is equivalent to ((lambda (a b) (+ a b)) 1 3)
+-nw (--no-window-system) opens emacs in a terminal ignoring DISPLAY
+--no-site-file disables loading site-start.el
+--debug-init shows information about errors in an init file
+#elisp with return values
+(+ (expt (sin .5) 2) (expt (cos .5) 2)) ; 1
+(cons 1 (cons 2 (cons 3 nil))) ; (1 2 3)
+(float 5) ; 5.0
+(apply '+ '(1 2 3)) ; 6
+(concat "aa" "bb") ; "aabb"
+(length "aa") ; 2
+(replace-regexp-in-string "a+" "b" "aac") ; "bc"
+(split-string "a,b" ",") ; ("a" "b")
+(format "%03d" 2) ; "002"
+(string-to-number "3") ; 3
+(number-to-string 3) ; "3"
+(file-name-directory "/dir/file.txt") ; "/dir/"
+(file-name-nondirectory "/dir/file.txt") ; "file.txt"
+(file-name-extension "/dir/file.txt") ; "txt"
+(file-name-sans-extension "/dir/file.txt") ; "/dir/file"
+(lsh 128 -3) ; 16
+(lsh 512 -3) ; 64
+(logior 1 3) ; 3
+(logiand 1 3) ; 1
+(substring "xyz" -1) ; "z"
+(replace-regexp-in-string "[ \t\n]*$" "" "a \t") ; "a"
+(remove 'b '(a b c)) ; (a c)
+(remove-duplicates '(1 1 2)) ; (1 2)
+(remove-duplicates '("a" "a" "b") :test 'string=) ; ("a" "b")
+(nconc '(a b) 'c) ; (a b . c)
+(nconc '(a b) '(c d)) ; (a b c d)
+(append '(a b) '(c d)) ; (a b c d)
+(last '(a b c d e) 2) ; (d e)
+(butlast '(a b c d e) 2) ; (a b c)
+(number-sequence 1 7 3) ; (1 4 7)
+(mapcar 'car '((a b) (c d))) ; (a c)
+(mapcar '1+ [1 2 3]) ; (2 3 4)
+(mapcar* 'cons '(a b) '(1 2)) ; ((a . 1) (b . 2))
+(member "c" '("a" "b")) ; nil
+(expt 16 4) ; 65536
+(regexp-quote "[a].") ; "\\[a\\]\\."
+(string-equal "/" (substring "a/" -1)) ; t
+(read-from-string "abcde") ; (abcde . 5)
+(read-from-string "abcde" 2) ; (cde . 4)
+(prin1-to-string 'aa) ; "aa"
+(all-completions "aa" '(("aab" 1) ("aac" 2) ("bb" 3))) ; ("aab" "aac")
+(/= 15 5) ; t
+(shell-quote-argument "it's") ; "it\\'s"
+(buffer-local-value 'major-mode (get-buffer "*Messages*")) ; fundamental-mode
+(lognot #b1001) ; -10
+(aref [7 8 9] 2) ; 9
+(elt [1 2 3 4] 2) ; 3
+(string (elt "1234" 2)) ; "3"
+#elisp config
+(setq rng-nxml-auto-validate-flag nil) ; disable validation by default
+(setq ido-enable-prefix t) ; use prefix matching instead of substring matching
+(add-hook 'markdown-mode-hook (lambda () (variable-pitch-mode t))
+(add-hook 'html-mode-hook (lambda () (auto-fill-mode -1)))
+(unless (server-running-p) (server-start))
+(global-set-key (kbd "<C-f1>" 'ignore)
+(delete '("\\.html?\\'" flymake-xml-init) flymake-allowed-file-name-masks)
+(setq x-stretch-cursor t) ; make the cursor wider over characters like tab
+(setq initial-buffer-choice "~/notes/temp.txt")
+(setq show-paren-style 'expression) ; highlight the whole expression
+(setq disabled-command-hook nil) ; enable all disabled commands
+(setq local-function-key-map (delq '(kp-tab . [9]) local-function-key-map))
+(setq compilation-scroll-output t) ; always scroll a compilation buffer
+(setq compilation-scroll-output 'first-error) ; stop scrolling after an error
+(setq grep-command "grep -PnHe") ; make M-x grep use PCRE
+(setq-default fill-column 80)
+(substitute-key-definition 'kill-buffer 'kill-buffer-and-its-windows global-map)
+(setq browse-url-browser-function 'browse-url-default-macosx-browser)
+(setq confirm-nonexistent-file-or-buffer nil)
+(setq-default line-spacing 0.1)
+(set-register ?e '(file . "~/.emacs")) ; make C-x r j e open ~/.emacs
+(iswitchb-mode) ; bind C-x b to ido-switch-buffer
+(setq comment-auto-fill-only-comments t)
+(add-hook 'c-mode-hook (lambda () (linum-mode 1)))
+(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
+(add-to-list 'completion-ignored-extensions ".orig")
+(setq show-trailing-whitespace t) ; highlight trailing whitespace
+(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
+(substitute-key-definition 'kill-buffer 'kill-buffer-and-its-windows global-map)
+(if (equal "xterm" (tty-type)) (define-key (input-decode-map "\e[1;2A" [S-up])))
+(setq comint-input-ignoredups t) ; don't add repeated commands to the input ring
+(setq tab-always-indent complete) ; complete if the line is already indented
+(comment-or-uncomment-region (line-beginning-position) (line-end-position)))
+(setq x-stretch-cursor t) ; stretch the cursor over wide characters
+(setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
+(global-set-key "\M-`" 'other-frame)
+(setq compilation-skip-threshold 2) ; make M-n and M-p skip warnings
+(random 3) ; return a random number between 0 and 2
+(set-buffer "*scratch*")
+(kill-buffer "*scratch*")
+(directory-files "/usr/share/emacs/site-lisp/" nil "\\.el$")
+(count-lines (window-start) (window-end))
+(if (null (get-buffer-process (current-buffer))) (kill-buffer))
+(setenv "PATH" (concat (getenv "HOME") "/bin:" (getenv "PATH")))
+(delete-region 1 10)
+(file-directory-p "/bin")
+(switch-to-buffer (generate-new-buffer "temp"))
+(if (not (one-window-p) (delete-window)))
+(mapc 'kill-buffer (delq (current-buffer) (buffer-list))) ; kill other buffers
+(insert-file-contents "~/file.txt")
+(thing-at-point 'word)
+(thing-at-point 'symbol)
+(bounds-of-thing-at-point 'line)
+(rename-file "/tmp/a" "/tmp/b")
+(delete-char 5) ; delete five characters forward
+(defmacro comment (rest body) nil)
+(kill-new (buffer-file-name)) ; save the name of the buffer to the kill ring
+(browse-url (concat "file://" (buffer-file-name)))
+(propertize "a" 'face 'italic)
+(dotimes (i 20) (insert (format "%d\n" (1+ i))))
+(setq buffer-read-only t)
+(expand-file-name (concat user-emacs-directory "elisp"))
+(format-kbd-macro (read-key-sequence "key? " nil t))
+(setq mode-line-format nil) ; hide the mode line
+(skip-chars-forward "\n ") ; move to the first character that is not space or \n
+(region-active-p) ; t if transient mark mode is enabled and the mark is active
+(manual-entry (current-word)) ; open a man page for the word near the point
+(let (minibuffer-allow-text-properties) (read-from-minibuffer "Prompt: "))
+(file-name-directory (buffer-file-name))
+(setq echo-keystrokes 0.1) ; echo unfinished commands after 0.1 seconds
+(set-window-text-height (selected-window) 7)
+(text-scale-increase 5)
+(defun xor (a b) (if a (not b) b))
+(select-window (split-window-horizontally))
+(setq history-add-new-input nil) ; don't add elements to minibuffer history
+(read-from-minibuffer "Prompt: ")
+(read-buffer "Buffer: ")
+(read-command "Eval: ")
+(if (looking-at "//") (delete-char 2))
+(string-equal system-type "gnu/linux")
+(insert-file-contents "file.txt")
+(if (region-active-p) (region-beginning) (line-beginning-position))
+(kill-buffer (current-buffer))
+(switch-to-buffer-other-window "*info*")
+(directory-files "/usr/local") ; names of files and directories
+(directory-files "/usr/local" t) ; absolute paths of files and directories
+(if (> (length (window-list)) 1) (delete-other-windows) (bury-buffer))
+(shell-command-on-region (mark) (point) "python -mjson.tool" (buffer-name) t)))
+(if (and (buffer-modified-p) (buffer-file-name)) (write-file (buffer-file-name))
+(interactive "p") ; prefix arg converted to number
+(interactive "P") ; prefix arg in raw form
+(delete-indentation t) ; delete indentation forward
+(set-frame-parameter nil 'alpha '(85 50))
+(find-alternate-file (concat "/sudo::" (buffer-file-name)))
+(set-frame-parameter (selected-frame) 'fullscreen 'fullboth)
+(floor (* 0.6 (x-display-pixel-width)))
+(>= emacs-major-version 24)
+(kill-region (point) (point-max)) ; delete to the end of a buffer
+(executable-interpret (buffer-file-name))
+(find-function 'f) ; jump to the definition of f
+(symbol-file 'f) ; the file where f is defined
+(if (window-system) (set-frame-height (selected-frame 60))
+(setq message-log-max nil) ; don't add any messages to the messages buffer
+(message "%s" (propertize "message" 'face '(:foreground "red")))
+(read-passwd "Password: ")
+(delq nil (mapcar 'buffer-file-name (buffer-list))) ; files of buffers
+(mapconcat 'identity (delq nil (mapcar 'buffer-file-name (buffer-list))) "\n")
+(set-frame-width (selected-frame) 100)
+(unless (bolp) (beginning-of-line))
+(and (bolp) (eolp)) ; test if the point is on an empty line
+(skip-chars-backward " \t")
+(region-active-p) ; t if the region is active
+(use-region-p) ; t if the region is active and not empty
+(equal last-input-event 'backspace)
+(get-char-property (point) 'face))
+(indent-region (point-min) (point-max)) ; reindent a buffer
+(eq major-mode 'Info-mode)
+(window-buffer) ; buffer of the current window
+(window-buffer (second (window-list)))
+(other-window 1 nil) ; select the next window in the current frame
+(other-window -1 t) ; select the previous window including all frames
+(get-buffer-window "*scratch*") ; the first window that displays *scratch*
+(add-hook 'after-save-hook 'check-parens)
+(select-window (previous-window))
+(global-unset-key "\C-x\C-c")
+(shell-command-on-region (region-beginning) (region-end) "pbcopy")
+(define-obsolete-function-alias f1 f2) ; (defalias f1 f2) (make-obsolete f1)
+(ido-completing-read "Prompt: " '("aa" "bb"))
+(equal (tty-type) "xterm-vt220")
+(setq split-height-threshold nil split-width-threshold 0)
+(setq message-log-max t) ; don't truncate *Messages*
+(if (window-system) (set-frame-height (selected-frame) 60))
+(set-face-attribute 'default nil :height 120)
+(display-graphic-p) ; non-nil if DISPLAY is a graphic display
+(setq whitespace-style '(face)) enables all visualizations that use special faces
+M-x size-indication-mode shows the buffer size in the mode line
+a line number is not shown if a buffer is larger than line-number-display-limit
+(setq display-time-24hr-format t) uses 24 hour clock for display-time-mode
+display-battery-mode uses battery-mode-line-format
+(set-face-attribute 'mode-line nil :box nil) removes the borders
+(setq mode-line-in-non-selected-windows nil) disables using mode-line-inactive
+Emacs uses the very visible cursor in text terminals by default
+(setq visible-cursor nil) makes Emacs use the visible cursor in text terminals
+(setq cursor-in-non-selected-windows nil) hides cursors in non-selected windows
+M-x toggle-truncate-lines changes the truncate-lines variable locally
+visual-line-mode changes C-a to beginning-of-visual-line
+(setq visible-bell t) uses a visible bell instead of an audible bell
+(setq display-hourglass nil) disables changing the pointer to an hourglass
+hourglass-delay is 1 by default
+(setq make-pointer-invisible nil) disables hiding the pointer when typing
+underline-minimum-offset is 1 by default
+(setq isearch-lazy-highlight nil) disables highlighting other matches
+M-e is isearch-edit-string in isearch-mode-map
+(setq search-whitespace-regexp nil) disables lax space matching for isearch
+M-<TAB> is isearch-complete in isearch-mode-map
+C-w yanks a word, C-M-w deletes a character, and M-s C-e yanks a line
+(setq isearch-allow-scroll t) makes for example C-v and M-v not exit isearch
+C-r searches in minibuffer history when the minibuffer is active
+M-s w is isearch-toggle-word when incremental search is active
+M-s w is isearch-forward-word when incremental search is not active
+M-r is isearch-toggle-regexp
+\= matches the empty string at the point
+\_< matches the beginning of a symbol
+\_> matches the end of a symbol
+\s. matches punctuation characters
+\S- matches non-whitespace characters
+\S. matches non-punctuation characters
+(setq case-fold-search nil) enables considering case
+(setq tags-case-fold-search nil) makes tags operations consider case
+(setq replace-lax-whitespace t) enables lax space matching for query-replace
+\# is 0 during the first replacement, 1 during the second replacement, and so on
+\? prompts for a replacement
+\#& is the whole match converted to a number
+\#1 is the first backreference converted to a number
+M-x multi-isearch-buffers searches in multiple buffers
+M-x occur shows matching lines in a new buffer
+M-3 M-x occurr shows three lines of context before and after each matching line
+pressing RET over a line in an occur buffer shows the line in the original buffer
+C-x ` selects the next occurrence in an occur buffer
+pressing e in an occur buffer enters occur-edit-mode
+C-c C-c exits occur-edit-mode
+list-matching-lines is a synonym for occur
+M-s o runs occur when an incremental search is active
+M-x multi-occur searches in multiple buffers
+M-x multi-occur-in-matching-buffers searches in buffers matching a regexp
+M-x how-many shows the number of matches for a regexp after the point
+M-x undo-only never redoes changes
+undo-limit is 80000 by default and undo-strong-limit is 120000 by default
+undo-outer-limit is 120000000 by default
+C-M-t is transpose-sexps
+M-x ispell applies to region or buffer
+M-x ispell-buffer applies to a buffer and M-x ispell-region applies to a region
+M-x flyspell-prog-mode enables flyspell-mode only for comments and strings
+C-u <F3> adds keys to the last macro after executing it
+C-u C-u <F3> adds keys to the last macro
+(setq kmacro-execute-before-append nil) makes C-u <F3> not execute a macro
+C-x C-k r is apply-macro-to-region-lines
+<F3> is kmacro-start-macro-or-insert-counter
+<F4> is kmacro-end-or-call-macro
+C-x ( is kmacro-start-macro
+C-x ) is kmacro-end-macro
+C-x e is kmacro-end-and-call-macro
+M-4 C-x ) executes a macro four times
+C-x C-k C-n is kmacro-cycle-ring-next
+C-x C-k C-p is kmacro-cycle-ring-previous
+C-x C-k C-i inserts a counter starting from 1
+C-u C-x C-k C-i inserts a counter starting from 0
+C-x C-k C-f specifies a format for the counter
+M-5 C-x C-k C-a adds 5 to the counter
+C-u C-x C-k C-a resets the counter
+C-x q is kbd-macro-query
+C-x C-k b gives a temporary keybinding for the last defined keyboard macro
+C-x C-k b 4 binds the last macro to C-x C-k 4
+C-x C-k n NAME ret gives a command name for the last keyboard macro
+M-x insert-kdb-macro RET NAME RET inserts Lisp code for the NAME macro
+C-x C-k C-e (kmacro-edit-macro) edits the last defined keyboard macro
+C-x C-k l (kmacro-edit-lossage) edits the last 300 keystrokes as a macro
+C-x C-k SPC is kmacro-step-edit-macro
+(setq insert-default-directory nil) disables inserting default-directory
+large-file-warning-threshold is 10000000 by default
+C-x C-v (find-alternate-file) kills the current buffer and visits a new file
+(setq find-file-run-dired nil) disables invoking dired when visiting a directory
+M-x find-file-literally disables format conversion and automatic uncompression
+M-x find-file-literally ignores require-final-newline
+find-file-not-found-functions is run before find-file-hook
+M-~ is not-modified
+C-u M-~ marks the current buffer as changed
+M-x set-visited-file-name changes the name that is used when saving the buffer
+C-u C-x C-s backs up the buffer on next save
+C-u C-u C-x C-s saves the previous file as a backup and saves the buffer
+M-x auto-revert-mode enables auto revert for the current buffer
+(setq global-auto-revert-non-file-buffers t) enables auto revert for all buffers
+the buffer menu reverts automatically every auto-revert-interval seconds
+(setq auto-save-visited-file-name t) performs auto-save in place
+(setq delete-auto-save-files nil) disables deleting auto-save files on save
+auto-save-interval is 300 by default and auto-save-timeout is 30 by default
+M-x recover-file restores an auto-save file
+M-x recover-session recovers auto-save files from the previous session
+(setq find-file-visit-truename t) enables resolving symlinks when visiting files
+C-u C-x C-d shows a verbose directory listing
+list-directory-brief-switches is -CF by default
+list-directory-verbose-switches is -l by default
+(setq delete-by-moving-to-trash t) makes M-x delete-file use the trash
+diff-switches is -c by default
+M-n is diff-hunk-next in diff-mode
+M-x make-symbolic-link creates a symbolic link
+M-x add-name-to-file creates a hard link
+chmod is an alias for set-file-modes
+M-x chmod changes the mode of a file
+e extracts a file in tar-mode
+v opens a file in view mode in tar-mode
+o opens a file in a new window in tar-mode
+(setq ange-ftp-make-backup-files t) enables backups for files accessed via ftp
+C-<tab> completes from the file name cache in the minibuffer
+M-x file-cache-add-directory RET /dir RET adds files in /dir to the file cache
+M-x recentf-save-list saves the recentf-file-list to a file
+(filesets-init) enables filesets
+M-x filesets-add-buffer RET NAME RET adds a buffer to the fileset NAME
+M-x filesets-open visits all files in a fileset
+C-u M-g M-g goes to a line in the previous buffer
+M-x view-buffer opens a buffer in view-mode
+M-x kill-matching-buffers kills buffers that match a regexp
+M-x clean-buffer-list kills buffers that have not been visited in three days
+midnight-hook includes clean-buffer-list by default
+C-x 4 c is clone-indirect-buffer-other-window
+truncate-partial-width-windows is 50 by default
+C-x 4 C-o is iswitchb-display-buffer
+C-x 4 C-o opens a buffer in another window without selecting the window
+C-x 4 0 is kill-buffer-and-window
+C-x ^ (enlarge-window) makes a window taller horizontally
+C-x - is shrink-window-if-larger-than-buffer
+C-x + (balance-windows) makes windows the same width or height
+buffers in same-window-buffer-names are always displayed in the selected window
+(setq pop-up-frames t) makes display-buffer create new frames
+M-x follow-mode makes windows display adjacent sections of the same buffer
+(windmove-default-keybindings) binds for example <S-right> to windmove-right
+C-x 5 1 is delete-other-frames
+C-x 5 2 (make-frame-command) creates a frame and switches to it
+M-x creates a speedbar associated with the current frame
+(setq use-dialog-box nil) makes mouse commands not use graphical dialogs
+enable-multibyte-characters is non-nil in multibyte buffers
+M-x toggle-enable-multibyte-characters disables multibyte support in a buffer
+C-h L is describe-language-environment
+C-h L UTF RET describes the UTF-8 language environment
+exit-language-environment-hook is run before set-language-environment-hook
+C-h C is describe-coding-system
+C-h C utf-8-unix RET  describes the utf-8-unix coding system
+the raw-text coding system sets enable-multibyte-characters to nil
+C-x RET r is revert-buffer-with-coding-system
+C-x RET f dos RET saves a file with CRLF line endings
+emacs -fn fontset-standard uses the standard fontset instead of the default fontset
+standard-fontset-spec is -*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard
+the japanese-jisx0208 charset has the highest priority in the Japanese language environment
+C-u C-x = shows the character set of a character
+(setq-default major-mode 'text-mode) uses text-mode instead of fundamental-mode
+-*-Lisp-*- is equivalent to -*-mode:Lisp;-*-
+interpreter-mode-alist contains elements like ("bash" . sh-mode)
+auto-mode-alist contains elements like ("\\.rb\\'" . ruby-mode) and ("\\.bz2\\'" nil jka-compr)
+magic-fallback-mode-alist contains elements like ("<\\?xml " . xml-mode)
+M-x indent-relative indents a line to have the same indentation level as the previous non-blank line
+C-M-o is split-line
+(setq indent-tabs-mode nil) makes indentation commands use spaces
+M-x untabify converts tabs to spaces based on tab-width
+indent-for-tab-command is t by default
+(setq indent-for-tab-command t) makes tab attempt completion if the current line is already indented
+(setq indent-for-tab-command nil) makes tab indent only at the left margin and the indentation
+C-x [ is backward-page, C-x C-p is mark-page, and C-x l is count-lines-page
+C-x f is set-fill-column
+M-o M-s (center-line) centers a line within the current fill column
+breaking a line is disabled if a function in fill-nobreak-predicate returns non-nil
+C-x . is set-fill-prefix
+M-x fill-individual-paragraphs fills a region considering changes in indentation as paragraph boundaries
+lines that don't start with the fill prefix are considered to start a paragraph
+M-<TAB> is ispell-complete-word in text mode
+entering outline mode runs text-mode-hook followed by outline-mode-hook
+outline-mde uses C-c as a prefix and outline-minor-mode uses C-c @ as a prefix
+C-c C-n is outline-next-visible-heading in outline-mode
+C-c C-f is outline-forward-same-level and C-c C-u is outline-up-heading in outline-mode
+C-c C-c is hide-entry and C-c C-e is show-entry in outline mode
+M-x reveal-mode enables automatically unhiding text near point in outline mode
+(eval-after-load "outline" '(require 'foldout)) adds folding commands to outline mode
+foldout binds C-c C-z to foldout-zoom-subtree in outline mode
+C-c C-t is org-todo, C-c C-s is org-schedule, and C-c C-d is org-deadline
+tex-default-mode is latex-mode by default
+latex-mode, plain-tex-mode, and doctex-mode are child modes of tex-mode
+C-c { (tex-insert-braces) inserts braces and positions the point between them in tex-mode
+C-c } (up-list) moves to the next closing brace in tex-mode
+C-c C-o (tex-latex-block) inserts \begin and \end in latex-mode
+C-c C-e is tex-close-latex-block in latex-mode
+latex-electric-env-pair-mode inserts \end tags automatically
+C-c C-b is tex-buffer, C-c C-r is tex-region, and C-c C-f is tex-file
+C-c C-p is tex-print
+C-c C-v (tex-view) shows the output of a command like tex-buffer in an external program
+C-c C-v uses tex-dvi-view-command and C-c C-p uses tex-dvi-print-command
+C-c C-l scrolls a *tex-shell* buffer so that the last line is visible
+C-c C-k is tex-kill-job
+the header used by C-c C-r starts with \documentclass or \documentstyle in latex mode
+tex-start-commands is "\\nonstopmode\\input" by default
+C-c <TAB> (tex-bibtex-file) runs tex-bibtex-command to produce a .bbl file
+C-c C-n (sgml-name-char) inserts a named entity in sgml mode and HTML mode
+C-c C-t (sgml-tag) inserts an opening and closing tag
+C-c / is sgml-close-tag
+C-c C-f is sgml-skip-tag-forward and C-c C-d is sgml-delete-tag
+2C-two-columns is bound to <F2> 2 and C-x 6 2
+C-M-h is c-mark-function in C mode
+M-x imenu jumps to a definition
+M-x indent-code-rigidly indents code but not comments or strings
+C-M-q is indent-pp-sexp in Lisp mode and c-indent-exp in C mode
+C-c C-q is c-indent-defun in C mode
+<TAB> is c-indent-command in C mode
+c-tab-always-indent is t by default
+C-c . (c-set-style) changes indentation style in C mode
+C-M-<SPC> is mark-sexp
+C-M-n is forward-list, and C-M-p is backward-list
+C-M-u is backward-up-list and C-M-d is down-list
+blink-matching-delay is 1 by default
+C-u M-; (comment-kill) kills a comment on the current line
+C-x ; is comment-set-column
+comment-region is bound to C-c C-c in C-like modes
+c-indent-comment-alist changes the behavior of M-;
+C-h S is info-lookup-symbol
+C-c @ C-h is hs-hide-block and C-c @ C-s is hs-show-block
+C-c @ C-c is hs-toggle-hiding
+C-c @ C-M-h is hs-hide-all and C-c @ C-M-s is hs-show-all
+C-c @ C-l is hs-hide-level
+(setq hs-hide-comments-when-hiding-all t) makes hs-hide-all also hide comments
+hs-isearch-open is set to code by default
+C-M-i is completion-at-point in many programming modes
+completion-at-point uses semantic parser data for completion when semantic mode is enabled
+M-x glasses-mode adds underscores to camel case words
+M-x semantic-mode makes some modes use a semantic parser instead of syntax tables
+semantic mode understands C, C++, Scheme, JavaScript, Java, HTML, and Make
+C-c , j is semantic-complete-jump-local and C-c , J is semantic-complete-jump
+C-c , <SPC> (semantic-complete-analyze-inline) shows a list of completions for a symbol at point
+C-c , l (semantic-analyze-possible-completions) shows a list of completions in another window
+C-c C-l is c-toggle-electric-state and C-c C-a is c-toggle-auto-newline
+C-c <DEL> (c-hungry-delete-backwards) deletes whitespace before the point
+C-c C-d (c-hungry-delete-forward) deletes whitespace after the point
+(subword-mode 1) enables treating uppercase characters in camelcase identifiers as word boundaries
+C-c C-s (c-show-syntactic-information) shows syntactic information abount the current line
+cwarn-mode highlights for example assignments inside expressions and semicolons after if, for, and while
+M-x ff-find-related-file finds a corresponding header or source file
+M-x recompile invokes a compiler with the same command as the last invocation of M-x compile
+the default compile-command is make -k where -k continues after errors
+M-g n is next-error and M-g p is previous-error
+M-} is compilation-next-file and M-{ is compilation-previous-file in compilation mode
+C-c C-f toggles next-error-follow-minor-mode in compilation mode
+compilation-skip-threshold is set to 1 by default
+(setq compilation-skip-threshold 2) makes next-error and previous-error also skip warnings
+compilation-error-regexp-alist is used to match errors
+find-grep is an alias for grep-find
+(setq grep-highlight-matches t) enables --color
+M-x lgrep is like M-x grep but it uses prompts to construct the grep command
+M-x rgrep is like M-x grep-find but it uses prompts to construct the grep command
+grep-files-aliases makes for example ch match *.[ch]
+grep-find-ignored-directories is used by rgrep but not grep-find
+grep-find-ignored-directories includes for example .git and .svn by default

File osx/

+## js
+    'AA'.toLowerCase() // 'aa'
+    'abcd'.indexOf('bc')!=-1 // true
+    'aa'.replace('a','b') // 'ba'
+    'aa'.replace(/a/g,'b') // 'bb'
+    'abc'.charAt(2) // 'c'
+    'abc'.slice(-2) // 'bc'
+    'aa'<'ab' // true
+    ' a '.trim() // 'a'
+    ' a '.trimRight() // ' a'
+    s='some string';s.charAt(0).toUpperCase()+s.slice(1) // 'Some string'
+    String.fromCharCode(65) // 'A'
+    'string'.indexOf('str')==0 // true
+    s='string';end='ing';s.indexOf(end,s.length-end.length)!=-1 // true
+    'bca'.split('').sort.join('') // 'abc'
+    [1,2].indexOf(2) // 1
+    a=[1,2];a.push(3);a // [1, 2, 3]
+    a=[1,2,3];a.pop();a // [1, 2]
+    a=[1,2,3];a.shift();a // [2, 3]
+    a=[3,4];a.unshift(1,2);a // [1, 2, 3, 4]
+    [1,2].concat(3,4) // [1, 2, 3, 4]
+    [1,2,3,4,5].slice(2,4) // [3, 4]
+    a=['a','b','d'];a.splice(2,0,'c');a // ['a', 'b', 'c', 'd']
+    a=[];for(i=0;i<=3;i++){a.push(i)};a // [0, 1, 2, 3]
+    a=['a','b','x','x','e'];a.splice(2,2);a // ['a', 'b', 'e']
+    a=['a','b','x','x','e'];a.splice(2,2,'c','d');a // ['a', 'b', 'c', 'd', 'e']
+    [2,3,1].sort().reverse() // [3, 2, 1]
+    'abab'.lastIndexOf('b') // 3
+    a=[1,2,3,4];i=a.indexOf(3);if(i>-1)a.splice(i,1);a // [1, 2, 4]
+    a=[0,0];a[5]=0;Object.keys(a) // ['0', '1', '5']
+    a=[0,0];a[5]=0;a.length // 6
+    ['a','b'].join('') // 'ab'
+    ['a','b'].join() // 'a,b'
+    ['11','2'].sort(parseInt) // ['2', '11']
+    ['--','---','-'].sort(function(x,y){return x.length>y.length}) // ['-', '--', '---']
+    a=[1,2];2 in a // true
+    o={};;o // {foo: 1}
+    Object.keys({a:1,b:2}).length # 2
+    o={a:1};'a' in o // true
+    Math.abs(-2) // 2
+    Math.cos(Math.PI) // -1
+    Math.log(Math.exp(3)) // 3
+    Math.log(Math.pow(Math.E,3)) // 3
+    Math.max(1,2) // 2
+    Math.round(Math.pow(125,(1.0/3))) // 5
+    '0089'.replace(/^0+/,'') // '89'
+    '0a1b'.match(/\d(?=a)/) // ['0']
+    '0a1b'.match(/\d(?!a)/) // ['1']
+    ' \t a '.replace(/^\s+|\s+$/g,'') // 'a'
+    new RegExp('a+','ig') // /a+/ig
+    var x;typeof x // 'undefined'
+    0=='' // true
+    0=='0' // true
+    null==undefined // true
+    false==undefined // false
+    false==null // false
+    typeof(new String('a')) // 'object'
+    typeof('a') // 'string'
+    eval('2+2') // 4
+    eval(new String('2+2')) // {'0': '2', '1': '+', '2': '2'}
+    eval((new String('2+2')).valueOf()) // 4
+    [4,9].map(Math.sqrt) // [2, 3]
+    ['1','2'].map(function(x){return parseInt(x)}) // [1, 2]
+    [1,'2',3].filter(function(x){return typeof x=='number'}) // [1, 3]
+    [1,'2',3].some(isNumber) // true
+    [1,'2',3].every(isNumber) // false
+    [1,2,3,4].reduce(function(x,y){return x*y}) // 24
+    [[0,1],[2,3]].reduce(function(x,y){return x.concat(y)} // [0, 1, 2, 3]
+    Array.apply(null,{length:4}).map(,Number) // [0, 1, 2, 3]
+"ab",function(x){return x.charCodeAt(0)}) // [97, 98]
+    a=[1,2,3,4];a.reduce(function(x,y){return x+y})*1.0/a.length // 2.5
+    JSON.parse('{"a":1}') // {a: 1}
+    JSON.stringify({a:1}) // '{"a":1}'
+    Date.UTC(2013,12,31,23,59,59) // 1391212799000
+    ('000'+789).slice(-4) // '0789'
+    (1e4+789+'').substr(1) // '0789'
+    encodeURIComponent('H & M') // 'H%20%26%20M'
+    decodeURIComponent('H%20%26%20M') // 'H & M'
+    function f(){return,0)};f(1,2) // [1, 2]
+    p=1;a=[1,2,3,4];for(i=0;i<a.length;i++){p*=a[i]};p // 24
+    new Array(5+1).join('x') // 'xxxxx'
+    (new Number(33)).toString(2) // '100001'
+    [2,3].map(x=>x*x) // [4, 9]
+## readinglist
+    #emacs
+    #osx
+    #other
+    #shell
+## ruby
+ # [nil, nil]
+, 0) # [0, 0]
+, # [[nil, nil], [nil, nil]]
+, # [{}, {}]
+    n = [0, 2]; [7, 8, 9].values_at(*n) # [7, 9]
+    %w(a b).repeated_permutation(2).map(&:join) # ["aa", "ab", "ba", "bb"]
+    [1, 2].repeated_combination(2).to_a # [[1, 1], [1, 2], [2, 2]]
+    [[1, 2], [3, 4], [5, 6]].transpose[0] # [1, 3, 5]
+    [1, 2] & [1] # [1]
+    [3, 1] | [1, 2] # [3, 1, 2]
+    [1, 2, 3, 4, 5].each_slice(2).to_a # [[1, 2], [3, 4], [5]]
+    a = [1, 2, 3, 4, 5]; a.shift(2); a # [3, 4, 5]
+    a = [2, 3]; a.unshift(1); a # [1, 2, 3]
+    [1, nil].compact # [1]
+    [[0, 0], [0, 1], [1, 2]].uniq { |e| e[0] } # [[0, 0], [1, 2]]
+    [1, 2] * 2 # [1, 2, 1, 2]
+    %w(a b) * ", " # "a, b"
+    a = [1, 2, 3, 4]; a.reduce(:+).to_f / a.size # 2.5
+    a = [1, 2, 3]; a.delete_at(1); a # [1, 3]
+    [[1], [2, 3]].flatten # [1, 2, 3]
+    %w(aa bb).grep(/^a/) # ["aa"]
+    [1.0, "two", 3].grep(Fixnum) # [3]
+    [1, 2].map(&:to_s) # ["1", "2"]
+    "1 2" # [1, 2]
+    [" aa", "bb", " cc"].partition { |x| x =~ /^ / } # [[" aa", " cc"], ["bb"]]
+    ["11 a", "2 b"].sort_by { |x| x[/^\d+/].to_i }
+    [1, 2, 3, 4, 5].last(2) # [4, 5]
+    require "pp"; pp hash # pretty print a hash
+    {a: 1}.key(1) # :a
+    {a: 1}.invert # {1=>:a}
+    Hash[1, 2, 3, 4] # {1=>2, 3=>4}
+    a = [1, 2, 3, 4]; Hash[*a] # {1=>2, 3=>4}
+    Hash[{a: 11, b: 1, c: 2}.sort_by { |k, v| v.to_i }] # {:b=>1, :c=>2, :a=>11}
+    {:a=>1}.merge({:b=>2}) # {:a=>1, :b=>2}
+    h =; h[:a] += 5; h # {:a=>5}
+    h = { |x, k| x[k] = [] }; h[:a] << 1; h[:a] << 2; h # {:a=>[1, 2]}
+    h =; [2, 2, 3, 4, 4].each { |v| h[v] += 1 }; h # {2=>2, 3=>1, 4=>2}
+    h = {}; %w(aa bb).each { |v| (h["k"] ||= []) << v }; h # {"k"=>["aa", "bb"]}
+    h = {}; %w(aa bb).each { |v| (h["k"] ||= []) << v }; h # {"k"=>"aabb"}
+    {"x"=>1,"y"=>2}.flatten # ["x", 1, "y", 2]
+    {"x":1}.has_value?(1) # true
+    {"x"=>1,"y"=>2,"z"=>2}.assoc(2) # nil
+    {"x"=>1,"y"=>2,"z"=>2}.rassoc(2) # ["y", 2]
+    Hash[[:x, :y].zip([1, 2])] # {:x=>1, :y=>2}
+    "\u{1234}".size # 1 in 1.9 and 2 in 1.8
+    ["1234".hex].pack("U").scan(/./mu).size # 1 in both 1.9 and 1.8
+    "z".ord.to_s(16) # "7a" (1.9)
+    "%x" % "z".unpack("U*")[0] # "7a" (1.8)
+    "abb".index("b") # 1
+    "abb".rindex("b") # 2
+    "xxy".count("x") # 2
+    "aa".rjust(4) # "  aa"
+    "aa".center(5, "-") # "-aa--"
+    s = "abb"; s["bb"] = "c"; s # "ac"
+    s = "ab"; s["cd"] # nil
+    "az".next # "ba"
+    "a\t".split("\t") # ["a"]
+    "a\t".split("\t", 2) # ["a", ""]
+    "xaxbxx".split("x") # ["", "a", "b"]
+    "xaxbxx".scan(/(?<=(?:x|^))[^x]*/) # ["", "a", "b", "", ""]
+    "\ta\n  b".split # ["a", "b"]
+    "a\u{5b57}".codepoints.to_a # [97, 23383]
+    "abc".tr("ac", "AC") # "AbC"
+    "a\nb\n" # ["a", "b"]
+    "<b>aa</b>"[/<b>(.*?)<\/b>/, 1] # "aa"
+    [1, 2, 3, 4, 5].take(2) # [1, 2]
+    [1, 2, 3, 4, 5].drop(2) # [3, 4, 5]
+    [2, 3, 4].reduce(:+) # 9
+    [2, 3, 4].reduce(:*) # 24
+    [1, 3].all? { |x| x.odd? } # true
+    enum = [1, 2].each; p # 1
+    enum = { |x| x << 1 }; p # 1
+    enum = "x".enum_for(:each_byte); enum.first # 120
+    p [1, 2].cycle.take(5) # [1, 2, 1, 2, 1]
+ { |n| "file_#{n}" } # ["file_0", "file_1", "file_2"]
+    %w(x y z).select.with_index { |e, i| i.even? } # ["x", "z"]
+    (1..6).group_by { |i| i % 3 } # {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
+    (0.2..0.6).step(0.2).to_a # [0.2, 0.4, 0.6]
+    ["--", "---"].reduce(0) { |sum, x| sum + x.length } # 5
+ { [*"a".."z", *"0".."9"].sample }.join
+    "%3i" % 9 # "  9"
+    "%03i" % 9 # "009"
+    "%-3s" % "a" # "  a"
+    "%02x" % 10 # "0a"
+    "%b" % 6 # 110
+    Math.log(Math::E**3) # 3.0
+    -3.abs # 3
+    [1, 2].min # 1
+    (1..6).reduce(:*) # 720
+    a.reduce(:+).to_f / a.size # arithmetic mean
+    a.reduce(:*).to_f ** (1.0 / a.size) # geometric mean
+    a.size.to_f / { |n| 1.0 / n }.reduce(:+) # harmonic mean
+    ( { |n| n ** 2 }.reduce(:+).to_f / a.size) ** 0.5 # RMS
+    (125 ** (1.0 / 3)).round # 5 (cube root)
+ { |x| x**2 % 5 == 0 }.take(10).reduce(:+) # 275
+    File.write("file", "text\n") # 1.9.3 and later
+"file", "w") { |f| f.puts("text") } # 1.8
+"file", "a") { |f| f.puts("text") } # append
+    Dir.home # an alternative to ENV["HOME"] in 1.9 and later
+    FileUtils.rm(Dir["*.html"])
+    FileUtils.mkdir_p("a/b")
+    File.basename("/folder/file.txt", ".txt") # "file"
+    File.basename("file.txt", ".*") # "file"
+"utf16.txt", "r:UTF-16:UTF-8")
+    Dir["*.txt"].map { |f| File.size(f) }.reduce(:+)
+    Dir["**/*.txt"].each { |f| IO.write(f,"aa", "bb")) }
+    Dir.chdir(File.dirname(__FILE__)) # cd to the directory of a script
+    Dir.chdir(__dir__) # cd to the directory of a script (2.0 and later)
+    File.mtime(".").strftime("%F")
+    require "pathname";".").realpath
+    puts Dir["*"].sort_by { |f| File.mtime(f) }[0]
+"file").gets # first line
+    rand(6) + 1 # random number between 1 and 6
+    [1, 2, 3].sample(2) # two random elements
+    rand 2 # 0 or 1
+ { rand(1000) }
+    ("a"..."c") === "b" # true
+    ("a".."c").cover?("bb") # true
+    ("a".."e").step(2).to_a # ["a", "c", "e"]
+    [*0..2] # [0, 1, 2]
+    "<b>aa</b>" =~ /(?<=<b>)(.*)(?=<\/b>)/; $& # "aa"
+    "aabc" =~ /b/; $` # "aa"
+    /b/.match("aabc").pre_match # "aa"
+    "aa,bb,cc".gsub(/(?<=,|^)(.*?)(?=,|$)/, "a") # "a,a,a"
+    "some string".gsub(/\b\w/) { $&.upcase } # "Some String"
+"pattern"), "i") # /pattern/i
+    "xyz".gsub(/[xyz]/, "x" => 1, "z" => 3) # "1y3"
+    system("echo", "a")
+    IO.popen(["echo", "a"]).read
+    IO.popen("tr y z", "w") { |io| io.puts "xyz" }
+    IO.popen(["tr", "y", "z"], "w") { |io| io.puts "xyz" }
+    IO.popen("tr y z", "r+") { |io| io.puts("xyz"); io.close_write; }
+ # seconds since epoch
+    "%.3f" % # time with milliseconds
+    require "date"; Date.parse("2013-09-07").month # 9
+    require "time"; Time.parse("2013-01-13 15:55:13 +0200")
+ # true
+    Nokogiri.XML("<a><b>c</b></a>").css("a b").to_s # "<b>c</b>"
+    x = Nokogiri.XML("<a>1</a><b>2</b>"); x.at_css("a").content = "3"; x.to_xml
+    require "json"; JSON.load('{"a":[1,2],"b":"c"}')
+    JSON.parse("\\u003Cp\\u003E") # "<p>"
+    JSON.pretty_generate(json) # pretty print JSON
+    require "csv";"input.csv").map { |row| row.join("\t") }.join("\n")
+    CSV.parse("1,2\n3,4").map { |row| row.to_csv(:col_sep => ";") }.join
+    IO.readlines("input.tsv").map { |l| l.split("\t").values_at(2, 3) }
+    CSV.parse("field1,field2\n1,a\n2,b\n", headers: true)[0]["field2"] # "a"
+    "a\nb\n".lines # ["a\n", "b\n"] in 2.0 and an enumerator in older versions
+    %i(a b) # [:a, :b] in 2.0
+    __dir__ # a shorter alternative to File.dirname(__FILE__) in 2.0
+    [1, 2] { |x| x * 10 }.take(3).to_a # [10, 20, 10] in 2.0
+    "a\nb\rc\v".gsub(/\R/, "") # "abc" (\R is linebreak in 2.0)
+    raise ArgumentError, "Invalid argument"
+    raise IndexError, "Out of range"
+    $: # $LOAD_PATH
+    abort "error" # an alternative to STDERR.puts "error"; exit 1
+    input = ARGV[0] ||
+    input = if STDIN.stat.size > 0
+\A\n*/m, "").sub(/\n*\Z/m, "\n")
+[^\0-\177]/, "")
+    puts "\033[1mbold\033[mnormal"
+    p x # same as puts x.inspect
+    Symbol.all_symbols
+    trap("EXIT") { exit 0 }
+    require "sqlite3";"file.db").execute("SELECT * FROM data")
+    require "securerandom"; SecureRandom.uuid
+    [8, 4, 4, 4, 14].map { |n| "%#{n}x" % rand(16**n) }.join("-")
+    __END__ # use the rest of the file for the DATA IO object
+    __FILE__ == $0 # test if a script is run directly
+    n = 0; readlines.sort_by { |l| n += 1; [l.split(" ")[0], n] } # stable sort_by
+    Encoding.list # list encoding names
+    IO.readlines("file.tsv").sort_by { |l| l.split("\t")[2] }
+    Dir["*"].sort_by { |f| File.mtime(f) }
+    require "grooveshark";"Artist - Title")
+    File.exists?(f) ? IO.readlines(f).map(&:chomp) : []
+    Kernel.is_a?(Module) # true
+    "a" # "UTF-8"
+    a = [1, 2, 3, 2]; a.max_by { |x| a.count(x) } # 2
+    a = [8, 9, 8]; h =; a.each { |x| h[x] += 1}; h # {8=>2, 9=>1}
+    [1, 2].flat_map { |e| [e, -e] } # [1, -1, 2, -2]
+    [1, 1, 2].count(1) # 2
+    [1, 1, 2].count{ |x| x % 2 == 0} # 1
+    [1, 2].cycle(2).to_a # [1, 2, 1, 2]
+    [1, 2, 3, 4].drop_while { |x| x <= 2 } # [3, 4]
+    (1..4).each_cons(2).to_a # [[1, 2], [2, 3], [3, 4]]
+    (1..4).each_cons(3).to_a # [[1, 2, 3], [2, 3, 4]]
+    require "prime"; Prime.entries(10) # [2, 3, 5, 7]
+    (1..10).find_index(5) # 4
+    (1..10).grep(4..6) # [4, 5, 6]
+    (1..6).group_by { |x| x % 3 } # {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]}
+    IO.constants.include?(:SEEK_SET) # true
+    (1..9).find_all { |x| x % 3 == 0 } # [3, 6, 9]
+    (1..5).take_while { |i| i <= 3 } # [1, 2, 3]
+    %w(aa bb).each_with_index.to_h # {"aa"=>0, "bb"=>1}
+    [1,2].to_enum.first # 1

File osx/

+`d=~/Library/KeyBindings;mkdir $d;echo '{"~x"=(selectParagraph:,cut:);}'>$d/DefaultKeyBinding.dict` makes option-X cut a line
+`brew install bash;echo /usr/local/bin/bash|sudo tee -a /etc/shells;chsh -s /usr/local/bin/bash` installs bash 4
+`defaults write -g AppleFontSmoothing -int 1` makes OS X use a lighter text rendering style
+`defaults write -g NSUserKeyEquivalents -dict-add 'Select Previous Tab' @j 'Select Next Tab' @k` makes command-J and command-K change tabs
+you can make sudo not require a password by running `sudo visudo` and changing `%admin ALL=(ALL) ALL` to `%admin ALL=(ALL) NOPASSWD: ALL`
+`COPYFILE_DISABLE= tar -cf dir.tar dir` creates a tar archive with no AppleDouble files
+`zip -r dir` creates a zip archive with no __MACOSX directory
+`echo setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin|sudo tee -a /etc/launchd.conf` adds /usr/local/bin to PATH after restarting
+`brew install duti;echo net.sourceforge.skim-app.skim .pdf all>~/.duti;duti ~/.duti` sets Skim as the default application for PDF files
+`echo org.gnu.Emacs public.plain-text all>>~/.duti;duti `~/.duti` sets Emacs as the default application for text files with no extension
+`echo org.gnu.Emacs public.unix-executable all>>~/.duti;duti ~/.duti` sets Emacs as the default application for executable scripts
+`osascript -e 'set text item delimiters to linefeed' -e 'tell app "Safari" to (URL of tabs of window 1) as text'` lists the URLs of tabs
+you can see what files would be copied by an installer by pressing command-I in an installer window
+`brew tap homebrew/dupes;brew install coreutils findutils gawk gnu-sed gnu-tar wget homebrew/dupes/grep` installs GNU utilities
+`brew tap phinze/cask;brew install brew-cask;brew cask install sequential` installs Sequential
+`find . \( -iname \*.rar -o -iname \*.zip \) -execdir unar -p '' {} +` extracts archives and skips archives that require a password
+`x() { for f;do case $f in *.dmg)hdiutil attach "$f";;*)unar "$f";;esac;done; }` mounts disk images and extracts archives
+`defaults write -g NSScrollAnimationEnabled -bool false` disables smooth scrolling
+`defaults write -g NSShowAppCentricOpenPanelInsteadOfUntitledFile -bool false` makes TextEdit and Preview not show an open dialog on launch
+`defaults write ShowSidebar -bool false` makes Finder hide the sidebar by default
+`for x in 'On -float 999999999' 'Off -float 0';do defaults write -g NSTextInsertionPointBlinkPeriod$x;done` disables blinking the caret
+`defaults write -g NSAllowContinuousSpellChecking -bool false` disables spell checking in most text views
+`syslog` is an alternative to `cat /var/log/system.log` and `syslog -w` is an alternative to `tail -f /var/log/system.log`
+`open -jga Mail` opens Mail hidden and in the background
+`launchctl unload /System/Library/LaunchAgents/` quits Finder
+`launchctl limit` is an alternative to `ulimit -a;ulimit -Ha`
+`sudo launchctl limit maxfiles 10000` changes the soft and hard limits for the number of open files temporarily for new processes
+`echo limit maxfiles 10000|sudo tee -a /etc/launchd.conf` changes the limits for the number of open files permanently after restarting
+`mdimport -A` shows a list of the kMD attribute identifiers
+`mdfind '"search phrase"'` searches for an exact phrase
+`mdfind` searches for applications
+`mdfind` searches for videos
+`mdfind 'kMDItemFSContentChangeDate>$' -onlyin ~/Library/Caches/Metadata/Safari/History` shows recent Safari history items
+`shis() { mdfind "$*" -onlyin ~/Library/Caches/Metadata/Safari/History|xargs mdls -n kMDItemURL|cut -d\" -f2; }` searches for history items
+`mdls -n kMDItemURL $(mdfind kMDItemURL=** -onlyin ~/Library/Caches/Metadata/Safari/History)` lists Stack Overflow URLs
+`mdfind 'kMDItemDateAdded>$'` shows files added in the last week
+`mdfind 'kMDItemAuthors="Artist Name"' -onlyin ~/Music` searches by artist
+`mdfind 'kMDItemContentType=*' -onlyin .` lists all indexed files
+`mdfind 'kMDItemFSSize>1e8'` finds files over 100 MB
+`touch /tmp/a.mkv;mdls -n kMDItemContentTypeTree /tmp/a.mkv` shows the UTI and parent UTIs for the mkv extension
+`mdfind -0 -onlyin ~/Music 'kMDItemFSName=*.mp3&&kMDItemAudioBitRate<=192000'|xargs -0 mdls -n kMDItemAlbum|sort -u` finds low quality albums
+`sudo mdutil -E /` erases the Spotlight index on the startup volume and `sudo mdutil -Ea` erases the Spotlight indexes on all volumes
+`mdfind` finds files excluded from Time Machine backups
+you can see if files have been opened before by running `mdls -n kMDItemFSName -n kMDItemLastUsedDate *`
+`mdls -n kMDItemFSName -n kMDItemWhereFroms *` shows the URLs that files were downloaded from
+`mdfind -s example` is an alternative to `mdfind "$(PlistBuddy -c 'Print RawQuery' ~/Library/Saved\ Searches/example.savedSearch)"`
+`mdfind kMDItemUserTags=*` finds files with tags
+`sudo tmutil disablelocal` disables local Time Machine snapshots
+`tmutil status` shows if a backup is in progress
+`sudo ln -s "$(tmutil machinedirectory)" /tm;sudo chflags -h hidden /tm` creates a symlink for the machine directory
+`tmutil compare ~/Notes/ "$(tmutil machinedirectory)"/Latest/*/Users/$USER/Notes/` shows changes to ~/Notes/ since the last backup
+`tmutil calculatedrift "$(tmutil machinedirectory)"` shows the size of changes between backups
+`screencapture -ic` is an alternative to control-shift-command-4
+`screencapture -l$(osascript -e 'tell app "Safari" to id of window 1') a.png` saves a screenshot of the frontmost Safari window
+`security find-internet-password -s -w` shows a Google account password
+`find ~/Library/Scripts -name \*.scpt|parallel osadecompile {}\>{.}.applescript\;rm {}` replaces .scpt files with .applescript files
+`quit() { osascript -e 'on run {a}' -e 'quit app a' -e end -- "$1"; }` quits an application
+`osascript -e 'tell app "Safari" to source of document 1'` shows the source of the current tab
+`osascript -e 'tell app "Safari" to do JavaScript "document.body.innerHTML" in document 1'` shows the generated source of the current tab
+`osascript -e 'tell app "iTunes" to tell current track to artist&" - "&name'` shows the artist and title of the current track
+`osascript -e 'tell app "System Events" to name of processes whose background only is false'` lists open applications
+`osascript -e 'display notification "text" with title "title" subtitle "subtitle"'` is an alternative to terminal-notifier in 10.9 and later
+`find . -Btime -1` or `mdfind 'kMDItemFSCreationDate>$' -onlyin .` finds files created in the last 24 hours
+`mdfind 'kMDItemFSCreationDate>$time.iso(2014-03-16T01:03:08Z)' -onlyin .` is an alternative to `TZ=UTC0 find . -newerBt '2014-03-16 01:03:08'`
+`find . -acl` finds files with ACLs and `find . -xattrname` finds files with resource forks
+`find . -flags +uchg` finds locked files
+`xattr -dr ~/Downloads` unquarantines files
+`xattr -cr .` removes extended attributes for all files in the directory tree
+`ls -l@eO` lists extended attributes, ACLs, and file flags
+`ls -lU` shows creation times in place of modification times
+`cat file/..namedfork/rsrc` shows the resource fork of a file
+`>file/..namedfork/rsrc` or `xattr -d file` deletes a resource fork
+`rsync -E` preserves extended attributes, ACLs, file flags, and resource forks
+`chmod -RN .` removes ACLs recursively
+`find . -xattrname` finds quarantined files
+`touch -m -t $(stat -f %SB -t %Y%m%d%H%M a) a` or `SetFile -m "$(GetFileInfo -d file)" a` sets modification time to creation time
+`find . -name ._\* -delete` deletes ._ files and `dot_clean .` deletes ._ files after converting the metadata stored in them to native formats
+`diskutil eject WD` ejects a disk and `diskutil mountDisk WD` mounts all volumes on a disk
+`diskutil mount Recovery\ HD;hdiutil mount /Volumes/Recovery\ HD/` mounts the recovery partition
+`mkdir /tmp/efi;sudo mount -t msdos /dev/disk0s1 /tmp/efi` mounts the EFI partition
+`osascript -e 'tell app "Finder" to eject'` ejects disks
+`LC_CTYPE=UTF-8 pbcopy` and `LC_CTYPE=UTF-8 pbpaste` preserve non-ASCII characters when the locale variables are unset like in Automator
+`pbcopy<file` copies the contents of a file
+`hdiutil attach file.dmg;sudo installer -pkg /Volumes/Volume/file.pkg -target /` mounts a disk image and installs a package
+`sudo repair_packages --repair --standard-pkgs` is an alternative to repairing permissions from Disk Utility
+`sudo repair_packages --list-standard-pkgs` lists the packages that are checked when verifying or repairing permissions
+`pmset -g assertions` shows if some processes have made power assertions that prevent idle sleep or display sleep
+`pmset -g log` shows a log of power management events
+`pmset sleepnow` puts a Mac to sleep
+`pmset displaysleepnow` puts displays to sleep in 10.9 and later
+`osascript -e 'tell app "System Events" to restart'` restarts and `osascript -e 'tell app "System Events" to log out'` logs out
+`pmset noidle` or `caffeinate` prevents idle sleep
+`textutil -convert html *.rtf` converts rtf to html and `textutil -convert txt *.doc` converts doc to txt
+`pandoc|textutil -inputencoding UTF-8 -format html -convert rtf -stdin -stdout|pbcopy` copies a Markdown file as rich text
+`sudo codesign -fs - /Applications/` replaces the code signature with an ad-hoc signature and disables sandboxing
+`find ~/Library/Containers/ -type f` finds files in TextEdit's sandbox container
+`strings /Applications/|grep -E '^[a-zA-Z0-9.-]{9,99}$'|awk '!a[$0]++'` finds potential defaults keys
+`mdfind kMDItemContentType=public.unix-executable -onlyin /System|xargs strings|grep -iE '^[a-z0-9.-]{9,99}$'` finds potential defaults keys
+`kextstat|grep -v` lists non-Apple kernel extensions
+`sudo defaults write LogoutHook ~/.logouthook` enables running ~/.logouthook on logout
+`for f in *.icns;do sips -s format png "$f" -o "${f%icns}png";done` converts icns to png
+`ls -t1 /var/db/receipts` or `cat /Library/Receipts/InstallHistory.plist` shows a list of installed packages
+`lsbom installer.pkg/Contents/` or `lsbom $(pkgutil --bom installer.pkg)` shows what files would be copied by an installer
+`lsbom /var/db/receipts/` or `pkgutil --info com.adobe.pkg.FlashPlayer` shows files installed by Flash
+`qlmanage -p $(ls -t)` opens a Quick Look window for files sorted by modification time
+`brew install imagesnap;i=1;while :;do imagesnap $((i++)).png;done` saves images from a webcam
+`bid() { osascript -e 'on run {a}' -e 'id of app a' -e end -- "$*"; }` shows the bundle identifier of an application
+`osascript -e 'text returned of (display dialog "" default answer "")'` shows a text dialog
+`pbpaste|sed 's/$/[[slnc 1000]]/'|say` speaks lines of text with a one second pause between each line
+`defaults write NSUserKeyEquivalents -dict-add 'Show Package Contents' @\r` makes command-return show package contents
+`defaults delete persistent-apps;killall Dock` removes all applications from the Dock
+`defaults read ~/Library/Safari/Bookmarks.plist|sed -n 's/^ *URLString = "\(.*\)";/\1/p'` lists the URLs of bookmarks and reading list items
+`$(locate lsregister) -dump` shows the contents of the Launch Services database
+`sudo systemstats` shows for example periods of high I/O and memory activity and what processes have been launched most often
+`sudo powermetrics` shows for example CPU package energy use and processes sorted by a weighted average of package idle wakeups and CPU use
+`lsappinfo listen +becameFrontmost forever` shows when the frontmost application changes
+`lsappinfo launch nofront=true launchandhide=true /Applications/` is an alternative to `open -gja TextEdit`
+`lsappinfo visibleProcessList|cut -d\" -f4` prints the name of the second frontmost application
+`open $(mdls -name kMDItemWhereFroms ~/Downloads/*.download|grep -o 'http[^"]*')` attempts downloading partially downloaded files again
+`sudo find / -name .localized -delete` disables using localized folder names when the OS language is not English
+`defaults write AppleAntiAliasingThreshold -int 999` disables antialiasing in TextEdit
+`find ~/Music \( -name \*.pls -o -name \*.m3u \) -delete` deletes playlist files
+`find ~/Music -name \*.flac -o name \*.ogg|parallel ffmpeg -i {} -aq 1 {.}.mp3\;rm {}` converts FLAC and OGG files to V1 MP3
+`ps -eco comm=` lists the names of processes
+`stat -f '%N %z %Sm %SB %Su' *` shows filename, size in bytes, modification time, creation time, and username
+`find . -exec stat -f '%m %N' {} +|sort|tail -n1` finds the newest file
+`find /usr/local/bin ! -lname '../Cellar/*'` finds non-Homebrew binaries
+`brew list --verbose gawk` lists the files installed by the gawk formula
+`brew install emacs --cocoa` installs
+`brew install webkit2png;webkit2png http://www.example\.com` saves a screenshot of a website
+`brew install ntfs-3g` adds support for writing to NTFS drives
+`git clone github\.com/pufuwozu/toggle-osx-shadows.git;cd toggle-osx-shadows;make;./toggle-osx-shadows` disables shadows
+`man -k dtrace` lists dtrace scripts
+`sudo opensnoop` shows opened files, `sudo execsnoop` shows new processes, and `sudo iosnoop` shows IO events
+`sudo iotop` shows processes with the highest IO use and `sudo kill.d` shows signals sent to processes
+control-option-command-2 sorts by kind and control-option-command-5 sorts by modification date in Finder
+control-option-command-6 sorts by size and control-option-command-7 sorts by tags in Finder
+you can change the default column width for column view windows in Finder by dragging a column while holding option
+you can edit tags with the keyboard in Finder by adding a shortcut for the Tags... menu item from System Preferences
+you can change the columns used for new playlists in iTunes by changing the columns in the view for all songs
+shift-command-H opens iTunes Store and command-1 opens the music library in iTunes
+you can find recently played songs in iTunes by pressing command-1 and sorting by last played
+you can move the files of items in iTunes by copying the items in iTunes and pressing option-command-V in Finder
+command-N selects the next item and command-P selects the previous item in the window for editing tags in iTunes
+you can tell iTunes to save the playback position for a file like an audiobook by selecting Get Info > Options > Remember playback position
+command-L shows the current item in the library or on the playlist the item was started from in iTunes
+you can preview a single track from each album on a playlist in iTunes by sorting the playlist by track number
+`tell app "iTunes" to refresh selection` updates the tags of the selected items if the tags have been edited outside iTunes
+you can move focus from the location bar to the first Google search result in Safari by pressing tab or shift-tab one or more times
+you can remove the suggested search phrases from Safari's location bar by selecting Privacy > Prevent search engine from providing suggestions
+you can download files like videos that are not saved by command-S in Safari by focusing the location bar and pressing option-return
+option-command-C opens the JavaScript console and option-command-A opens the resources tab in Safari
+you can add a category for all characters to the sidebar in Character Viewer by selecting Customize List... > Code Tables > Unicode
+option-command-1 hides thumbnails, option-command-2 shows thumbnails, and option-command-6 shows a contact sheet view in Preview
+you can open a URL from Terminal by double-clicking the URL while holding command
+control-F2 or command-? moves focus to the menu bar
+you can change the output volume in smaller increments by pressing the volume keys while holding option and shift
+you can set the output volume to a level between zero bars and one fourth bar by pressing the mute key after setting the volume to zero
+you can add words to a spelling dictionary by adding one word per line to a file in ~/Library/Spelling/ and running `killall AppleSpell`
+you can replace straight quotes with smart quotes in a selection by selecting Substitutions > Smart Quotes from a context menu
+shift-command-3 saves a screenshot of the whole screen and shift-command-4 saves a screenshot of an area
+you can take a screenshot of a window without a shadow by pressing shift-command-4, pressing space, and option-clicking the window
+control-shift-eject puts displays to sleep, option-command-eject puts the computer to sleep, and control-command-eject restarts the computer
+command-F1 toggles mirroring displays
+command-delete selects buttons like Don't Save
+control-' and control-" insert straight quotes even when smart quotes are enabled
+you can disable the notifications about new updates in 10.8 and later by disabling automatic updates completely from System Preferences
+you can open recent files or minimized windows from the application switcher by pressing the down arrow key twice
+`defaults write -g NSAutomaticWindowAnimationsEnabled -bool false` disables the animations for opening and closing windows
+`defaults write -g NSDocumentSaveNewDocumentsToCloud -bool false` disables using iCloud as the default location in save dialogs
+`defaults write -g NSTextShowsControlCharacters -bool true` makes text views show ASCII control characters in caret notation
+`defaults write DialogType none` disables crash report dialogs
+`defaults write LSQuarantine -bool false` removes the dialogs shown when opening files downloaded from the Internet
+`defaults write mcx-disabled -bool true` disables Dashboard
+`defaults write dearchive-reveal-after -bool false` disables opening a Finder window after extracting an archive
+installing gnuplot with `brew install gnuplot --with-x` and installing XQuartz makes gnuplot support displaying the output in an X window
+you can enable the root user from Directory or by running dsenableroot
+if you accidentally edit /etc/sudoers so that you cannot use sudo, you can enable the root user, run `su root`, and then edit /etc/sudoers
+if Spotlight indexing always stops at some point, try to delete files shown by `sudo lsof|grep mdworker`
+you can take a screenshot on another Mac by enabling remote login and running `ssh username@other_computers_ip;sudo screencapture a.png`
+holding option during startup shows Startup Manager and holding shift starts up in safe mode
+command-R starts up from the recovery partition, command-S starts up in single user mode, and command-V starts up in verbose mode
+`mount -uw /;launchctl load /S*/*/LaunchDaemons/*.{notifyd,kextd}.plist;mkdir a;mount_hfs /dev/disk1s2 a` mounts a drive in single user mode
+you can reinstall OS X over an existing installation by starting up from the recovery partition and choosing Reinstall OS X
+you can erase and reinstall OS X by starting up from the recovery partition, erasing the OS X partition, and choosing Install OS X
+`open -Rh Events.h` reveals Events.h in Finder
+`grep 'BSD process name' /Library/Logs/DiagnosticReports/*.panic` shows what processes caused kernel panics
+`cat "$(ls -dt ~/Library/Logs/DiagnosticReports/*|head -n1)"` shows the newest crash report
+you can make OS X use a lighter text rendering style by running `defaults write -g AppleFontSmoothing -int 1` and reopening applications
+1 corresponds to the "Light" setting that was included in System Preferences in 10.5 and earlier
+3 corresponds to "Strong", 0 corresponds to "Standard - Best for CRT", and 2 corresponds to "Medium - Best for Flat Panel"
+#installing bash 4
+run `brew install bash;echo /usr/local/bin/bash|sudo tee -a /etc/shells;chsh -s /usr/local/bin/bash`
+`chsh -s` changes the default login shell
+chsh only allows selecting shells in /etc/shells
+you can also change the default login shell from System Preferences or by running `sudo dscl . -change $HOME UserShell /usr/local/bin/bash`
+the crontab format is described in `man 5 crontab`
+cron adds a message to /var/mail/ when a command has any STDOUT or STDERR output
+adding MAILTO="" to the start of a crontab makes cron not send mail messages
+you can remove existing mail messages by running `sudo rm /var/mail/$USER`
+the default path is /usr/bin:/bin even if you have changed the path in /etc/launchd.conf
+the default shell is /bin/sh, but you can change it by adding adding a line like SHELL=/usr/local/bin/bash to the start of a crontab
+the locale variables are unset by default, but you can change them by adding a line like LANG=en_US.UTF-8 to the start of a crontab
+the root has its own crontab which can be edited with `sudo crontab -e`
+% is replaced with a newline in the command field so % has to be escaped as \%
+\ does not have to be escaped as \\ unless it precedes %
+1-3,5 is equivalent to 1,2,5 and 1-7/2 is equivalent to 1,3,5,7
+@hourly is equivalent to `0 * * * *` and @daily is equivalent to `0 0 * * *`
+@reboot runs a command after restarting but not after logging out and back in
+/etc/crontab uses a different format where the sixth field is the username, like `* * * * * username command`
+you can enable logging by adding `cron.* /var/log/cron.log` to /etc/syslog.conf and then unloading and loading
+the files for crontabs are stored in /var/at/tabs/
+/usr/lib/cron is a symlink to /var/at
+/System/Library/LaunchDaemons/com.vix.cron.plist has /usr/lib/cron/tabs in QueueDirectories
+#setting a default path
+run for example `echo setenv PATH /Users/username/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin|sudo tee -a /etc/launchd.conf` and restart
+#setting environment variables with launchd
+`launchctl setenv var value` changes var for all new child processes of the user's launchd process until the launchd process exits
+`echo setenv var value|sudo tee -a /etc/launchd.conf` changes var permanently
+you can apply changes to /etc/launchd.conf by restarting
+`launchctl export` shows the environment variables of the user's launchd process
+`sudo launchctl export` shows the environment variables of the root launchd process
+`sudo launchctl export` does not print anything by default
+variables set in /etc/launchd.conf are listed by both `launchctl export` and `sudo launchctl export`
+`man launchd.conf` says that ~/.launchd.conf is currently unsupported, and I haven't gotten settings in ~/.launchd.conf to have any effect
+~/.MacOSX/environment.plist stopped working in 10.8
+#path_helper, /etc/paths, and /etc/paths.d/
+/usr/libexec/path_helper adds lines in /etc/paths and /etc/paths.d/* to the path
+path_helper is run from /etc/profile, /etc/zsh.env, and /etc/csh.login
+zsh reads /etc/zsh.env even for non-login shells but bash does not read /etc/profile for non-login shells
+path_helper is not run by graphical applications like Xcode or
+/etc/paths contains /usr/local/bin at the end by default
+there are no files in /etc/paths.d/ by default, but for example the XQuartz and MacTeX installers add files to /etc/paths.d/
+I prefer changing the path in /etc/launchd.conf because it also affects processes that are not started from shells
+#erasing an SSD securely
+the option to erase a disk securely in Disk Utility has been disabled for SSDs since 10.7
+according to a KB article by Apple, erasing an SSD normally might be secure enough or make it difficult to recover data
+it is still possible to run something like `diskutil secureErase 4 disk0s2` from Terminal on the recovery partition
+I don't know if using `diskutil secureErase` is more secure than erasing an SSD normally
+another option is to turn on FileVault 2 before erasing the drive, but enabling encryption after an SSD has already been used is not necessarily secure either
+#Internet Recovery mode
+Internet Recovery mode is supported by all Macs that came with 10.7 or later and by some older Macs after a firmware update
+Internet Recovery mode means that the Mac downloads a disk image for the recovery system from Apple's servers
+you can use Internet Recovery to install OS X on an empty drive after you replace a drive or erase a drive completely
+option-command-R forces starting up in Internet Recovery mode
+#startup keys
+command-R starts from a recovery partition
+command-S starts up in single user mode
+command-V starts up in verbose mode
+option opens Startup Manager
+shift starts up in safe mode
+C starts up from an optical disk
+D opens Apple Hardware Test
+N attempts to start up from a NetBoot server
+T starts up in target disk mode
+option-N starts from a NetBoot server using the default boot image
+holding P and R while holding option and command resets NVRAM or PRAM
+holding eject, F12, or a button on a pointing device ejects removable media like optical disks
+option-command-R starts up in Internet Recovery mode
+holding 6 and 4 starts up using a 64-bit kernel
+holding 3 and 2 starts up using a 32-bit kernel
+#mounting an external drive in single user mode
+run `mount -uw /`
+run `launchctl load /System/Library/LaunchDaemons/{notifyd,kextd}.plist`
+run `mkdir /tmp/a;mount_hfs /dev/disk1s2 /tmp/a` where disk1s2 is an identifier shown by `diskutil list`
+#resource forks
+resource forks are not stored as extended attributes even though they can be accessed and modified through the extended attribute interface
+`cat file/..namedfork/rsrc` or `xattr -p file` shows the contents of a resource fork
+`cat file/rsrc` stopped working in 10.7
+`xattr -dr .` removes resource forks recursively
+`find . -type f -xattrname` or `find . -type f -exec test -s {}/..namedfork/rsrc \; -print` finds files with resource forks
+resource forks are used to store custom icons set in Finder, the images of Icon\r files, file-specific default applications, and information about aliases
+if you delete the resource fork of an alias file, the alias stops working
+resource forks are used to store script objects in scpt files, AppleScript Editor window state, and RTF descriptions of scripts
+#AppleDouble files
+AppleDouble files are used to store extended attributes, resource forks, ACLs, and file flags on non-HFS+ volumes and in archives
+Archive Utility and /usr/bin/tar create AppleDouble files but /usr/bin/zip doesn't
+zip archives created with Archive Utility include a __MACOSX folder for AppleDouble files
+`COPYFILE_DISABLE= tar -cf folder.tar folder` creates a tar archive without AppleDouble files
+`zip -r folder` creates a zip archive without AppleDouble files
+`ditto -c -k --sequesterRsrc --keepParent folder` creates a zip archive that includes AppleDouble files
+`ditto -x -k` extracts an archive and convert metadata stored in AppleDouble files back to native formats
+`find . -name ._\* -delete` deletes AppleDouble files
+`dot_clean .` deletes AppleDouble files after converting metadata to native formats
+#Spotlight comments
+Spotlight comments added from Finder are stored both in .DS_Store files and as extended attributes
+if you use Finder to add a Spotlight comment for a file you don't have write permission to, the comment is not saved as an external attribute
+Spotlight comments that are not saved as extended attributes are not seen by Spotlight
+if you delete .DS_Store files, Spotlight comments are still seen by Spotlight, but they are not shown in Finder's information windows
+#default view modes and view options in Finder
+the view mode that is used for new windows is changed when you close a Finder window
+I don't know any way to set a default view mode permanently
+the "Always open in" checkbox enables saving a folder-specific default view mode in a .DS_Store file
+if you check "Always open in column view" and change the view mode to icon view, the folder-specific default view mode becomes icon view
+the "Use as Defaults" button changes some of the settings in ~/Library/Preferences/
+the settings saved with "Use as Defaults" are not used for folders that have folder-specific settings saved in a .DS_Store file
+there is no "Use as Defaults" button in column view because the settings in the two bottom sections of the view options panel are the same for all folders
+#HFS compression
+support for HFS compression was added in 10.6
+HFS compression is enabled for many of the files that are installed with OS X
+most command line utilities and graphical applications display the uncompressed sizes for files
+you can see the compressed size of a file with `sudo fileXray --diskusage`
+when a file is compressed, the data is stored in the resource fork and the data fork is empty
+compressed files have a extended attribute that is hidden by xattr
+`ditto --hfsCompression file1 file2` makes a compressed copy of file1 to file2
+`cp file1 file2` or `ditto --nopreserveHFSCompression file1 file2` makes a non-compressed copy of file1 to file2
+`stat -f%f` prints 32 if a file is compressed and has no other flags
+`ls -lO` displays `compressed` if a file is compressed
+you can use to enable HFS compression for user files
+the extended attributes have values like 0042;5106ce90;Safari;119A94C7-09B5-4E53-805C-3CA43B6B9612
+the second field is a timestamp
+the fourth field corresponds to a UUID in ~/Library/Preferences/
+the first field is a hexadecimal bitfield
+the seventh bit of the first field gets set after you open a file
+the sixth bit of the first field gets set if you try to open a file but press cancel in the warning dialog
+you can create ~/.ssh/id_rsa and ~/.ssh/ by running ssh-keygen and acceping the defaults in every step
+you can make the key pair passphraseless by pressing return in the step for entering a password
+if you enter a password, you can choose to save it to OS X's keychain later so you won't have to type it manually
+you can upload the public key to a host by running `ssh user@host 'cat>>~/.ssh/authorized_keys'<~/.ssh/` or by running ssh-copy-id
+if ~/.ssh/ or ~/.ssh/authorized_keys doesn't exist on the host, run `mkdir -p ~/.ssh/;chmod 700 ~/.ssh/;chmod 600 ~/.ssh/authorized_keys`
+old versions of OpenSSH used authorized_keys2 for SSH2 and authorized_keys for SSH1
+authorized_keys2 is now deprecated and authorized_keys is used for both SSH2 and SSH1
+#folder actions
+a folder action can be an AppleScript with an `adding folder items` handler or an Automator workflow created using the Folder Action template
+Folder Actions Setup only allows selecting scripts and workflows in `~/Library/Workflows/Applications/Folder Actions/`
+Folder Actions Setup modifies ~/Library/LaunchAgents/{enabled,folders}.plist
+folder actions were reimplemented so that they rely on launchd in 10.5 and support for creating folder actions with Automator was added in 10.6
+the job gets throttled if a folder with folder actions is modified within 10 seconds from the last invocation
+sometimes the current window loses focus for a split second when a folder action is run, but I don't know any workarounds for it
+one advantage folder actions have over launchd jobs is that folder actions can get the modified files as input but launchd jobs cannot
+there are some example scripts in `/Library/Scripts/Folder Action Scripts/`
+#logout hooks
+logout hooks were deprecated in 10.4 but they still work as of 10.9
+I haven't figured out any way to reliably run programs on logout with launchd
+`sudo defaults write LogoutHook ~/.logouthook` adds a logout hook
+the value of the LogoutHook key can only be a path to an executable not a shell command
+there can be only one logout hook, but it can be a script that runs multiple programs
+`sudo defaults write` modifies /var/root/Library/Preferences/
+adding a LogoutHook key to /Library/Preferences/ does not work
+if a logout hook takes long enough to run, a gray screen is shown until the logout hook terminates
+there is no time limit after which a logout hook is forced to terminate
+#using an OS X VM with VMware Fusion
+VMware Fusion 5 does not support Mavericks but VMware Fusion 6 does
+you can create a VM from an OS X installer application downloaded from App Store
+if you download a torrent for OS X, just download an unmodified OS X installer application or disk image and not any modified ISO or VM image meant for PCs
+installing VMware Tools adds support for other resolutions than the default resolution and for copy and paste between the guest and host
+if you want to restore the VM to the initial state later, take a snapshot before you start using the VM or after you install VMware Tools
+you can copy files between a VM and the host by adding a shared folder from Virtual Machine > Settings > Sharing
+#manual two-sided printing
+select Paper Handling > Pages to Print > Odd Only and print
+if the total number of pages is odd, either remove the last page or don't remove any pages depending on the printer
+depending on the printer, either flip the pile of papers and set the order to reverse or don't flip the papers and don't set the order to reverse
+select Even Only and print
+#decomposed filenames
+HFS+ stores many characters in decomposed form instead of composed form
+HFS+ uses a variant of NFD where some characters are not decomposed
+`iconv -f utf-8-mac -t utf-8` converts text from the NFD variant used by HFS+ to NFC
+`touch $'\xc3\xa4';ls|tr -d \\n|xxd -p` prints 61cc88
+`touch $'\xc3\xa4';ls|tr -d \\n|iconv -f utf-8-mac -t utf-8|xxd -p` prints c3a4
+bash 4.1 and later treat the decomposed and precomposed forms of characters as equivalent for filename completion and globbing
+a precomposed a-umlaut completes to a decomposed a-umlaut in bash 4.1 but not in bash 3.2
+#pbpaste and pbcopy encodings
+pbpaste and pbcopy don't preserve non-ASCII characters in the C locale
+Terminal and iTerm 2 set LANG to a value like en_US.UTF-8 by default
+the locale variables are unset by default in other applications like Automator and AppleScript Editor
+if you for example run `do shell script "pbpaste"` in AppleScript Editor, it doesn't preserve non-ASCII characters