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
(1..100).map do |n| | |
if n % 15 == 0 | |
"FizzBuzz" | |
elsif n % 3 == 0 | |
"Fizz" | |
elsif n % 5 == 0 | |
"Buzz" | |
else | |
"x" | |
end |
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 'minitest/autorun' | |
class StringPairsFinder | |
def find(s) | |
return if s.nil? | |
tokens = s.split | |
result = Result.new | |
tokens.each_with_index do |t,i| |
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
import java.util.List; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestMethod; | |
import org.springframework.web.bind.annotation.ResponseBody; | |
import com.santos.leandro.spring.mvc.models.Season; | |
import com.santos.leandro.spring.services.SeasonService; |
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
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.RandomAccess; | |
public class CollectionUtils { | |
public static <E> List<E> typeSafeCopy(@SuppressWarnings("rawtypes") List list, Class<E> clazz) { | |
List<E> returnList = (list instanceof RandomAccess) ? new ArrayList<E>(list.size()) : new LinkedList<E>(); | |
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
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Target(value = ElementType.METHOD) | |
@Retention(value = RetentionPolicy.RUNTIME) | |
public @interface ToStringBuilderIgnore { | |
} |
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
module IPad::Api | |
class UrlMapper | |
class << self | |
def urls_for(args, options = {:include_base_url => false}) | |
league, model, id, *extra = args | |
object = get_model(league, model, id) | |
model_urls(league, model).map { |url| | |
instance_eval("\"#{url}\"") unless (url.match(/\#\{id\}/) && id.blank?) || (url.match(/\#\{league\}/) && league.blank?) |
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
# Use Hash#assert_valid_keys (from ActiveSupport) to document what | |
# keys to use when calling the method | |
def greet(options) | |
options.assert_valid_keys(:first_name, :last_name) | |
puts "Hello #{options[:first_name]} #{options[:last_name]}!" | |
end | |
#=> Hello Thuva Tharma! | |
greet(:first_name => "Thuva", :last_name => "Tharma") | |
#=> Unknown key(s): name (ArgumentError) |
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
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'ostruct' | |
urls = %w( | |
http://development.thescore.com/nhl/events/2820-philadelphia-at-buffalo/box_score | |
http://development.thescore.com/mlb/events/5795/box_score | |
http://development.thescore.com/ncaaf/events/3118/box_score | |
http://development.thescore.com/nba/7275-cleveland-at-boston/box_score | |
http://development.thescore.com/ncaab/events/14267/box_score |