Skip to content

Instantly share code, notes, and snippets.

View jodonnell's full-sized avatar

Jacob O'Donnell jodonnell

View GitHub Profile
defmodule Mix.Tasks.Default do
use Mix.Task
@shortdoc "Runs all the tests and the linter"
@moduledoc """
Runs all the tests and the linter
"""
def project do
defmodule Euler.Problem4 do
def parallel do
receive do
{sender, low..high} -> send sender, {:ok, solve_for(low..high)}
end
end
def solve_for(low..high) do
get_list_of_products(low..high)
|> is_palindrome?
[#HashDict<[{"number", 3400}, {"comments", 14},
{"title", "Float.round is inconsistent"},
{"created_at", "2015-06-17T13:04:45Z"}, {"state", "open"}, {"locked", false},
{"url", "https://api.github.com/repos/elixir-lang/elixir/issues/3400"},
{"comments_url",
"https://api.github.com/repos/elixir-lang/elixir/issues/3400/comments"},
{"labels",
[[{"url",
"https://api.github.com/repos/elixir-lang/elixir/labels/App:Elixir"},
{"name", "App:Elixir"}, {"color", "CCCCCC"}],
defmodule Chop do
def guess(n, start..finish) when n > div(finish - start, 2) + start do
IO.puts "Is it #{math(start, finish)}"
guess(n, math(start, finish)..finish)
end
def guess(n, start..finish) when n < div(finish - start, 2) + start do
IO.puts "Is it #{math(start, finish)}"
guess(n, start..math(start, finish))
end
@jodonnell
jodonnell / bam.js
Last active November 5, 2015 00:29
// Model
var Time = function () {
this.time = 0;
}
Time.prototype = {
tick: function (timeElapsed) {
this.time += timeElapsed;
},
puts "You awaken inside the clinic. You can basically only go left."
joke_finished = false
while 1
if joke_finished
puts "Which way do you want to go? N, S, E, W"
direction = gets.chomp
if direction == 'N'
fern
nerf
"fern" -> ["nerf", "erfn", ...]
hash = Hash(a..z) = 0
hash['f'] += 1
hash['e'] += 1
hash['r'] += 1
hash['n'] += 1
does not work:
def run retries = 2
formatter.before_script_run path
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
exit_status = formatter.format stdout
return run(retries - 1) if exit_status != 0 and retries != 0 # difference on this line
raise ScriptFailedError.new('Test Script Failed') if exit_status != 0 and !run_all
end
end
2014-02-18T21:54:02.030567+00:00 heroku[web.1]: source=web.1 dyno=heroku.21649698.ca9cbbc4-b480-4a70-bb0f-37a575e74a74 sample#memory_total=380.26MB sample#memory_rss=380.23MB sample#memory_cache=0.00MB sample#memory_swap=0.03MB sample#memory_pgpgin=0pages sample#memory_pgpgout=128062pages
2014-02-18T21:54:21.888493+00:00 heroku[web.1]: source=web.1 dyno=heroku.21649698.ca9cbbc4-b480-4a70-bb0f-37a575e74a74 sample#memory_total=401.49MB sample#memory_rss=401.43MB sample#memory_cache=0.01MB sample#memory_swap=0.05MB sample#memory_pgpgin=0pages sample#memory_pgpgout=157417pages
2014-02-18T21:54:41.936531+00:00 heroku[web.1]: source=web.1 dyno=heroku.21649698.ca9cbbc4-b480-4a70-bb0f-37a575e74a74 sample#memory_total=419.76MB sample#memory_rss=419.69MB sample#memory_cache=0.01MB sample#memory_swap=0.07MB sample#memory_pgpgin=0pages sample#memory_pgpgout=175993pages
2014-02-18T21:55:01.808358+00:00 heroku[web.1]: source=web.1 dyno=heroku.21649698.ca9cbbc4-b480-4a70-bb0f-37a575e74a74 sample#memory_total=419.77MB sample