From bd55cf1f2491a8324e20648aa112c40e67d90324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 21 May 2021 15:45:55 +0200 Subject: [PATCH] Add Elixir sample --- test/samples-all.generated.js | 4 ++ test/samples/sample.elixir.txt | 80 +++++++++++++++++++++++++ website/index/samples/sample.elixir.txt | 80 +++++++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 test/samples/sample.elixir.txt create mode 100644 website/index/samples/sample.elixir.txt diff --git a/test/samples-all.generated.js b/test/samples-all.generated.js index a9c76af4..0401c885 100644 --- a/test/samples-all.generated.js +++ b/test/samples-all.generated.js @@ -112,6 +112,10 @@ define([], function() { return[ "name": "sample.dockerfile.txt", "content": "FROM mono:3.12\r\n\r\nENV KRE_FEED https://www.myget.org/F/aspnetvnext/api/v2\r\nENV KRE_USER_HOME /opt/kre\r\n\r\nRUN apt-get -qq update && apt-get -qqy install unzip \r\n\r\nONBUILD RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.sh | sh\r\nONBUILD RUN bash -c \"source $KRE_USER_HOME/kvm/kvm.sh \\\r\n && kvm install latest -a default \\\r\n && kvm alias default | xargs -i ln -s $KRE_USER_HOME/packages/{} $KRE_USER_HOME/packages/default\"\r\n\r\n# Install libuv for Kestrel from source code (binary is not in wheezy and one in jessie is still too old)\r\nRUN apt-get -qqy install \\\r\n autoconf \\\r\n automake \\\r\n build-essential \\\r\n libtool \r\nRUN LIBUV_VERSION=1.0.0-rc2 \\\r\n && curl -sSL https://github.com/joyent/libuv/archive/v${LIBUV_VERSION}.tar.gz | tar zxfv - -C /usr/local/src \\\r\n && cd /usr/local/src/libuv-$LIBUV_VERSION \\\r\n && sh autogen.sh && ./configure && make && make install \\\r\n && rm -rf /usr/local/src/libuv-$LIBUV_VERSION \\\r\n && ldconfig\r\n\r\nENV PATH $PATH:$KRE_USER_HOME/packages/default/bin\r\n\r\n# Extra things to test\r\nRUN echo \"string at end\"\r\nRUN echo must work 'some str' and some more\r\nRUN echo hi this is # not a comment\r\nRUN echo 'String with ${VAR} and another $one here'" }, + { + "name": "sample.elixir.txt", + "content": "# Elixir is a dynamic, functional language for building scalable\n# and maintainable applications. Learn more: https://elixir-lang.org\n\n\"Elixir\" |> String.graphemes() |> Enum.frequencies()\n#=> %{\"E\" => 1, \"i\" => 2, \"l\" => 1, \"r\" => 1, \"x\" => 1}\n\n\n### Scalability ###\n\n# All Elixir code runs inside lightweight threads of execution (called processes)\n# that are isolated and exchange information via messages:\n\ncurrent_process = self()\n\n# Spawn an Elixir process (not an operating system one!)\nspawn_link(fn ->\n send(current_process, {:msg, \"hello world\"})\nend)\n\n# Block until the message is received\nreceive do\n {:msg, contents} -> IO.puts(contents)\nend\n\n\n### Fault-tolerance ###\n\n# To cope with failures, Elixir provides supervisors which describe\n# how to restart parts of your system when things go awry, going back\n# to a known initial state that is guaranteed to work:\n\nchildren = [\n TCP.Pool,\n {TCP.Acceptor, port: 4040}\n]\n\nSupervisor.start_link(children, strategy: :one_for_one)\n\n\n### Functional programming ###\n\n# Functional programming promotes a coding style that helps\n# developers write code that is short, concise, and maintainable.\n# One prominent example is pattern matching:\n\n%User{name: name, age: age} = User.get(\"John Doe\")\nname #=> \"John Doe\"\n\n# When mixed with guards, pattern matching allows us to elegantly\n# match and assert specific conditions for some code to execute:\n\ndef drive(%User{age: age}) when age >= 16 do\n # Code that drives a car\nend\n\ndrive(User.get(\"John Doe\"))\n#=> Fails if the user is under 16\n\n\n### Extensibility and DSLs ###\n\n# Elixir has been designed to be extensible, letting developers\n# naturally extend the language to particular domains,\n# in order to increase their productivity.\n\ndefmodule MathTest do\n use ExUnit.Case, async: true\n\n test \"can add two numbers\" do\n assert 1 + 1 == 2\n end\nend\n\n\n### Erlang compatible ###\n\n# An Elixir programmer can invoke any Erlang function with no runtime cost:\n\n:crypto.hash(:md5, \"Using crypto from Erlang OTP\")\n#=> <<192, 223, 75, 115, ...>>\n" + }, { "name": "sample.fsharp.txt", "content": "(* Sample F# application *)\r\n[]\r\nlet main argv = \r\n printfn \"%A\" argv\r\n System.Console.WriteLine(\"Hello from F#\")\r\n 0 // return an integer exit code\r\n\r\n//-------------------------------------------------------- \r\n" diff --git a/test/samples/sample.elixir.txt b/test/samples/sample.elixir.txt new file mode 100644 index 00000000..f0d187e6 --- /dev/null +++ b/test/samples/sample.elixir.txt @@ -0,0 +1,80 @@ +# Elixir is a dynamic, functional language for building scalable +# and maintainable applications. Learn more: https://elixir-lang.org + +"Elixir" |> String.graphemes() |> Enum.frequencies() +#=> %{"E" => 1, "i" => 2, "l" => 1, "r" => 1, "x" => 1} + + +### Scalability ### + +# All Elixir code runs inside lightweight threads of execution (called processes) +# that are isolated and exchange information via messages: + +current_process = self() + +# Spawn an Elixir process (not an operating system one!) +spawn_link(fn -> + send(current_process, {:msg, "hello world"}) +end) + +# Block until the message is received +receive do + {:msg, contents} -> IO.puts(contents) +end + + +### Fault-tolerance ### + +# To cope with failures, Elixir provides supervisors which describe +# how to restart parts of your system when things go awry, going back +# to a known initial state that is guaranteed to work: + +children = [ + TCP.Pool, + {TCP.Acceptor, port: 4040} +] + +Supervisor.start_link(children, strategy: :one_for_one) + + +### Functional programming ### + +# Functional programming promotes a coding style that helps +# developers write code that is short, concise, and maintainable. +# One prominent example is pattern matching: + +%User{name: name, age: age} = User.get("John Doe") +name #=> "John Doe" + +# When mixed with guards, pattern matching allows us to elegantly +# match and assert specific conditions for some code to execute: + +def drive(%User{age: age}) when age >= 16 do + # Code that drives a car +end + +drive(User.get("John Doe")) +#=> Fails if the user is under 16 + + +### Extensibility and DSLs ### + +# Elixir has been designed to be extensible, letting developers +# naturally extend the language to particular domains, +# in order to increase their productivity. + +defmodule MathTest do + use ExUnit.Case, async: true + + test "can add two numbers" do + assert 1 + 1 == 2 + end +end + + +### Erlang compatible ### + +# An Elixir programmer can invoke any Erlang function with no runtime cost: + +:crypto.hash(:md5, "Using crypto from Erlang OTP") +#=> <<192, 223, 75, 115, ...>> diff --git a/website/index/samples/sample.elixir.txt b/website/index/samples/sample.elixir.txt new file mode 100644 index 00000000..f0d187e6 --- /dev/null +++ b/website/index/samples/sample.elixir.txt @@ -0,0 +1,80 @@ +# Elixir is a dynamic, functional language for building scalable +# and maintainable applications. Learn more: https://elixir-lang.org + +"Elixir" |> String.graphemes() |> Enum.frequencies() +#=> %{"E" => 1, "i" => 2, "l" => 1, "r" => 1, "x" => 1} + + +### Scalability ### + +# All Elixir code runs inside lightweight threads of execution (called processes) +# that are isolated and exchange information via messages: + +current_process = self() + +# Spawn an Elixir process (not an operating system one!) +spawn_link(fn -> + send(current_process, {:msg, "hello world"}) +end) + +# Block until the message is received +receive do + {:msg, contents} -> IO.puts(contents) +end + + +### Fault-tolerance ### + +# To cope with failures, Elixir provides supervisors which describe +# how to restart parts of your system when things go awry, going back +# to a known initial state that is guaranteed to work: + +children = [ + TCP.Pool, + {TCP.Acceptor, port: 4040} +] + +Supervisor.start_link(children, strategy: :one_for_one) + + +### Functional programming ### + +# Functional programming promotes a coding style that helps +# developers write code that is short, concise, and maintainable. +# One prominent example is pattern matching: + +%User{name: name, age: age} = User.get("John Doe") +name #=> "John Doe" + +# When mixed with guards, pattern matching allows us to elegantly +# match and assert specific conditions for some code to execute: + +def drive(%User{age: age}) when age >= 16 do + # Code that drives a car +end + +drive(User.get("John Doe")) +#=> Fails if the user is under 16 + + +### Extensibility and DSLs ### + +# Elixir has been designed to be extensible, letting developers +# naturally extend the language to particular domains, +# in order to increase their productivity. + +defmodule MathTest do + use ExUnit.Case, async: true + + test "can add two numbers" do + assert 1 + 1 == 2 + end +end + + +### Erlang compatible ### + +# An Elixir programmer can invoke any Erlang function with no runtime cost: + +:crypto.hash(:md5, "Using crypto from Erlang OTP") +#=> <<192, 223, 75, 115, ...>>