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
[ | |
[true, false], # => [true, false] | |
[false, true], # => [false, true] | |
[true, true], # => [true, true] | |
[false, false], # => [false, false] | |
[false, false, false], # => [false, false, false] | |
[false, false, true], # => [false, false, true] |
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
pi@mac:~/company/minishrimp-container/minishrimp-server$ be rake -T -A | grep test | |
rake db:test:clone # | |
rake db:test:clone_structure # | |
rake db:test:load # | |
rake db:test:load_schema # | |
rake db:test:load_structure # | |
rake db:test:prepare # | |
rake db:test:purge # | |
rake emba:test # Extra rake tast | |
rake test # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins) |
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
def devise(n) | |
arr = n.to_s.split("").reverse.each_slice(3).to_a.reverse.map do |group| # => [["1"]], [["0", "1"]], [["0", "0", "1"]], [["1"], ["0", "0", "0"]], [["0", "1"], ["0", "0", "0"]], [["0", "0", "1"], ["0", "0", "0"]], [["1"], ["0", "0", "0"], ["0", "0", "0"]], [["5", "3"], ["5", "3", "2"], ["5", "3", "2"]] | |
group.reverse.join("") # => "1", "10", "100", "1", "000", "10", "000", "100", "000", "1", "000", "000", "35", "235", "235" | |
end # => ["1"], ["10"], ["100"], ["1", "000"], ["10", "000"], ["100", "000"], ["1", "000", "000"], ["35", "235", "235"] | |
arr.join(",") # => "1", "10", "100", "1,000", "10,000", "100,000", "1,000,000", "35,235,235" | |
end | |
devise(1) == "1" # => true | |
devise(10) == "10" # => true |
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
# wl-test.txt | |
# asalsa | |
# heros | |
# horse | |
# idisd | |
# shore | |
# shores | |
# sshore | |
def sorted_letters(word) |
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
input = "abc cba" # => "abc cba" | |
input = "cB!a This is a valid\n input, you have to read the specification carefully! abc" # => "cB!a This is a valid\n input, you have to read the specification carefully! abc" | |
input = input.downcase # => "cb!a this is a valid\n input, you have to read the specification carefully! abc" | |
input = input.gsub(/\W/) { |c| # => "cb!a this is a valid\n input, you have to read the specification carefully! abc" | |
c =~ /\s/ ? " " : "" # => "", " ", " ", " ", " ", " ", " ", "", " ", " ", " ", " ", " ", " ", " ", "", " " | |
} # => "cba this is a valid input you have to read the specification carefully abc" | |
arr = input.split(" ") # => ["cba", "this", "is", "a", "valid", "input", "you", "have", "to", "read", "the", "specification", "carefully", "abc"] |
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 Color | |
def initialize | |
@colors = ["R", "G", "B"] # => ["R", "G", "B"], ["R", "G", "B"] | |
end | |
def get | |
c = @colors.first # => "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R" | |
@colors = @colors.rotate # => ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"], ["B", "R", "G"], ["R", "G", "B"], ["G", "B", "R"] | |
c # => "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R", "G", "B", "R" | |
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
#!/bin/sh | |
exec scala -savecompiled "$0" "$@" | |
!# | |
// This is how magic of Action object in Play Framework works. | |
object Action { | |
val foo = "foo" | |
def apply(text: String) = { |
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 pl.japila.scalania.s99 | |
object S99_P15 { | |
def duplicateN[T](n: Int, ts: Seq[T]): Seq[T] = ts match { | |
case Nil => Nil | |
case x :: xs => | |
List.fill(n)(x) ++ duplicateN(n, xs) | |
// (0 until n toList).map { _ => x } ++ duplicateN(n, xs) | |
} |
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
# works with ruby 2.0 | |
def fib(x) | |
if x <= 1 | |
1 | |
else | |
fib(x-1) + fib(x-2) | |
end | |
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
class Solution | |
attr_reader :array # => nil | |
def initialize(a) | |
@array = a # => [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2], [4, 5, 8, 5, 1, 4, 6, 8, 7, 2, 2, 5], [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2], [4, 5, 8, 5, 1, 4, 6, 8, 7, 2, 2, 5], [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2], [4, 5, 8, 5, 1, 4, 6, 8, 7, 2, 2, 5], [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2], [4, 5, 8, 5, 1, 4, 6, 8, 7, 2, 2, 5] | |
end | |
def peak?(left, center, right) | |
left < center && center > right # => true, false, true, false, true, false, false, false, false, true, false, true, false, false, false, false, true, false, false, false, false, true, false, true, false, true, false, true, false, false, false, false, true, false, true, false, false, false, false, true, false, false, false, true, false, true, false, true, false, false, false, false, true, false, true, false, false, false, false, true, false, false, false | |
end |
NewerOlder