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
| USING: kernel random math accessors sequences prettyprint io ; | |
| USING: io.encodings.binary io.files serialize math.parser ; | |
| IN: examples.war | |
| TUPLE: player name hitpoints acc ; | |
| ! We're starting w/ Two sample players on the stack | |
| ! The rule is to always keep them there | |
| "Urg" 20 70 player boa | |
| "Conan" 25 65 player boa | |
| ! "Gwent" 18 95 player boa |
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
| ;; Die Roll stuff | |
| (defn die-roll [numSides] | |
| (int (+ 1 (rand numSides)))) | |
| (defn d4 [] | |
| (die-roll 4)) | |
| (defn d6 [] | |
| (die-roll 6)) |
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 Die do | |
| def init(), do: :random.seed(:erlang.now) | |
| def d6(), do: :random.uniform(6) | |
| def d100(), do: :random.uniform(100) | |
| end | |
| defmodule War do | |
| def create_player(name, skill, hp) do | |
| [ name: name, skill: skill, hp: hp ] | |
| 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 Preso do | |
| # shows what was passed in and then evals it and shoves the | |
| # lhs back into the current context | |
| defmacro show(stuff) do | |
| {op, _, [{lhs,_, _}, rhs]} = stuff | |
| IO.write "#{IO.ANSI.blue}#{IO.ANSI.bright}" | |
| IO.write "#{lhs} #{op} " | |
| IO.inspect rhs | |
| IO.puts "#{IO.ANSI.reset}" | |
| quote 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
| server { | |
| listen 80; | |
| server_name www.demoit.io; | |
| underscores_in_headers on; | |
| listen 443 ssl; | |
| client_max_body_size 500M; | |
| ssl_certificate /etc/nginx/ssl/api_demoit_io.crt; | |
| ssl_certificate_key /etc/nginx/ssl/api_demoit_io.key; | |
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 FileripperTest do | |
| use ExUnit.Case, async: true | |
| @test_files_path "fixtures/test" | |
| setup_all do | |
| File.mkdir_p(@test_files_path) | |
| on_exit fn -> | |
| IO.puts "At the very 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 FileripperTest do | |
| use ExUnit.Case, async: true | |
| @test_files_path "fixtures/test" | |
| setup do | |
| File.mkdir_p(@test_files_path) | |
| on_exit fn -> | |
| IO.puts "End of test case" |
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 Taskrun do | |
| def run(num) do | |
| IO.puts "running sleep task: #{num}" | |
| :timer.sleep(num) | |
| num | |
| end | |
| def launch(num) do | |
| Task.async(Taskrun, :run, [num]) |
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 Catstore do | |
| def start() do | |
| {:ok, store} = Agent.start(fn -> ["Biggles"] end) | |
| store | |
| end | |
| def pr_cats(cats) do | |
| Enum.each(cats, fn cat -> IO.puts cat 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 Catstore.Server do | |
| use GenServer | |
| ## really simple API | |
| def new_store(cats) do | |
| {:ok, store} = GenServer.start_link(Catstore.Server, cats) | |
| store | |
| end | |
| def add(store, cat) do |