Moved here: https://github.com/TampaRuby/Learn
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 Array | |
def sum | |
reduce(:+) | |
end | |
end | |
def is_laser(character) | |
character == '|' ? 1 : 0 | |
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
# | |
# Cookbook Name:: apt | |
# Provider:: repository | |
# | |
# Copyright 2010-2011, Opscode, Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License 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
desc "Rebuild the development database and then seed " | |
task :rebuild_and_seed_development_database => %w{other_tasks} if Rails.env.development? | |
# versus | |
if Rails.env.development? | |
desc "Rebuild the development database and then seed " | |
task :rebuild_and_seed_development_database => %w{other_tasks} | |
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
# Assuming the exception is something like this | |
module Flicker | |
class ApiError < StandardError | |
end | |
end | |
def error_with_message(pattern) | |
error_handling_module = Module.new | |
(class << error_handling_module; self; end).instance_eval do | |
define_method(:===) do |exception| |
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
$ rvm mount -r https://rvm.io/binaries/ubuntu/12.04/i386/ruby-1.9.3-p392.tar.bz2 --verify-downloads 1 | |
https://rvm.io/binaries/ubuntu/12.04/i386/ruby-1.9.3-p392.tar.bz2 - #configure | |
ruby-1.9.3-p392 - #download | |
######################################################################## 100.0% | |
ruby-1.9.3-p392 - #validate archive | |
ruby-1.9.3-p392 - #extract | |
ruby-1.9.3-p392 - #validate binary | |
ruby-1.9.3-p392 - #setup | |
Saving wrappers to '/home/rdm/.rvm/wrappers/ruby-1.9.3-p392'........ | |
ruby-1.9.3-p392 - #importing default gemsets, this may take time....................... |
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
grep -i jgroup jboss.log | |
17:00:23,999 INFO [org.jboss.as.clustering.jgroups] (ServerService Thread Pool -- 56) JBAS010260: Activating JGroups subsystem. | |
17:00:26,119 WARN [org.jgroups.protocols.UDP] (ServerService Thread Pool -- 86) send buffer of socket java.net.DatagramSocket@5b5496bc was set to 640KB, but the OS only allocated 131.07KB. This might lead to performance problems. Please set your max send buffer in the OS correctly (e.g. net.core.wmem_max on Linux) | |
17:00:26,120 WARN [org.jgroups.protocols.UDP] (ServerService Thread Pool -- 86) receive buffer of socket java.net.DatagramSocket@5b5496bc was set to 20MB, but the OS only allocated 131.07KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux) | |
17:00:26,120 WARN [org.jgroups.protocols.UDP] (ServerService Thread Pool -- 86) send buffer of socket java.net.MulticastSocket@24b5d935 was set to 640KB, but the OS only allocated 131.07KB. This might lead to performance problems. |
For the numbers 1
through 1000
-
if the number is divisible by
5
printIron
-
if the number is divisible by
7
, printYard
-
if it is divisible by both
5
and7
, printIronYard
-
that is:
1
My review of the Tesla Model S test drive
Tesla Miami
July 28th, 2012
by Gavin Stark
DISCLAIMER: I am not a car guy. I don't know what a limited slip differential is (ok, I sorta know) and I don't drive a manual transmission
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
>> matcher = lambda { |value| puts "value is #{value}"; value == "foo" } | |
=> #<Proc:0x0000000110219b28@(irb):14> | |
>> matcher === "foo" | |
=> false | |
>> matcher.call("foo") | |
value is foo | |
=> true | |
>> |