1
1.upto(1_000_000) { |number| puts Linguistics::EN.numwords(number) }

Ruby On Displaying numbers to words.

by Adam, November 27, 2008 17:13

You want to print numbers f...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
# http://www.deveiate.org/projects/Linguistics/
require 'linguistics'

...

Ruby On Displaying numbers to words.

by Adam, November 27, 2008 15:42
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
def field_row(&block)
  content_tag(:div, :class => :field_row, &block)
end

Ruby On Cheap ruby block templating

by Adam, November 24, 2008 04:38
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
module NameAssociation
  def self.extended(object)
    object.instance_eval(<<-EOS, '(__NAME_ASSOCIATION__)', 1)
...

Ruby On Similar virtual attributes ...

by Adam, November 21, 2008 06:12
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class SchoolYear < ActiveRecord::Base
  has_many :semesters
end
...

Ruby On Arrays, loops, strings...

by Adam, November 21, 2008 05:23

I get the feeling you would...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
require 'activesupport'

class Object
...

Ruby On Caching Methods

by Adam, November 19, 2008 06:03 Star_fullStar_fullStar_fullStar_full

Caching the result in memca...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class Object
  def self.cache_method(method, options = {})
    define_method("#{method}_with_memoization") do |*args|
...

Ruby On Caching Methods

by Adam, November 19, 2008 06:02 Star_fullStar_fullStar_fullStar_full

Memoization with expiration.

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
#include <limits.h>

#define MIN(a,b) ((a) > (b) ? (b) : (a))
...

C On How to find max, min of thr...

by Adam, November 18, 2008 16:34 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
switch (V_VT(&var)) {
    case VT_BSTR:
        for (char *string = (char *)var.bstrVal; *string; string += 2) {
...

C++ On Stream ADODB recordset into...

by Adam, November 18, 2008 06:19

I don't know if it's any fa...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
<% form_for @user do |f| %>
<% end %>

Ruby On Re-use code for new and cre...

by Adam, November 12, 2008 16:51

I used respond_to? because ...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
1.upto(limit).inject(1) { |result,element| result * element }

Ruby On A simple factorial program.

by Adam, November 12, 2008 05:05

The require statement retur...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
require 'enumerator'

def factorial(limit)
...

Ruby On A simple factorial program.

by Adam, November 12, 2008 04:04
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class PropertiesController < ApplicationController
  PUBLIC_ACTIONS  = %w[index show map_info_window]
  LANDORD_ACTIONS = %w[new edit create update destroy]
...

Ruby On Condensing nested conditionals

by Adam, November 12, 2008 03:55
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class PropertiesController < ApplicationController
  before_filter :authorize_user_is_logged_in, :only => [ :new, :create, :edit, :update, :destroy ]
  before_filter :authorize_user_has_permission, :only => [ :new, :create, :edit, :update, :destroy ]
...

Ruby On Condensing nested conditionals

by Adam, November 11, 2008 23:43

I'm not sure what deny_acce...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
require 'filemode'
File.stat(ARGV[0]).to_s # => "-rw-r--r--"

...

Ruby On Pretty output of permission...

by Adam, November 07, 2008 03:12 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
<% @feeds.each_slice(3) do |feeds| %>
  <ul>
...

Ruby On View refactoring

by Adam, November 07, 2008 00:52 Star_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
for directory in @directories
  xml.item do
    xml.title "#{directory.name} (PR #{directory.pagerank})"
...

Ruby On xml rss feed

by Adam, November 05, 2008 16:12
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class UsersController < ApplicationController
  def new
    @user = User.new
...

Ruby On Re-use code for new and cre...

by Adam, November 05, 2008 15:56
A8d3f35baafdaea851914b17dae9e1fc Talk

Ruby On DRY up a controller action

by Adam, November 03, 2008 05:32

I get feeling that you real...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
# http://code.google.com/p/rainpress/
require 'rainpress/packer'

...

Ruby On Gsubing

by Adam, October 31, 2008 13:32 Star_fullStar_fullStar_fullStar_fullStar_full

You could do more with your...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
require 'rexml/document'

document = REXML::Document.new(xml)
...

Ruby On Simplest way to find the na...

by Adam, October 29, 2008 03:49
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class Photo < ActiveRecord::Basse
  URL_PREFIX = 'http://s3.carfinancechief.com.au'
  DIMENSIONS = { 'search' => '200x100', 'module' => '100x50', 'main' => '418x155' }
...

Ruby On DRY it up please

by Adam, October 27, 2008 04:48 Star_fullStar_fullStar_fullStar_full

Personally, I would probabl...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class PriceFilter < ItemFilter
  DIRECTIONS = { 'at most' => '<=', 'at least' => '>=' }
  
...

Ruby On DRYing/shortening form proc...

by Adam, October 27, 2008 04:06 Star_fullStar_fullStar_fullStar_full

I am going to leave the imp...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class MutableFixnum
  instance_methods.each { |method| undef_method(method) unless method =~ /^__.*__$/ }
  
...

Ruby On Yield by 'reference'

by Adam, October 24, 2008 16:15 Star_fullStar_fullStar_fullStar_fullStar_full

Not without a wrapper class...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
>> 1.object_id
=> 3

...

Ruby On Yield by 'reference'

by Adam, October 24, 2008 15:58

That's because Fixnums are ...

A8d3f35baafdaea851914b17dae9e1fc Talk