The following rules of programming style are excerpted from the book "The Elements of Programming Style" by Kernighan and Plauger, published by McGraw Hill. Here is quote from the book: "To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually find in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules."
//github.com/jed/140bytes/wiki/Byte-saving-techniques | |
Number.prototype.isPrime = function(n) { | |
var n = '1'.repeat(this); | |
return !n.match(/^1?$|^(11+?)\1+$/gi); | |
}; | |
// | |
String.prototype.repeat = function(n) { |
require 'active_record' | |
require 'arel' | |
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
# | |
# What you would usually write like this: | |
# | |
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
# | |
# can now be written like this (note those parentheses required by the operators precedences): |
// ==UserScript== | |
// @name Use Markdown, sometimes, in your HTML. | |
// @author Paul Irish <http://paulirish.com/> | |
// @link http://git.io/data-markdown | |
// @match * | |
// ==/UserScript== | |
// If you're not using this as a userscript just delete from this line up. It's cool, homey. |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
MacOSX has a truly global path setting that precedes any other setting like ~/.bash_profile
.
The file /private/etc/paths
is a list of pathnames. The order from top to bottom defines the resulting order in the $PATH
variable.
After loading /private/etc/paths
there is a directory /private/etc/paths.d/
with files in the same style. Those are appended to the $PATH variable.
The default content of /private/etc/paths
looks like this:
/usr/bin
/bin
One of the things I loved about using Safari was that I could have items in my bookmark bar that I could invoke with ⌘1, ⌘2, etc. This was especially nice for things like bookmarklets. For example, I'm viewing an article that I want to read later, I could hit ⌘2 and save it to [Instapaper][instapaper].
Chrome has no such shortcuts for its bookmark bar, but it does have [custom search engines][search_engines].
The idea behind these is allowing you to set a search engine for something like Amazon and be able to type amazon⇥, enter a search term, and get your results without having to do it by manually typing into a search field on the site.
But it can do so much more.
Copy, with line wrapping!
If you've been trying to copy/paste text from a multi-pane tmux
session with the mouse, you've probably been pretty pissed at the blissful ignorance a terminal application has of the rodent in your hand.
The alternative, which is quote-unqoute native copy/pasting using copy-mode takes a bit to get used to. So this is one solution for copying and pasting lines from a session with correct line wrapping behaviour, albeit keyboard only.
Disclaimer
Since copy-mode has similar concepts of marks, regions, and temp buffers to Emacs .. you'll probably find it straight forward if you're familar with Emacsen. For people using vi-mode in tmux
, the same still applies but obviously the default key bindings will differ alot from what I show below.