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."
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 Ssh < Thor | |
desc "copy", "Copies the public key to a remote server" | |
def copy(server) | |
system %Q{cat ~/.ssh/id_dsa.pub | ssh #{server} "cat >> ~/.ssh/authorized_keys"} | |
end | |
end |
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 NilClass | |
def to_param | |
"all" | |
end | |
end | |
class Symbol | |
alias to_param to_s | |
end |
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
module Slug | |
def to_param | |
"#{super}-#{slug}" | |
end | |
def slug | |
to_s.gsub("'", "").gsub(/\p{^Alnum}/u, " ").strip.gsub(/\s+/, "-").downcase | |
end | |
end |
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
require "redis" | |
require "nest" | |
redis = Redis.new | |
users = Nest.new(:users, redis) | |
posts = Nest.new(:posts, redis) | |
user = users[users.incr] | |
user.hmset(:name, "Albert") |
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
require "go/gtp/board" | |
require "cutest" | |
setup do | |
string = <<-EOS.gsub(/^ {2}/, "") | |
A B C D E F G H J | |
9 . . . . . . . . . 9 | |
8 . . . . . . . . . 8 | |
7 . . X . . . + . . 7 | |
6 . . . . . . . . . 6 |
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
/* | |
* Hide the "Click here to download plugin" flash placeholders. | |
*/ | |
embed[type="application/x-shockwave-flash"] { | |
display: none !important; | |
} |
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
require "ohm" | |
require "pp" | |
class Foo < Ohm::Model | |
def my_strings | |
key[:my_strings] | |
end | |
end | |
f = Foo.create |
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
require "cuba" | |
run Cuba.new { on(root) { res.write "hello, world" } } |
As some of you may know, traffic within AWS is free, and traffic going outside of AWS has a small cost. We had never restricted outgoing traffic because it makes sense for our customers to access their database from their local environments. Everyone needs to run administrative commands every now and then, and that's totally fair.
Recently, we noticed an increase in traffic going outside of AWS, to the point that we were operating at a loss. We tried to contact all our customers to let them know that we would restrict that kind of usage, and effectively did so today. After all, we thought,
OlderNewer