Skip to content

Instantly share code, notes, and snippets.

module Austin
Guess = Struct.new(:letter, :frequency_ratio, :word_frequency_ratio) do
def <=>(guess)
weight <=> guess.weight
end
def weight
2 * word_frequency_ratio + frequency_ratio
end
<s:taxonomies:find name="Featured Pages">
<s:taxons:find name="Home Page">
<div id="featured_products">
<h2>Featured Products</h2>
<s:snippet name="Products" />
</div>
</s:taxons:find>
</s:taxonomies:find>
{{ store.taxonomies | find_by_name:'Featured Pages' | assign_to:'featured_pages_taxonomy' }}
{{ featured_pages_taxonomy.taxons | find_by_name:'Home Page' | assign_to:'home_page_taxon' }}
{{ home_page_taxon.products | assign_to:'featured_products' }}
{{ featured_products | only:6 | assign_to:'featured_products' }}
<div id="featured_products">
<h2>Featured Products</h2>
{% snippet 'Products' products:featured_products %}
</div>
class Y
def name
'bar'
end
end
class X
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<p><strong style="color:#c00;">DO NOT USE THIS CODE AS IS.</strong> This is an attempt to recreate <a href="../3.0/code.html">Custom Buttons v3.0</a> without requiring <a href="../3.0/img/bg-button.gif">3.0's background gradient image</a>, yet still retain some dimensionality (via a subtle flat shadow on the bottom half of the button). This example code currently works as intended in Firefox and Safari, but fails in IE. And it's a little messy in terms of the required DOM. All caveats and explanations from the <a href="../3.0/code.html">v3.0 code demo</a> apply here too.</p>
<form action="#">
Encryptor.encrypt("hey", :key => "mykey")
# this returns "Ҷ\210\220ğ\255???u;\361\273\245@"
# trying to put this in the DB gives: incomplete multibyte character
# A class that looks like this..
class A
def initialize(x, y)
@x = x
@y = y
end
attr_accessor :x, :y
end
module MethodBenchmarker
def benchmarks(*methods)
methods.flatten.each do |method|
define_method("#{method}_with_benchmark") do |*args|
r = nil
secs = Benchmark.realtime { r = send("#{method}_without_benchmark", *args) }
puts *[
"\n##################################################",
"Method '#{method}' took #{sprintf("%.4f", secs)} seconds",
"##################################################"
puts :hi
=== General Commands
help # show this usage
version # show the gem version
list # list your apps
create [<name>] # create a new app
keys # show your user's public keys
keys:add [<path to keyfile>] # add a public key