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
| defmodule Tree do | |
| def parse(str) when is_bitstring(str) do | |
| str |> String.split() |> Enum.map(&String.to_integer/1) | |
| end | |
| def nodes_metadata(list) | |
| def nodes_metadata([]) do | |
| {[], []} | |
| 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 IEx | |
| defmodule Steps do | |
| def parse(str) when is_bitstring(str) do | |
| str |> String.split("\n") |> parse() | |
| end | |
| def parse([]), do: [] | |
| def parse([h | t]) do |
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
| defmodule Danger do | |
| def parse(str) when is_bitstring(str) do | |
| str | |
| |> String.split("\n") | |
| |> parse() | |
| |> Enum.with_index() | |
| |> Enum.map(fn {c, i} -> | |
| {c, [?a + i] |> to_string} | |
| end) | |
| 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
| defmodule Polymer do | |
| def scan(p, status \\ :ok) | |
| def scan(p, _) when is_bitstring(p) do | |
| p = "%#{p}" | |
| p | |
| |> String.to_charlist() | |
| |> scan(:ok) | |
| |> elem(0) |
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
| defmodule Sleeps do | |
| def parse([]), do: [] | |
| def parse([nil, t]), do: parse(t) | |
| def parse([h | t]), do: [parse(h) | parse(t)] | |
| def parse(str) do | |
| ~r/^\[(\d+)-(\d+)-(\d+) (\d+):(\d+)\] (.+)/ | |
| |> Regex.run(str) | |
| |> List.delete_at(0) | |
| |> List.to_tuple() |
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
| defmodule Squares do | |
| def parse([]), do: [] | |
| def parse([h | t]) do | |
| [parse(h) | parse(t)] | |
| end | |
| def parse(str) do | |
| ~r/^#(\d+)\s+@\s+(\d+),(\d+):\s+(\d+)x(\d+)$/ | |
| |> Regex.run(str) |
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
| defmodule Checksum do | |
| def countchars(''), do: 0 | |
| def countchars(chars) do | |
| chars | |
| |> Enum.uniq() | |
| |> Enum.map(&countchar(&1, chars)) | |
| end | |
| def countchar(_, []), do: 0 |
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
| defmodule One do | |
| def split(str) do | |
| [String.slice(str, 0..0), String.to_integer(String.slice(str, 1..-1))] | |
| end | |
| def value("+", n), do: n | |
| def value("-", n), do: -n | |
| def split_value(str) do | |
| apply(One, :value, split(str)) |
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
| # Activate the gem you are reporting the issue against. | |
| gem 'activerecord', '4.1.0.beta1' | |
| require 'active_record' | |
| require 'minitest/autorun' | |
| require 'logger' | |
| # Ensure backward compatibility with Minitest 4 | |
| Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
| # This connection will do for database-independent bug reports. |
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
| bundle | |
| Fetching gem metadata from https://****:****@gems.****.co.nz/. | |
| Fetching full source index from https://****:****@gems.****.co.nz/ | |
| Unfortunately, a fatal error has occurred. Please see the Bundler | |
| troubleshooting documentation at http://bit.ly/bundler-issues. Thanks! | |
| /Users/jeremy/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/net/https.rb:138:in `verify_mode=': can't modify frozen object (TypeError) | |
| from /Users/jeremy/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/net/https.rb:138:in `verify_mode=' | |
| from /Users/jeremy/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:337:in `configure_connection_for_https' | |
| from /Users/jeremy/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:323:in `connection_for' | |
| from /Users/jeremy/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:402:in `request' |