Benjamin Manns
- Number of Components: 5
- Average tail length: 105
- Maximum tail length: 257
- Minimum cycle length: 4
require 'benchmark' | |
def benchmark(setting, &block) | |
data = (1..10_000_000).map { block.call } | |
Benchmark.bm(15) do |x| | |
x.report("compact #{setting}") do | |
data.dup.each do |d| | |
[d[0],d[1]].compact.min | |
end |
<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<title>Redirect</title> | |
<meta name="author" content="Benjamin Manns" /> | |
<meta http-equiv="refresh" content="10;url=http://mechanize.rubyforge.org/mechanize/" /> | |
</head> | |
<body> | |
<div> |
# Basic Setup: | |
class User | |
has_one :widget, :dependent => :destroy | |
end | |
class Widget | |
belongs_to :user | |
end |
BIG_HASH_OF_OFTEN_UNCHANGING_VALUES = { ... } | |
BIG_HASH_OF_A_FEW_CHANGED_VALUES = { ... } | |
# Solve for x: | |
BIG_HASH_OF_OFTEN_UNCHANGING_VALUES.merge(x) == BIG_HASH_OF_A_FEW_CHANGED_VALUES + y | |
# where y is a set of k => v pairs that are in UNCHANGING but not in A_FEW_CHANGED | |
x = {} | |
BIG_HASH_OF_A_FEW_CHANGED_VALUES.each do |k, v| | |
x[k] = v unless v == BIG_HASH_OF_OFTEN_UNCHANGING_VALUES[k] |
# Option 1: | |
# Use content to separate the helper from the spec | |
it "should have something" do | |
content = helper.some_helper_method | |
content.should have_tag('a', :text => 'foo') | |
end | |
# Option 2: | |
# Combine helper call and spec |
# See http://ruby-doc.org/stdlib-1.9.2/libdoc/digest/rdoc/Digest/Class.html#method-c-digest | |
# See http://ruby-doc.org/stdlib-1.9.2/libdoc/openssl/rdoc/OpenSSL/Cipher.html | |
# See http://ruby.about.com/od/rubyfeatures/a/argv.htm | |
require 'openssl' | |
# Use this section to encrypt a file | |
input_file = 'abc.txt' | |
output_file = 'abc.encrypted' |
# Required: | |
access_key_id: | |
secret_access_key: | |
bucket_name: | |
# Optional: | |
server: s3.amazonaws.com | |
port: 80 | |
use_ssl: false | |
persistent: false |
// Run this in the JavaScript console to remove the SOPA message. | |
// | |
// Also, slap yourself for waiting 'til the last minute to finish the report. | |
// | |
// I mean, come on. | |
// | |
// Seriously. | |
$('div#mw-sopaOverlay').remove(); | |
$('body').children().show(); |
First things first, you want to make sure that all of your iptables chains are set to ACCEPT
, otherwise, you might lock yourself out of the system by blocking the SSH port.
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
Next, you can flush your chains to start from scratch.