Skip to content

Instantly share code, notes, and snippets.

it "should require login of minimum 4 chars" do
identity = new_identity(:login => "one")
identity.should_not be_valid
identity.errors.on(:login).should_not be_nil
end
def define(label, &block)
if block_given?
definition = capture(&block)
else
definition = label.first.last
label = label.first.first
end
content = markaby do
dt label.t
class Articles < ApplicationController
def index
@articles = Article.all
end
end
<h1>Articles</h1>
<% paginate(@articles).each do |article| %>
<div>
<h2><%= article.title %></h2>
<p><%= article.body %></h2>
</div>
<% end %>
#<ActionView::ReloadableTemplate:0x3b8b750 @previously_last_modified=Tue Mar 17 12:33:12 +0100 2009,
@_memoized_method_segment=["app47views47mailer47activation46de46text46plain46erb"], @format="de",
@_memoized_relative_path=["app/views/mailer/activation.de.text.plain.erb"], @extension=nil,
@_memoized_method_name_without_locals=["_run_app47views47mailer47activation46de46text46plain46erb"],
@load_path="/Users/matid/Projects/pokerring.com/trunk/app/views", @base_path="mailer",
@filename="/Users/matid/Projects/pokerring.com/trunk/app/views/mailer/activation.de.text.plain.erb",
@locale=nil, @name="activation", @template_path="mailer/activation.de.text.plain.erb">
#<ActionView::ReloadableTemplate:0x3b841e4 @previously_last_modified=Tue Mar 17 12:33:25 +0100 2009,
@_memoized_method_segment=["app47views47mailer47activation46en46text46plain46erb"], @format="en",
<?php
$array = array('abc', 'def');
$string = "String with 'abc' or 'def' in it";
function find($string, $array){
foreach($array as $token){
if(strpos($string, $token) !== false){
return true;
}
class Article
attr_accessor :title, :body
end
# config/initializers/rails3.rb
Dir.glob(File.join(RAILS_ROOT, "lib", "rails3", "**", "*")).map { |path| require path }
# lib/rails3/presence.rb
class Object
def presence
self if present?
end
end
@matid
matid / 1.rb
Created September 17, 2010 11:23
class PostTest < ActiveSupport::TestCase
test "adds 20 points to post author" do
@post.save!
assert 20, @post.author.points # should be assert_equal
end
should "add 20 points to post author" do
@post.save!
@post.author.points == 20 # no assertion, should be "@post.author.points.should == 20"
end
@matid
matid / tapes-privacy-policy
Created October 15, 2013 14:19
Tapes: Privacy Policy
# Privacy policy
Ink Labs Limited (“we” or “us”) are committed to protecting and respecting your privacy.
This policy (together with our Terms of Service and any other documents referred to) sets out the basis on which any personal data we collect from you, or that you provide to us, will be processed by us. Please read the following carefully to understand our views and practices regarding your personal data and how we will treat it. If you have any requests concerning your personal information please contact our support team by email at support@usetapes.com.
## Information we may collect from you
We collect personal information about you (“data”) when you subscribe for our Service. We may also collect information automatically about your use of our website through cookies and other devices.