Skip to content

Instantly share code, notes, and snippets.

@matid
matid / gist:10557431
Created April 12, 2014 21:19
keybase.md
### Keybase proof
I hereby claim:
* I am matid on github.
* I am matid (https://keybase.io/matid) on keybase.
* I have a public key whose fingerprint is BF77 1276 FCC7 254C 0C0E 28AE 8248 346F DDFC 3C94
To claim this, I am signing this object:
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
<h1>Articles</h1>
<% paginate(@articles).each do |article| %>
<div>
<h2><%= article.title %></h2>
<p><%= article.body %></h2>
</div>
<% end %>
class Articles < ApplicationController
def index
@articles = Article.all
end
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