1
2
3
4
require 'date'

module FancyDate
...

Ruby On Cleaner way to define const...

by Adam, January 19, 2010 22:14
A8d3f35baafdaea851914b17dae9e1fc Talk
1
<?php  echo "You may not distribute the software or any parts of it."; ?>

PHP On Need help decoding ZEND php...

by Adam, January 06, 2010 00:52 Star_fullStar_fullStar_fullStar_full

Hope this helps. ;)

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
pages.each do |channel,(name,types)|
  count = types.count { |type| type.values.include?('type' => 'dash') }
  logger.debug "Pages for #{channel} channel:"
...

Ruby On Can this be less clunky?

by Adam, November 28, 2009 04:54 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
numberWithDelimeter(number) {
    var delimeter = arguments[1] || ",";
    var separator = arguments[2] || ".";
...

JavaScript On Money formatting

by Adam, November 26, 2009 06:49

Strangely, I was in need of...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class Numeric
  def evenize(operator = '+')
    raise ArgumentError, "invalid argument (must be `+' or `-')" unless %w(+ -).include?(operator)
...

Ruby On Numeric#evenize

by Adam, November 18, 2009 06:02 Star_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
render :update do |page|
  page.facebox.reveal(action_string) if options[:action]
  page.facebox.reveal(template_string) if options[:action]
...

Ruby On Prototype Facebox Render

by Adam, November 05, 2009 16:37

I would start by building y...

A8d3f35baafdaea851914b17dae9e1fc Talk

Ruby On shallow controller and params

by Adam, October 22, 2009 02:56

Good call on find. That's w...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class ArticoliController < ApplicationController
  AVAILABLE_SCOPES = [ BollaDaFornitore, BollaDaRedazione, BollaVersoRedazione, BollaVersoFornitore ]
  
...

Ruby On shallow controller and params

by Adam, October 17, 2009 13:20
A8d3f35baafdaea851914b17dae9e1fc Talk

C On Version comparison

by Adam, October 15, 2009 15:25

Your second refactoring loo...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class MagicHash < Hash
  module NilExtension
    def __set_magic_hash__(hash, key)
...

Ruby On Magical Hash

by Adam, October 09, 2009 04:26

And a convoluted solution t...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
default_proc = lambda { |hash,key| hash[key] = Hash.new(&default_proc) }
hash = Hash.new(&default_proc)

Ruby On Magical Hash

by Adam, October 09, 2009 00:57

@Mortice dup-ing the hash c...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class ObjectContainer < Hash
  def <<(object)
    self[object.label] = object
...

Ruby On Adding an object with acces...

by Adam, October 07, 2009 20:10
A8d3f35baafdaea851914b17dae9e1fc Talk
1
require'cgi';CGI.parse(q)

Ruby On Parse a querystring

by Adam, October 05, 2009 20:18 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class Company < ActiveRecord::Base
  named_scope :created_after, lambda { |date| { :conditions => [ 'created_at > ?', date ] } if date }
  named_scope :in_locality, lambda { |location| { :conditions => [ 'locality_id IN (?)', location.is_a?(Array) ? location : Locality.find_with_children(location) ] } }
...

Ruby On Finder with fulltext

by Adam, September 25, 2009 16:09
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
def move_old_collection_to_new_collection
  source = CollectionOne.find(params[:collectionone_id])
  destination = CollectionTwo.find(params[:collectiontwo_id])
...

Ruby On Moving collections with eva...

by Adam, September 24, 2009 21:19

I think you may want to ret...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class Category < ActiveRecord::Base
  self.find_with_children_by_slug(slug)
    category = find_by_slug(slug, :include => :direct_children)
...

Ruby On Easy finder

by Adam, September 24, 2009 16:32

I think what you have is fi...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
function checkInterval(event) {
    var pad = function(s) { return Array(3 - s.length).join('0') + s }
    
...

JavaScript On check pattern and add zeroes

by Adam, September 14, 2009 21:20 Star_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
y_max = data.any? { |elements| elements[1..-1].any? { |element| element > 0 } } ? nil : 10

Ruby On 2D array manipulation

by Adam, September 12, 2009 14:35
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
int File_size(const char *path)
{
    struct stat info;
...

C On File bytesize

by Adam, September 11, 2009 15:33 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class Room
  SIZES = { :double => 2, :twin => 2, :single => 1 }

...

Ruby On ungliness and long too

by Adam, September 10, 2009 16:03
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
def button(title, options = {})
  category = options.delete(:category) || 'primary'
  endcap   = content_tag(:div, '&nbsp;', :class => 'endcap')
...

Ruby On Button code creates a gener...

by Adam, September 09, 2009 18:43
A8d3f35baafdaea851914b17dae9e1fc Talk
1
@documents.map(&:to_hash)

Ruby On Call a function to each member

by Adam, September 08, 2009 16:26 Star_fullStar_fullStar_fullStar_full

There is, in fact, somethin...

A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
class String
  unless defined?(lines)
    def lines
...

Ruby On Running Ruby 1.9 or 1.8 code

by Adam, August 25, 2009 21:10 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
1
@areas = Area.all(:include => :videos)

Ruby On Consolidate database count ...

by Adam, August 25, 2009 14:22
A8d3f35baafdaea851914b17dae9e1fc Talk
1
2
3
4
Ajax.Responders.register({
    onCreate: function(response) {
        response.parameters.ms = response.parameters.ms || new Date().getTime();
...

JavaScript On beautify prototype ajax req...

by Adam, August 13, 2009 15:20 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk