This file contains hidden or 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
# Ruby fizzbuzz, functional style, no conditionals whatsoever | |
one_if_divisible_by = lambda{|num, x| (1-((x.to_f / num) % 1).ceil)}.curry | |
fizz1 = one_if_divisible_by.(3) | |
buzz1 = one_if_divisible_by.(5) | |
one_to_word = lambda{|func, word, n| word * func.(n)}.curry | |
one_to_n_to_s = lambda{|func, n| n.to_s * func.(n)}.curry | |
fizz = one_to_word.(fizz1,'Fizz') | |
buzz = one_to_word.(buzz1,'Buzz') |
This file contains hidden or 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
bash>> gem env | |
RubyGems Environment: | |
- RUBYGEMS VERSION: 1.8.24 | |
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2] | |
- INSTALLATION DIRECTORY: /Users/pmarreck/.rvm/gems/ruby-1.9.3-p327@desk-rails3 | |
- RUBY EXECUTABLE: /Users/pmarreck/.rvm/rubies/ruby-1.9.3-p327/bin/ruby | |
- EXECUTABLE DIRECTORY: /Users/pmarreck/.rvm/gems/ruby-1.9.3-p327@desk-rails3/bin | |
- RUBYGEMS PLATFORMS: | |
- ruby | |
- x86_64-darwin-11 |
This file contains hidden or 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
bash>> rvm @global do rvm gemset empty | |
/Users/pmarreck/.rvm/gems/ruby-1.9.3-p327@global@global did not previously exist. Ignoring. | |
bash>> rvm --trace @global do rvm --trace gemset empty | |
@global do rvm --trace gemset empty | |
rvm 1.17.3 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] | |
+ [[ -n '' ]] | |
+ set -o errtrace |
This file contains hidden or 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
bash>> ruby -Itest test/unit/customer_merge_test.rb | |
Features that will be loaded are: [:rails, :activerecord, :autoload, :test, :stubbing, :root, :search, :database, :patches, :enum_model] | |
WARNING: This version of mysql2 (0.3.11) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1 | |
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x | |
Run options: | |
# Running tests: | |
EE/Users/pmarreck/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/minitest/unit.rb:780: [BUG] cfp consistency error - send | |
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin11.4.2] |
This file contains hidden or 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
bash>> rvm --trace config-get CC --trace | |
config-get CC --trace | |
rvm 1.17.3 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] | |
+ [[ -n '' ]] | |
+ set -o errtrace | |
+ export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > ' | |
+ PS4='+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > ' | |
+ /scripts/cli : __rvm_parse_args() 757 > [[ -z '' ]] |
This file contains hidden or 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
bash>> sort $MY_RUBY_HOME/config | |
ALLOCA="" | |
AR="ar" | |
ARCHFILE="" | |
ARCH_FLAG="" | |
AS="as" | |
ASFLAGS="" | |
BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false" | |
BUILTIN_TRANSSRCS=" newline.c" | |
CAPITARGET="nodoc" |
This file contains hidden or 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
bash>> gem env | |
RubyGems Environment: | |
- RUBYGEMS VERSION: 1.8.24 | |
- RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [x86_64-darwin11.4.2] | |
- INSTALLATION DIRECTORY: /Users/pmarreck/.rvm/gems/ruby-1.9.3-p327@desk-rails3 | |
- RUBY EXECUTABLE: /Users/pmarreck/.rvm/rubies/ruby-1.9.3-p327/bin/ruby | |
- EXECUTABLE DIRECTORY: /Users/pmarreck/.rvm/gems/ruby-1.9.3-p327@desk-rails3/bin | |
- RUBYGEMS PLATFORMS: | |
- ruby | |
- x86_64-darwin-11 |
This file contains hidden or 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
Rails 3.1: | |
>> Mailbox.first.emails.each(&:destroy); mb = Mailbox.first; eml = mb.emails.new(site: Site.first); mb.save | |
Mailbox Load (0.6ms) SELECT `mailboxes`.* FROM `mailboxes` WHERE `mailboxes`.`deleted_at` IS NULL LIMIT 1 | |
Email Load (0.3ms) SELECT `emails`.* FROM `emails` WHERE `emails`.`mailbox_id` = 1 | |
Mailbox Load (0.3ms) SELECT `mailboxes`.* FROM `mailboxes` WHERE `mailboxes`.`deleted_at` IS NULL LIMIT 1 | |
Site Load (0.4ms) SELECT `sites`.* FROM `sites` WHERE `sites`.`deleted_at` IS NULL LIMIT 1 | |
(0.2ms) BEGIN | |
(0.4ms) SELECT 1 FROM `mailboxes` WHERE (LOWER(`mailboxes`.`email`) = LOWER('[email protected]') AND `mailboxes`.`id` != 1 AND `mailboxes`.`site_id` = 3 AND `mailboxes`.`deleted_at` IS NULL) LIMIT 1 |
This file contains hidden or 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
# RFC 5322 Email Validation Regex in Ruby | |
# This work is released under the BSD 3-Clause License | |
# http://choosealicense.com/licenses/bsd-3-clause/ | |
# Copyleft (ɔ) 2013, Peter R. Marreck | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# |
This file contains hidden or 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
require 'active_support/inflector' | |
module AbstractClassDependency | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def depends_on_class(class_str, params={}) | |
raise(ArgumentError, 'First parameter must not be an actual Class') if class_str.is_a? Class |