This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns | |
| Compress 1K bytes with Zippy 3,000 ns | |
| Send 2K bytes over 1 Gbps network 20,000 ns | |
| Read 1 MB sequentially from memory 250,000 ns | |
| Round trip within same datacenter 500,000 ns | |
| Disk seek 10,000,000 ns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; a fortune function that works if you have the | |
| ;; "fortune" program installed via macports | |
| (defun fortune () | |
| (interactive) | |
| (let ((fortune-program "/opt/local/bin/fortune")) | |
| (if (file-exists-p fortune-program) | |
| (shell-command fortune-program)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; from http://stackoverflow.com/questions/7249244/how-can-i-define-functions-taking-blocks-as-parameters-in-elisp | |
| ;; | |
| ;; the 'do-times function emulates n.times behavior from Ruby. | |
| ;; | |
| ;; definition | |
| (defmacro do-times (n &rest body) | |
| (let ((i (gensym))) | |
| `(do ((,i 0 (1+ ,i))) | |
| ((= ,i ,n)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; messages the active region to the minibuffer | |
| (defun message-region () | |
| (interactive) | |
| (if (region-active-p) | |
| (let ((region-contents-string (buffer-substring (region-beginning) (region-end)))) | |
| (message region-contents-string)) | |
| (message "Mark is not set"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PostsController | |
| before_filter :set_entry | |
| before_filter :reject_spam | |
| def create | |
| @comment = @entry.comments.create!(params[:post].permit(:title, :body).merge(author: current_user)) | |
| deliver_comment @comment | |
| post_to_twitter @comment if @comment.share_on_twitter? | |
| post_to_facebook @comment if @comment.share_on_facebook? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns sudoku | |
| (:refer-clojure :exclude [==]) | |
| (:use clojure.core.logic)) | |
| (defn get-square [rows x y] | |
| (for [x (range x (+ x 3)) | |
| y (range y (+ y 3))] | |
| (get-in rows [x y]))) | |
| (defn init [vars hints] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Use Ctrl+O as bind key | |
| unbind C-b | |
| unbind C-o | |
| set -g prefix C-o | |
| # Use vi key bindings to navigate | |
| set-window-option -g mode-keys vi | |
| # Use Ctrl+O, O to switch back and forth between panes | |
| bind-key C-o last-window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun read-region () | |
| "Read the currently active region and return it as a string" | |
| (if (region-active-p) | |
| (let ((region-contents-string (buffer-substring (region-beginning) (region-end)))) | |
| region-contents-string))) | |
| (defun ruby-extract-variable () | |
| "Extract variable from currently active region." | |
| (interactive) | |
| (if (region-active-p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Also, please write good git commit messages. A good commit message | |
| looks like this: | |
| Header line: explaining the commit in one line | |
| Body of commit message is a few lines of text, explaining things | |
| in more detail, possibly giving some background about the issue | |
| being fixed, etc etc. | |
| The body of the commit message can be several paragraphs, and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ruby swank.rb | |
| # emacs prompts: | |
| # Versions differ: 20100404 (slime) vs. nil (swank). Continue? (y or n) | |
| # if yes, backtrace occurs. | |
| Listening on ["AF_INET6", 4005, "::1", "::1"] | |
| dispatch: [:":emacs-rex", [:"swank:connection-info"], "COMMON-LISP-USER", :t, 1] | |
| dispatch: [:":emacs-rex", [:"swank:create-repl", :nil], "COMMON-LISP-USER", :t, 2] |