This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Bar; | |
use strict; | |
sub new { | |
my $class = ref($_[0]) || $_[0]; shift; | |
return bless({}, $class); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Exceptions | |
# custom exceptions / errors with custom default messages a-go-go | |
# the base for defined errors. | |
class DefinedError < RuntimeError | |
@msg = "Undefined Defined Error" | |
def message | |
return @msg || super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -l | |
# | |
# hartog/20100311: break down a WSDL into a list of functions with | |
# input and output nicely tucked in. | |
# | |
# install the perl modules below, put this in your | |
# cgi-bin and get going. | |
# | |
# wouldn't be using this in a public space as it | |
# might consume a lot of resources... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
# same as attr_accessor :variant | |
def variant | |
return @variant | |
end | |
def variant=(arg) | |
@variant = arg | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make an alternative for send_later that accepts a run_at time | |
# | |
module Delayed | |
module MessageSending | |
def send_later_at(at, method, *args) | |
Delayed::Job.enqueue( | |
Delayed::PerformableMethod.new(self, method.to_sym, args), | |
0, #priority | |
at #run_at | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PassphraseGenerator | |
WORDS_LIST = "/usr/share/dict/words" | |
@@words = nil | |
CONJUNCTIONS = %w(and or but you me we him + the -) | |
FUZZ = %w(! @ # $ % ^ & * - + ~ ` , . < > / ?); | |
# make a phrase of two words and a conjuction | |
# | |
# fuzz the words and return the fuzzed phrase and the original phrase | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateprogramDependencies < ActiveRecord::Migration | |
def self.up | |
create_table :program_dependencies do |t| | |
t.references :dependency, :polymorphic => true | |
t.references :program | |
end | |
end | |
def self.down | |
drop_table :program_dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# = I18n scoped | |
# | |
# Set a temporal default scope for I18n | |
# | |
# == Synopsis | |
# | |
# Given a locale YAML that looks like this: | |
# | |
# customers: | |
# firstname: Customer firstname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game | |
attr_reader :secret | |
def initialize | |
@secret = Secret.new | |
end | |
def console_play | |
bulls = -1 | |
while bulls != 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
has_many :abcees | |
has_many :bees, :through => :abcees | |
has_many :cees, :through => :abcees | |
end | |
class Bee | |
end | |
class Cee |
OlderNewer