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
if System.get_env("EXERCISM_TEST_EXAMPLES") do | |
Code.load_file("example.exs") | |
else | |
Code.load_file("point_mutations.exs") | |
end | |
ExUnit.start | |
defmodule DNATest do | |
use ExUnit.Case, async: 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
list = for i <- 1..4, do: <<255>> | |
my_int = :crypto.bytes_to_integer(:erlang.list_to_binary list) | |
iex> Enum.reduce(1..255, [], fn(x, acc) -> [x|acc] end) |> IO.iodata_to_binary |> byte_size | |
255 | |
iex(7)> :crypto.bytes_to_integer(:erlang.list_to_binary list) | |
16777215 | |
iex(96)> <<a::1, rest::bitstring>> = :erlang.integer_to_binary 0b00000001 |
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
# These are most of the Ecto touchpoints within Phoenix. | |
# I may have missed a few though. | |
# / | |
## mix.exs | |
:postgrex, :phoenix_ecto | |
# web/ | |
## web.ex | |
* controller & channel |
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
defmodule AssertMore do | |
@moduledoc """ | |
More assert functions. | |
""" | |
import ExUnit.Assertions, only: [assert: 1, assert: 2] | |
@doc """ | |
Asserts that two data structures are equal, except certain keys. | |
The data structures can be nested, such as maps with lists with maps. |
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
for i<-1..100,r=&(rem(&1, &2)==0 && &3),x=(r.(i,15,"FizzBuzz")||r.(i,5,"Buzz")||r.(i,3,"Fizz")||i),do: IO.write "#{x} " |
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
import Graphics.Element exposing (show) | |
main = show (iterate 100) | |
fizzbuzz : Int -> String | |
fizzbuzz n = | |
if | mod n 15 -> "FizzBuzz" | |
| mod n 5 -> "Buzz" | |
| mod n 3 -> "Fizz" | |
| otherwise -> toString n |
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
module DiscoBoxen where | |
import Array exposing (fromList, get) | |
import Color exposing (Color, black, white, green, red, blue, yellow, brown, purple, orange) | |
import Graphics.Element exposing (Element, spacer, color, flow, right, show) | |
import List exposing (foldr, (::)) | |
import Random exposing (generate, initialSeed) | |
import Time exposing (every, millisecond, second) | |
drawSquare : Int -> Int -> Color -> Element |
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
iex(134)> m=String;for x<-0..10,y=x<1&&"*"||x>9&&"H"||"0",z=1<x&&x<10&& m.rjust("0",x-1,?0)||"",do: IO.puts m.rjust(z,8)<>y<>z | |
* | |
0 | |
000 | |
00000 | |
0000000 | |
000000000 | |
00000000000 | |
0000000000000 | |
000000000000000 |
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
defmodule Phtest.OrientConnector do | |
use Jazz | |
@base_url "http://localhost:2480/" | |
@database "Phtest" | |
@user "admin" | |
@password "admin" | |
@basic_auth [basic_auth: {@user, @password}] | |
def get(document_id, type) do | |
OrientConnector.get_document(document_id) |
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
import os | |
import subprocess | |
import sys | |
import string | |
import re | |
for dir, subdir, files in os.walk( sys.argv[1] ): | |
for filename in files: | |
# ignore OSX fs file | |
if( filename != ".DS_Store"): |
OlderNewer