Public Gists by Roman2K

Gravatar
Tue Mar 17 05:51:16 -0700 2009
1
2
class Test
end
Gravatar
Wed Mar 11 06:14:42 -0700 2009
1
2
3
  def on_time_value
    attendances.inject(0) do |sum, attendance|
      sum + (attendance.late? ? 0 : 5)
Gravatar
Tue Mar 03 08:41:20 -0800 2009
1
2
3
# Minimalistic Mininova TV show browser with live search, written in Shoes.
#
# To run it, drop `minishoes.rb' onto `Shoes.app'. You should see something like
Gravatar
Mon Feb 09 08:12:30 -0800 2009
1
2
3
# Portable monkey patch for reloading constants before hitting metal
# applications. More details in the introduction article at:
#
Gravatar
Mon Feb 02 08:47:34 -0800 2009
1
2
3
# This is an augmented version of the original `insert!'. In addition to the
# original functionality, it allows for specifying:
#
Gravatar
Mon Feb 02 08:30:57 -0800 2009
1
2
3
article = insert! Article
comment = insert! Comment, :article => article
# ...use these records here...
Gravatar
Mon Feb 02 08:29:29 -0800 2009
1
2
article = Article.new { |a| a.save(false) }
comment = article.comments.build { |c| c.save(false) }
Gravatar
Mon Feb 02 08:28:35 -0800 2009
1
2
3
article = Article.new.save(false) # would be ideal, but `article' equals true here
article = Article.new
article.save(false) # => true
Gravatar
Sun Feb 01 01:58:27 -0800 2009
1
text "Hello World!"
Gravatar
Sun Feb 01 01:58:04 -0800 2009
1
pdf.text "Hello World!"
Gravatar
Sun Feb 01 01:57:46 -0800 2009
1
2
3
pdf.bounding_box [100, 600], :width => 200 do
  pdf.text "The rain in spain falls mainly on the plains " * 5
  pdf.stroke do
Gravatar
Sun Feb 01 01:57:26 -0800 2009
1
2
3
bounding_box [100, 600], :width => 200 do
  text "The rain in spain falls mainly on the plains " * 5
  stroke do
Gravatar
Sun Feb 01 01:56:51 -0800 2009
1
2
3
def show
  # ...
  send_file_headers! \
Gravatar
Sun Feb 01 01:55:33 -0800 2009
1
2
3
some.code(before)
eval(Pathname(__FILE__).dirname.join('_bar.pdf.prawn').read)
some.code(after)
Gravatar
Mon Dec 22 13:32:29 -0800 2008
1
2
3
From 3014a599a158c7ef1332bf3dbc6ca25c015c618e Mon Sep 17 00:00:00 2001
From: Roman Le Negrate <roman.lenegrate@gmail.com>
Date: Mon, 22 Dec 2008 22:30:20 +0100
Gravatar
Wed Nov 19 11:36:10 -0800 2008
1
2
3
def insert!(model, attributes={})
  attributes = attributes.stringify_keys
  begin
Gravatar
Tue Nov 18 23:53:27 -0800 2008
1
2
3
class Post < ActiveRecord::Base
  validates_length_of :title, :minimum => 4
  
Gravatar
Sun Nov 16 09:21:56 -0800 2008
1
2
3
def nil_blank_count(object)
  object.attributes.values.select(&:present?).size
end
Gravatar
Sun Nov 16 09:11:06 -0800 2008
1
2
3
# Untested
module WithLogger
  attr_writer :logger
gist: 16852 Test helper for painless re...
Gravatar
Tue Oct 14 20:49:13 -0700 2008
1
2
3
# Test helper for painless record creation. Details at:
# http://roman.flucti.com/painless-record-creation-with-activerecord
#