├── .gitattributes ├── alpaca ├── README.md └── hello_world │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── rebar.config │ ├── rebar.lock │ └── src │ ├── hello_world.alp │ ├── hello_world.app.src │ ├── hello_world_app.erl │ ├── hello_world_sup.alp │ ├── hello_world_sup_old.erl │ └── test_helpers.alp ├── bug-reports └── unicode_print_error │ ├── .gitignore │ ├── README.md │ ├── out.txt │ ├── rebar.config │ └── src │ ├── unicode_print_error.app.src │ └── unicode_print_error.erl ├── c ├── .gitignore ├── README.md ├── a_modern_approach │ ├── README.md │ ├── chapter-01 │ │ ├── 04_dweight.c │ │ └── makefile │ └── chapter-02 │ │ ├── 00_scanf.c │ │ ├── 04_dweight.c │ │ ├── 05_dweight.c │ │ ├── ex1.c │ │ ├── ex2.c │ │ ├── ex3.c │ │ ├── ex4.c │ │ ├── ex5.c │ │ └── makefile ├── exercism │ └── hamming │ │ ├── build │ │ └── .gitignore │ │ ├── makefile │ │ ├── src │ │ ├── hamming.c │ │ └── hamming.h │ │ └── test │ │ ├── test_hamming.c │ │ └── vendor │ │ ├── unity.c │ │ ├── unity.h │ │ └── unity_internals.h ├── scratch │ ├── backwards_while.c │ ├── factorial.c │ ├── linked_list_single.c │ ├── makefile │ ├── product.c │ └── vector.c └── tdd │ ├── makefile │ ├── src │ └── main.c │ └── test │ ├── main.c │ └── vendor │ ├── unity.c │ ├── unity.h │ ├── unity_fixture.c │ ├── unity_fixture.h │ ├── unity_fixture_internals.h │ ├── unity_fixture_malloc_overrides.h │ └── unity_internals.h ├── clojure ├── .gitignore ├── README.md ├── overtone-gentle-intro │ ├── .gitignore │ ├── README.md │ ├── doc │ │ └── intro.md │ ├── project.clj │ ├── src │ │ └── overtone_gentle_intro │ │ │ └── part_one.clj │ └── test │ │ └── overtone_gentle_intro │ │ └── core_test.clj ├── overtone-scratch │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── doc │ │ └── intro.md │ ├── project.clj │ ├── src │ │ └── overtone_scratch │ │ │ ├── core.clj │ │ │ ├── one.clj │ │ │ └── two.clj │ └── test │ │ └── overtone_scratch │ │ └── core_test.clj ├── quil-experiments │ ├── .gitignore │ ├── README.md │ ├── project.clj │ ├── src │ │ └── quil_experiments │ │ │ ├── one │ │ │ ├── core.clj │ │ │ └── dynamic.clj │ │ │ └── two │ │ │ ├── core.clj │ │ │ └── dynamic.clj │ └── test │ │ └── quil_experiments │ │ └── two │ │ └── dynamic_test.clj └── test_test │ ├── README.md │ ├── project.clj │ ├── src │ └── test_test │ │ └── core.clj │ └── test │ └── test_test │ └── core_test.clj ├── crystal └── sum │ ├── .editorconfig │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── shard.yml │ ├── spec │ ├── spec_helper.cr │ └── sum_spec.cr │ └── src │ └── sum.cr ├── do └── rolling │ ├── .gitignore │ ├── README.md │ └── dev │ ├── check_health.sh │ ├── main.tf │ └── test.sh ├── elixir ├── .gitignore ├── README.md ├── anagram │ ├── README.md │ ├── anagram.exs │ └── anagram_test.exs ├── baraxx │ ├── .formatter.exs │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── apps │ │ ├── core │ │ │ ├── .formatter.exs │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── config │ │ │ │ └── config.exs │ │ │ ├── lib │ │ │ │ ├── core.ex │ │ │ │ └── core │ │ │ │ │ └── application.ex │ │ │ ├── mix.exs │ │ │ └── test │ │ │ │ ├── core_test.exs │ │ │ │ └── test_helper.exs │ │ └── web │ │ │ ├── .formatter.exs │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── config │ │ │ └── config.exs │ │ │ ├── lib │ │ │ ├── web.ex │ │ │ └── web │ │ │ │ ├── application.ex │ │ │ │ └── router.ex │ │ │ ├── mix.exs │ │ │ └── test │ │ │ ├── test_helper.exs │ │ │ └── web_test.exs │ ├── config │ │ └── config.exs │ ├── mix.exs │ ├── mix.lock │ └── rel │ │ └── config.exs ├── delegate-genserver-call │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ └── del.ex │ ├── mix.exs │ └── test │ │ ├── del_test.exs │ │ └── test_helper.exs ├── elixir_appengine │ ├── .formatter.exs │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── app.yaml │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── app.ex │ │ └── app │ │ │ └── application.ex │ ├── mix.exs │ ├── mix.lock │ └── test │ │ ├── app_test.exs │ │ └── test_helper.exs ├── exq-explore │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── exqy.ex │ │ └── exqy │ │ │ └── application.ex │ ├── mix.exs │ ├── mix.lock │ └── test │ │ ├── exqy_test.exs │ │ └── test_helper.exs ├── first_app │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── first_app.ex │ │ └── first_app │ │ │ ├── bucket.ex │ │ │ └── registry.ex │ ├── mix.exs │ └── test │ │ ├── first_app │ │ ├── bucket_test.exs │ │ └── registry_test.exs │ │ ├── first_app_test.exs │ │ └── test_helper.exs ├── gilded-rose-refactoring-kata │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── gilded_rose.ex │ │ ├── item.ex │ │ └── item │ │ │ ├── backstage_pass.ex │ │ │ ├── brie.ex │ │ │ ├── magic.ex │ │ │ ├── plain.ex │ │ │ └── sulfuras.ex │ ├── mix.exs │ ├── mix.lock │ └── test │ │ ├── gilded_rose_test.exs │ │ └── test_helper.exs ├── lyse-sockets │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── naive_tcp.ex │ │ ├── para_tcp.ex │ │ └── sockets.ex │ ├── mix.exs │ └── test │ │ ├── sockets_test.exs │ │ └── test_helper.exs ├── lyse_concurrent_app │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── event.ex │ │ ├── event_server.ex │ │ └── lyse.ex │ ├── mix.exs │ ├── mix.lock │ └── test │ │ ├── event_server_test.exs │ │ ├── event_test.exs │ │ ├── lyse_test.exs │ │ └── test_helper.exs ├── lyse_kitty_server │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ ├── kitty.ex │ │ └── kitty_server.ex │ ├── mix.exs │ └── test │ │ ├── kitty_test.exs │ │ └── test_helper.exs ├── next_break_fits │ ├── .formatter.exs │ ├── .gitignore │ ├── README.md │ ├── lib │ │ └── next_break_fits.ex │ ├── mix.exs │ └── test │ │ ├── next_break_fits_test.exs │ │ └── test_helper.exs ├── reactive │ ├── 7_2_actor_model.exs │ └── README.md ├── scratch │ ├── 01.exs │ ├── 02-UPCASE.exs │ ├── char-stream.exs │ ├── fizzbuzz.exs │ ├── hanoi.exs │ └── largest_divisible.exs ├── streamy_data │ ├── .formatter.exs │ ├── .gitignore │ ├── README.md │ ├── config │ │ └── config.exs │ ├── lib │ │ └── streamy_data.ex │ ├── mix.exs │ ├── mix.lock │ └── test │ │ ├── streamy_data_test.exs │ │ └── test_helper.exs └── unix-sockets │ ├── socket.exs │ └── socket.js ├── elm ├── .gitignore ├── README.md ├── buttons │ ├── App.elm │ └── elm-package.json ├── checkbox │ ├── App.elm │ └── elm-package.json ├── counter-pair │ ├── .gitignore │ ├── App.elm │ ├── Counter.elm │ └── elm-package.json ├── elm-package.json ├── fields │ ├── App.elm │ └── elm-package.json ├── form │ ├── App.elm │ └── elm-package.json ├── hello-world │ ├── README.md │ ├── elm-package.json │ └── main.elm ├── http │ ├── App.elm │ └── elm-package.json ├── json │ ├── Makefile │ ├── src │ │ └── Lib.elm │ └── tests │ │ ├── .gitignore │ │ ├── TestRunner.elm │ │ ├── Tests.elm │ │ └── elm-package.json ├── markdown │ ├── App.elm │ ├── README.md │ └── elm-package.json ├── random │ ├── App.elm │ └── elm-package.json └── time │ ├── App.elm │ └── elm-package.json ├── erlang ├── fb_birth_death.erl └── lumen_test │ ├── .github │ └── workflows │ │ └── test.yml │ ├── .gitignore │ └── init.erl ├── fsharp └── hello-world │ ├── .gitignore │ ├── Program.fs │ └── hello-world.fsproj ├── gcp ├── Makefile ├── README.md ├── gcp-simple-deploy │ ├── .gitignore │ ├── README.md │ ├── bin │ │ └── deploy │ ├── env │ │ └── dev │ │ │ └── main.tf │ └── modules │ │ └── app │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── startup_script.template.sh │ │ └── variables.tf └── infra │ ├── deployment.mk │ └── deployment.yml ├── gleam ├── bubbles │ ├── .github │ │ └── workflows │ │ │ └── test.yml │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── gleam.toml │ ├── rebar.config │ ├── src │ │ ├── bubbles.app.src │ │ ├── bubbles.gleam │ │ └── factory.gleam │ └── test │ │ └── bubbles_test.gleam └── clippy │ ├── .github │ └── workflows │ │ └── test.yml │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── gleam.toml │ ├── rebar.config │ ├── rebar.lock │ ├── src │ ├── clippy.app.src │ └── clippy.gleam │ └── test │ └── clippy_test.gleam ├── glsl ├── .gitignore ├── README.md └── shader-school │ ├── 00-intro-0 │ └── hello.glsl │ ├── 01-intro-1 │ └── hello.glsl │ ├── 02-intro-2 │ └── sides.glsl │ ├── 03-intro-3 │ └── vectors.glsl │ ├── 04-intro-4 │ └── box.glsl │ ├── 05-intro-5 │ └── mandelbrot.glsl │ ├── 06-intro-6 │ └── mpow.glsl │ ├── 07-frag-1 │ └── fragment.glsl │ ├── 08-frag-2 │ └── fragment.glsl │ ├── 09-frag-3 │ └── fragment.glsl │ ├── 10-vert-1 │ └── vertex.glsl │ ├── 11-vert-2 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 12-geom-1 │ └── transforms.glsl │ ├── 13-geom-2 │ └── translate.glsl │ ├── 14-geom-3 │ └── scale.glsl │ ├── 15-geom-4 │ └── reflect.glsl │ ├── 16-geom-5 │ └── rotate.glsl │ ├── 17-light-1 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 18-light-2 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 19-light-3 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 20-light-4 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 21-light-5 │ ├── fragment.glsl │ ├── light.glsl │ └── vertex.glsl │ ├── 22-npr-1 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 23-npr-2 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 24-gpgpu-1 │ └── life.glsl │ ├── 25-gpgpu-2 │ └── heat.glsl │ ├── 26-gpgpu-3 │ └── wave.glsl │ ├── 27-prims-1 │ ├── fragment.glsl │ └── vertex.glsl │ ├── 28-prims-2 │ └── fragment.glsl │ ├── 29-playground-flocking │ ├── position.glsl │ ├── render.frag │ ├── render.vert │ ├── speed.glsl │ └── triangle.glsl │ ├── 30-playground-gpgpu │ ├── render.glsl │ └── update.glsl │ ├── Makefile │ └── package.json ├── go ├── .gitignore ├── aws-lambda-http-shim │ ├── .gitignore │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── Makefile │ ├── README.md │ ├── serverless.yml │ └── src │ │ └── main.go ├── aws-lambda-http │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── hello │ │ └── main.go │ ├── serverless.yml │ └── world │ │ └── main.go ├── buffalo-tutorial │ ├── .babelrc │ ├── .buffalo.dev.yml │ ├── .codeclimate.yml │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── README.md │ ├── actions │ │ ├── actions_test.go │ │ ├── app.go │ │ ├── auth.go │ │ ├── auth_test.go │ │ ├── home.go │ │ ├── home_test.go │ │ ├── render.go │ │ ├── users.go │ │ └── users_test.go │ ├── assets │ │ ├── css │ │ │ ├── _buffalo.scss │ │ │ └── application.scss │ │ ├── images │ │ │ ├── favicon.ico │ │ │ └── logo.svg │ │ └── js │ │ │ └── application.js │ ├── config │ │ ├── buffalo-app.toml │ │ └── buffalo-plugins.toml │ ├── database.yml │ ├── fixtures │ │ └── sample.toml │ ├── go.mod │ ├── go.sum │ ├── grifts │ │ ├── db.go │ │ └── init.go │ ├── inflections.json │ ├── locales │ │ └── all.en-us.yaml │ ├── main.go │ ├── migrations │ │ ├── 20200606115610_create_users.down.fizz │ │ └── 20200606115610_create_users.up.fizz │ ├── models │ │ ├── models.go │ │ ├── models_test.go │ │ ├── user.go │ │ └── user_test.go │ ├── package.json │ ├── postcss.config.js │ ├── public │ │ └── robots.txt │ ├── templates │ │ ├── _flash.plush.html │ │ ├── application.plush.html │ │ ├── auth │ │ │ ├── landing.plush.html │ │ │ └── new.plush.html │ │ ├── index.plush.html │ │ └── users │ │ │ └── new.plush.html │ ├── webpack.config.js │ └── yarn.lock ├── calculator │ ├── .gitignore │ ├── Makefile │ └── src │ │ ├── calculator.go │ │ └── calculator_test.go ├── flags │ ├── .gitignore │ ├── Gopkg.lock │ ├── Gopkg.toml │ └── fake-sonic-pi-tool.go ├── hello-world │ └── main.go ├── http-client │ ├── .gitignore │ └── furl.go ├── http-server │ ├── Makefile │ └── main.go ├── interface-visitor │ ├── .gitignore │ ├── Makefile │ └── src │ │ ├── calculator.go │ │ └── calculator_test.go ├── shared-value │ └── main.go ├── simple-server │ ├── .gitignore │ ├── Dockerfile │ ├── go.mod │ ├── go.sum │ └── simple-server.go ├── test-runner │ ├── cmd │ │ └── tester.go │ ├── go.mod │ ├── go.sum │ └── internal │ │ └── check │ │ ├── check.go │ │ ├── check_result.go │ │ ├── check_result_test.go │ │ ├── check_test.go │ │ └── one.go ├── test-wrapper │ ├── go.mod │ ├── go.sum │ └── main_test.go ├── testing │ ├── main.go │ └── main_test.go └── workflow-graph │ ├── Makefile │ ├── README.md │ ├── bin │ └── brook │ ├── cmd │ └── brook │ │ └── main.go │ ├── go.mod │ ├── go.sum │ └── internal │ └── pkg │ ├── database │ ├── database.go │ ├── link.go │ ├── step.go │ └── steps_test.go │ ├── transcode │ └── service.go │ └── workflow │ ├── step.go │ ├── step_check_size.go │ ├── step_transcode.go │ └── visitor_exec.go ├── haskell ├── .gitignore ├── HiAgainWorld.hs ├── README.md ├── beautiful-concurrency │ ├── LICENSE │ ├── README.md │ ├── Setup.hs │ ├── beautiful-concurrency.cabal │ ├── package.yaml │ ├── src │ │ └── Main.hs │ └── stack.yaml ├── brent-yorgeys-cis194 │ ├── 01-introduction │ │ ├── README.md │ │ ├── hw-creditcard.hs │ │ └── hw-hanoi.hs │ ├── 02-working-with-lists │ │ ├── README.md │ │ ├── hw.hs │ │ ├── words.hs │ │ └── words.txt │ ├── 03-algebraic-data-types │ │ ├── README.md │ │ └── lecture.hs │ └── README.md ├── bricky │ ├── LICENSE │ ├── README.md │ ├── Setup.hs │ ├── app │ │ └── Main.hs │ ├── bricky.cabal │ ├── package.yaml │ ├── src │ │ └── Lib.hs │ ├── stack.yaml │ └── test │ │ └── Spec.hs ├── csound-expression │ ├── tut-01-intro.lhs │ ├── tut-02-basictypes-1-signals.lhs │ └── tut-02-basictypes-2-constants.lhs ├── edx-fp101x │ ├── 03-hw-0.hs │ ├── 03-hw-1.hs │ ├── 03-hw-2.hs │ ├── 03-hw-3.hs │ ├── 04-hw-03.hs │ ├── 04-hw-04.hs │ ├── 04-hw-05.hs │ ├── 04-hw-07.hs │ ├── 04-hw-13.hs │ ├── 05-hw-00.hs │ ├── 05-lab.hs │ ├── 06-hw-01.hs │ ├── 06-hw-02.hs │ ├── 06-hw-05.hs │ ├── 06-lab.hs │ ├── 07-hw.hs │ ├── 08-hw-02.hs │ ├── 08-lec.hs │ ├── 10-lec.hs │ └── README.md ├── fizzbuzz.hs ├── hanoi.hs ├── haskell-exchange-2018.md ├── hsc3-play │ ├── LICENSE │ ├── Main.hs │ ├── README.md │ ├── Setup.hs │ └── hsc3-play.cabal ├── largestDivisible.hs ├── magic.lhs ├── megaparse │ ├── LICENSE │ ├── README.md │ ├── Setup.hs │ ├── app │ │ └── Main.hs │ ├── megaparse.cabal │ ├── stack.yaml │ └── test │ │ └── Spec.hs ├── okc.hs ├── prelude-remake │ ├── README.md │ ├── abs.hs │ ├── all.hs │ ├── ampamp.hs │ ├── and.hs │ ├── any.hs │ ├── bangBang.hs │ ├── concat.hs │ ├── curry.hs │ ├── cycle.hs │ ├── div.hs │ ├── dot.hs │ ├── drop.hs │ ├── dropWhile.hs │ ├── elem.hs │ ├── even.hs │ ├── filter.hs │ ├── flip.hs │ ├── fst.hs │ ├── hat.hs │ ├── head.hs │ ├── id.hs │ ├── init.hs │ ├── iterate.hs │ ├── last.hs │ ├── length.hs │ ├── lookup.hs │ ├── map.hs │ ├── min.hs │ ├── minimum.hs │ ├── negate.hs │ ├── not.hs │ ├── notElem.hs │ ├── null.hs │ ├── odd.hs │ ├── or.hs │ ├── otherwise.hs │ ├── pipepipe.hs │ ├── product.hs │ ├── repeat.hs │ ├── reverse.hs │ ├── sum.hs │ ├── tail.hs │ ├── takeWhile.hs │ ├── uncurry.hs │ ├── until.hs │ ├── unzip.hs │ ├── zip.hs │ └── zipWith.hs ├── quicksort.hs ├── sieveOfEratosthenes.hs ├── testing │ └── spec │ │ └── head-spec.hs ├── thinking-functionally │ ├── .gitignore │ ├── README.md │ ├── Setup.hs │ ├── app │ │ └── Main.hs │ ├── src │ │ ├── Chapter01.hs │ │ └── Lib.hs │ ├── stack.yaml │ ├── test │ │ ├── Chapter01Spec.hs │ │ └── Spec.hs │ └── thinking-functionally.cabal └── turtle-tutorial │ ├── README.md │ ├── eight.hs │ ├── five.hs │ ├── four.hs │ ├── one.hs │ ├── seven.hs │ ├── six.hs │ ├── three.hs │ └── two.hs ├── idris ├── .gitignore └── misc │ ├── HelloWorld.idr │ ├── Pipeline.idr │ ├── Repl.idr │ ├── StringOrInt.idr │ └── TDDExercises.idr ├── javascript ├── .gitignore ├── character-count.js ├── codeabbey │ ├── 000-sum-a-b.js │ ├── 001-sum-in-loop.js │ ├── 002-sums-in-loop.js │ ├── 003-min-of-two.js │ ├── 004-min-of-three.js │ ├── 005-max-of-arr.js │ ├── 006-rounding-no-vars.js │ ├── 006-rounding.js │ ├── 007-far-to-cel.js │ ├── 008-vowel-count.js │ ├── 009-median-of-three.js │ ├── 010-bmi.js │ ├── 011-dice-rolling.js │ ├── 012-weighted-sum-digits.js │ ├── 013-sum-of-digits.js │ ├── 014-average-of-array.js │ └── README.md ├── deno │ └── server-example.ts ├── egghead-angular │ ├── .jshintrc │ ├── 11-ui-router-state-params │ │ ├── app │ │ │ ├── categories │ │ │ │ ├── bookmarks │ │ │ │ │ ├── bookmarks.js │ │ │ │ │ ├── bookmarks.tmpl.html │ │ │ │ │ ├── create │ │ │ │ │ │ ├── bookmark-create.js │ │ │ │ │ │ └── bookmark-create.tmpl.html │ │ │ │ │ └── edit │ │ │ │ │ │ ├── bookmark-edit.js │ │ │ │ │ │ └── bookmark-edit.tmpl.html │ │ │ │ ├── categories.js │ │ │ │ └── categories.tmpl.html │ │ │ ├── common │ │ │ │ └── models │ │ │ │ │ ├── bookmarks-model.js │ │ │ │ │ └── categories-model.js │ │ │ └── main.js │ │ └── index.html │ ├── README.md │ └── server.sh ├── nodeschool-bug-clinic │ ├── 00-intake.js │ └── 01-triage.js ├── nodeschool-learnyounode │ ├── 00-hello-world.js │ ├── 01-baby-steps.js │ ├── 02-my-first-io.js │ ├── 03-my-first-async-io.js │ ├── 04-filtered-ls.js │ ├── 05-make-it-modular.js │ ├── 05-z-module.js │ ├── 06-http-client.js │ ├── 07-http-collect.js │ ├── 08-juggling-async.js │ ├── 09-time-server.js │ ├── 10-http-file-server.js │ ├── 11-http-uppercaser.js │ ├── 12-http-json-api-server.js │ └── README.md └── nodeschool-stream-adventure │ ├── 00-bleep-boop.js │ ├── 01-meet-pipe.js │ ├── 02-input-output.js │ ├── 03-transform.js │ ├── 04-lines.js │ ├── 05-concat.js │ ├── 06-http-server.js │ ├── 07-http-client.js │ ├── 08-websockets.js │ ├── 09-html-stream.js │ ├── 10-duplexer.js │ ├── 11-duplexer-redux.js │ ├── 12-combiner.js │ └── README.md ├── kubernetes ├── cheap │ ├── .gitignore │ ├── README.md │ ├── bin │ │ ├── infra │ │ └── k8s │ ├── infra │ │ ├── env │ │ │ └── ops │ │ │ │ └── main.tf │ │ └── modules │ │ │ └── infra │ │ │ ├── main.tf │ │ │ ├── outputs.tf │ │ │ └── variables.tf │ └── k8s │ │ ├── env │ │ └── dev │ │ │ └── main.tf │ │ └── modules │ │ └── app │ │ ├── app_ingress.template.yml │ │ ├── main.tf │ │ └── variables.tf ├── k3s-multiple-apps-test │ └── stack.yml └── kuard │ ├── README.md │ ├── bin │ └── book-services-setup.sh │ ├── kuard-deployment.yml │ ├── kuard-pod.yml │ ├── kuard-replicaset.yml │ ├── kuard-with-config-pod.yml │ ├── my-config.yml │ └── oneshot-job.yml ├── lua └── hello_world.lua ├── music ├── README.md └── miller-puckette-book │ ├── README.md │ ├── p_016.pd │ ├── p_020_additive.pd │ ├── p_020_dbtoorms.pd │ ├── p_020_lin-amp.pd │ ├── p_023_freq_midi_conversion.pd │ ├── p_024_additive_major_triad.pd │ └── p_025_beating_and_exercises.pd ├── nix ├── hello-world │ └── shell.nix ├── nix-ssh-deploy │ ├── README.md │ ├── bin │ │ └── deploy.sh │ └── src │ │ ├── configuration.nix │ │ ├── hardware-configuration.nix │ │ ├── networking.nix │ │ └── ssh.nix └── nixops-hello-world │ ├── README.md │ └── droplet.nix ├── ocaml ├── .gitignore ├── README.md ├── hello-bucklescript │ ├── .gitignore │ ├── README.md │ ├── bsconfig.json │ ├── package.json │ ├── src │ │ └── demo.re │ └── tasks.json ├── hello-jbuilder │ ├── .merlin │ ├── hello_world.ml │ ├── jbuild │ └── test_mod.ml ├── jbuilder-reason │ ├── Makefile │ ├── bin │ │ └── watch.sh │ └── src │ │ ├── .merlin │ │ ├── Main.re │ │ └── jbuild ├── real-world-mod-and-programs │ ├── .merlin │ ├── Counter.ml │ ├── Counter.mli │ ├── Makefile │ ├── jbuild │ └── program.ml └── tut │ ├── .gitignore │ ├── README.md │ ├── bsconfig.json │ ├── package.json │ ├── src │ ├── basics.re │ ├── demo.re │ ├── modules.re │ ├── modules_a.re │ ├── modules_b.re │ └── using_map.re │ └── tasks.json ├── postgrest └── compose │ └── docker-compose.yml ├── puppet └── hello │ └── main.pp ├── purescript ├── README.md ├── connect-n │ ├── .gitignore │ ├── bower.json │ ├── src │ │ ├── Connect.purs │ │ └── Main.purs │ └── test │ │ ├── Connect.purs │ │ └── Main.purs ├── express │ ├── .gitignore │ ├── bower.json │ ├── src │ │ ├── Main.js │ │ ├── Main.purs │ │ └── function.js │ └── test │ │ ├── Main.purs │ │ └── test-handle-server.js └── hello-world │ ├── .gitignore │ ├── bower.json │ ├── src │ └── Main.purs │ └── test │ └── Main.purs ├── ruby ├── .gitignore ├── chef │ └── chef-guide │ │ ├── .gitignore │ │ ├── .ruby-version │ │ ├── 0-goodbye.rb │ │ ├── 0-hello.rb │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ └── README.md ├── codeabbey │ ├── 000_sum_ab.rb │ ├── 001_sum_in_loop.rb │ ├── 002_sums_in_loop.rb │ ├── 003_min_of_two.rb │ ├── 004_min_of_three.rb │ ├── 005_max_of_array.rb │ ├── 006_rounding.rb │ ├── 007_fahrenheit_to_celsius.rb │ ├── 008_vowel_count.rb │ ├── 009_median_of_three.rb │ ├── 010_bmi.rb │ ├── 011_dice_rolling.rb │ ├── 012_weighted_sum_of_digits.rb │ ├── 013_sum_of_digits.rb │ ├── 014_array_checksum.rb │ ├── 015_average_of_an_array.rb │ ├── 016_array_counters.rb │ ├── 017_modular_calculator.rb │ ├── 018_bubble_sort.rb │ ├── 019_neumanns_rng.rb │ ├── 020_collatz_sequence.rb │ ├── 021_modulo_and_time_difference.rb │ ├── 022_fibonacci_seq.rb │ ├── 023_greatest_common_denom.rb │ ├── 024_sort_with_indexes.rb │ ├── 025_joe_problem.rb │ ├── 026_smoothing_weather.rb │ ├── 027_prime_generation.rb │ ├── 028_bubble_in_array.rb │ ├── 030_binary_search.rb │ ├── 031_arithmetic_prog.rb │ ├── 032_triangles.rb │ ├── 033_herons_square_root.rb │ ├── 035_two_printers.rb │ ├── 036_reverse_a_string.rb │ ├── 037_rotate_string.rb │ └── 038_savings_calc.rb ├── curses │ ├── 01_io.rb │ └── 02_move.rb ├── james_erb │ └── main.rb ├── katas │ └── anagram.rb ├── rspec │ └── tutsplus │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── README.md │ │ ├── book.rb │ │ ├── library.rb │ │ └── spec │ │ ├── book_spec.rb │ │ ├── library_spec.rb │ │ └── spec_helper.rb ├── scrap │ └── ruby_roulette.rb ├── sonic-pi │ ├── 00-beat.rb │ └── 01-bleeps.rb └── sorbet │ └── ice_cream │ ├── .gitignore │ ├── .travis.yml │ ├── CODE_OF_CONDUCT.md │ ├── Gemfile │ ├── Gemfile.lock │ ├── LICENSE.txt │ ├── README.md │ ├── Rakefile │ ├── bin │ ├── console │ └── setup │ ├── ice_cream.gemspec │ ├── lib │ ├── ice_cream.rb │ └── ice_cream │ │ └── version.rb │ ├── sorbet │ ├── config │ └── rbi │ │ ├── hidden-definitions │ │ ├── errors.txt │ │ └── hidden.rbi │ │ └── sorbet-typed │ │ └── lib │ │ ├── bundler │ │ └── all │ │ │ └── bundler.rbi │ │ ├── minitest │ │ └── all │ │ │ └── minitest.rbi │ │ └── ruby │ │ └── all │ │ ├── gem.rbi │ │ ├── open3.rbi │ │ └── resolv.rbi │ ├── test │ ├── ice_cream_test.rb │ └── test_helper.rb │ └── watch.sh ├── rust ├── .gitignore ├── README.md ├── actix-web-app │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── book_take_one │ ├── dining_philosophers │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ └── guessing_game │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── book_take_two │ └── guessing_game │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── by-example │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ ├── hello_world │ │ ├── formatted_print │ │ │ ├── debug.rs │ │ │ ├── display.rs │ │ │ ├── display_list.rs │ │ │ ├── formatting.rs │ │ │ └── mod.rs │ │ └── mod.rs │ │ └── main.rs ├── error_trait │ └── errorz │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── ffi-rc │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── gotham-hello │ ├── .dockerignore │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Dockerfile │ ├── README.md │ ├── img │ │ └── happylabs-logo.png │ └── src │ │ ├── main.rs │ │ ├── web.rs │ │ └── web │ │ ├── health_check.rs │ │ ├── hello.rs │ │ └── not_found.rs ├── hello_serde │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── lisp-calc │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ ├── lib.rs │ │ ├── main.rs │ │ └── parser.rs │ └── tests │ │ ├── sexpr_fmt.rs │ │ └── sexpr_values.rs ├── quickchecker │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── salsa_test │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── scratch │ └── piston_getting_started │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── staticly-linked-scratch-docker-image │ ├── .dockerignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Dockerfile │ └── src │ │ └── main.rs ├── too-many-lists │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ ├── first.rs │ │ ├── lib.rs │ │ └── second.rs └── warp-web-app │ ├── .dockerignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Dockerfile │ ├── src │ ├── graphql.rs │ └── main.rs │ └── templates │ ├── home.html │ └── layout.html ├── scala ├── .gitignore ├── README.md └── hello-world │ ├── Dockerfile │ ├── README.md │ ├── build.sbt │ ├── project │ ├── assembly.sbt │ └── build.properties │ └── src │ └── main │ └── scala │ └── Main.scala ├── sql ├── .gitignore ├── README.md └── the-hard-way │ ├── README.md │ ├── ex01.sql │ ├── ex02.sql │ ├── ex03.sql │ ├── ex04.sql │ ├── ex05.sql │ ├── ex06.sql │ ├── ex07.sql │ ├── ex08.sql │ ├── ex09.sql │ ├── ex10.sql │ ├── ex11.sql │ └── ex12.sql ├── supercollider ├── .gitignore ├── docs │ └── tuts-00.scd ├── gentle-intro │ ├── 01-basics.scd │ ├── 02-more-lang.scd │ ├── 03-patterns.scd │ ├── 04-synth-and-processing.scd │ └── README.md ├── how-to-make-a-noise │ └── chapter-01.scd ├── nick-collins-tut │ ├── README.md │ ├── chapter-01.scd │ ├── chapter-02.scd │ ├── chapter-03.1-envelopes.scd │ ├── chapter-03.2-synthedef.scd │ └── vendor │ │ ├── 1.1 Getting Started.html │ │ ├── 1.2 Getting Around in SC3.html │ │ ├── 1.3 Obtaining SC3.html │ │ ├── 10.1 Open Sound Control.html │ │ ├── 10.2 Messaging Style.html │ │ ├── 10.3 Network Music Lab.html │ │ ├── 10.4 Mouse To Lang.html │ │ ├── 11.1 Physical Modelling.html │ │ ├── 11.2 Analogue Modelling.html │ │ ├── 12.1 FFT.html │ │ ├── 12.2 Singing Voice Synthesis.html │ │ ├── 2.1 Subtractive and Additive Synthesis.html │ │ ├── 2.2 Mul and add.html │ │ ├── 2.3 Controlling Synths.html │ │ ├── 2.4 Modulation Synthesis.html │ │ ├── 2.5 More Synthesis Examples.html │ │ ├── 3.1 Envelopes.html │ │ ├── 3.2 SynthDefs.html │ │ ├── 3.3 Sequencing.html │ │ ├── 3.4 Server-side Sequencing and Triggers.html │ │ ├── 3.5 Nested Scheduling.html │ │ ├── 4.1 Interaction 1.html │ │ ├── 4.2 Graphical User Interfaces.html │ │ ├── 4.3 Further GUI Example.html │ │ ├── 5.1 Buffers and Sound Files.html │ │ ├── 5.2 Granular Synthesis.html │ │ ├── 5.3 GUI+Loop Example.html │ │ ├── 5.4 Granular Bonus Examples.html │ │ ├── 6.1 Buses.html │ │ ├── 6.2 Control Buses.html │ │ ├── 6.3 Nodes.html │ │ ├── 6.4 Effects 1.html │ │ ├── 6.5 Effects 2.html │ │ ├── 7.1 Interaction 2.html │ │ ├── 8.1 Precise Timing in SC.html │ │ ├── 8.2 Some Time and Rhythm Demoes.html │ │ ├── 9.1 Algorithmic Strategies.html │ │ ├── 9.2 Patterns.html │ │ ├── 9.3 Probability Distributions (optional).html │ │ ├── Exercises │ │ ├── Patterns Exercises.html │ │ └── SC Programming Exercises.html │ │ ├── Technicalities │ │ ├── 01 Programming.html │ │ ├── 02 Arrays.html │ │ ├── 03 Plotting.html │ │ ├── 04 Global Variables and Environments.html │ │ ├── 05 Clocks and Scheduling.html │ │ ├── 06 Routines and Tasks.html │ │ ├── 07 Dealing with Large Projects.html │ │ ├── 08 Writing Classes.html │ │ ├── 09 Programming (advanced).html │ │ ├── 10 Extending SuperCollider.html │ │ └── writingclassesexamples │ │ │ ├── NastySynth.sc │ │ │ └── SuperMario.sc │ │ ├── styles.css │ │ └── tutorial.html ├── queer-code-workshop │ └── tempo-dial-tick.scd ├── syntorial │ ├── README.md │ ├── adsr.scd │ ├── hello_world.scd │ ├── on_your_own_2.scd │ ├── on_your_own_3.scd │ ├── on_your_own_3a.scd │ └── on_your_own_3b.scd └── the-supercollider-book │ ├── 1.1-figure.scd │ ├── 1.2-seed.scd │ ├── 1.3-figure.scd │ ├── 1.6-multichannel-expansion.scd │ ├── 1.7-figure-1.4.scd │ └── 1.8-impulsey.scd ├── types ├── README.md └── algodub │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── rebar.config │ ├── rebar.lock │ └── src │ ├── algodub.app.src │ ├── algodub.erl │ ├── algodub.hrl │ ├── algodub_infer.erl │ ├── algodub_infer_test.erl │ ├── algodub_parser.yrl │ └── algodub_tokenizer.xrl └── viml └── hard-way ├── 01.vim ├── 02.vim ├── 03.vim ├── 04.vim ├── 05.vim ├── 06.vim ├── 07.vim ├── 08.vim ├── 20.vim ├── 21.vim └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | **/sorbet/rbi/hidden-definitions/** linguist-generated=true 2 | **/sorbet/rbi/sorbet-typed/** linguist-generated=true 3 | -------------------------------------------------------------------------------- /alpaca/README.md: -------------------------------------------------------------------------------- 1 | # Learning Alpaca 2 | -------------------------------------------------------------------------------- /alpaca/hello_world/.gitignore: -------------------------------------------------------------------------------- 1 | .rebar3 2 | _* 3 | .eunit 4 | *.o 5 | *.beam 6 | *.plt 7 | *.swp 8 | *.swo 9 | .erlang.cookie 10 | ebin 11 | log 12 | erl_crash.dump 13 | .rebar 14 | logs 15 | _build 16 | .idea 17 | *.iml 18 | rebar3.crashdump 19 | -------------------------------------------------------------------------------- /alpaca/hello_world/README.md: -------------------------------------------------------------------------------- 1 | hello_world 2 | ===== 3 | 4 | An OTP application 5 | 6 | Build 7 | ----- 8 | 9 | $ rebar3 compile 10 | -------------------------------------------------------------------------------- /alpaca/hello_world/rebar.config: -------------------------------------------------------------------------------- 1 | {plugins, [ 2 | {rebar_prv_alpaca, ".*", {git, "https://github.com/alpaca-lang/rebar_prv_alpaca.git", {branch, "master"}}} 3 | ]}. 4 | 5 | {provider_hooks, [{post, [{compile, {alpaca, compile}}]}]}. 6 | -------------------------------------------------------------------------------- /alpaca/hello_world/rebar.lock: -------------------------------------------------------------------------------- 1 | []. 2 | -------------------------------------------------------------------------------- /alpaca/hello_world/src/hello_world.app.src: -------------------------------------------------------------------------------- 1 | {application, hello_world, 2 | [{description, "An OTP application"}, 3 | {vsn, "0.1.0"}, 4 | {registered, []}, 5 | {mod, { hello_world_app, []}}, 6 | {applications, 7 | [kernel, 8 | stdlib 9 | ]}, 10 | {env,[]}, 11 | {modules, []}, 12 | 13 | {maintainers, []}, 14 | {licenses, ["Apache 2.0"]}, 15 | {links, []} 16 | ]}. 17 | -------------------------------------------------------------------------------- /alpaca/hello_world/src/hello_world_sup.alp: -------------------------------------------------------------------------------- 1 | module hello_world_sup 2 | 3 | export init/1, start_link/1 4 | 5 | let server = 6 | :alpaca_hello_world_sup 7 | 8 | -- API functions 9 | 10 | let start_link () = 11 | beam :supervisor :start_link [(:local, server), server, []] with 12 | | result -> result 13 | 14 | -- Supervisor callbacks 15 | 16 | -- Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules} 17 | let init _ = 18 | (:ok, ((:one_for_all, 0, 1), [])) 19 | -------------------------------------------------------------------------------- /alpaca/hello_world/src/test_helpers.alp: -------------------------------------------------------------------------------- 1 | module test_helpers 2 | 3 | export assert_equal/2 4 | 5 | let assert_equal x y = 6 | match x == y with 7 | | true -> :ok 8 | | _ -> throw (:not_equal, x, y) 9 | -------------------------------------------------------------------------------- /bug-reports/unicode_print_error/.gitignore: -------------------------------------------------------------------------------- 1 | .rebar3 2 | _* 3 | .eunit 4 | *.o 5 | *.beam 6 | *.plt 7 | *.swp 8 | *.swo 9 | .erlang.cookie 10 | ebin 11 | log 12 | erl_crash.dump 13 | .rebar 14 | logs 15 | _build 16 | .idea 17 | *.iml 18 | rebar3.crashdump 19 | *~ 20 | -------------------------------------------------------------------------------- /bug-reports/unicode_print_error/README.md: -------------------------------------------------------------------------------- 1 | Run `rebar3 eunit` to see `out.txt` being printed incorrectly. 2 | -------------------------------------------------------------------------------- /bug-reports/unicode_print_error/out.txt: -------------------------------------------------------------------------------- 1 | ┌── /src/tetromino.gleam:2:10 ─── 2 | │ 3 | 2 │ [1] == [1.0] 4 | │ ^^^^^ 5 | │ 6 | -------------------------------------------------------------------------------- /bug-reports/unicode_print_error/rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [debug_info]}. 2 | {deps, []}. 3 | 4 | {pre_hooks, [ 5 | {eunit, "cat out.txt"} 6 | ]}. 7 | -------------------------------------------------------------------------------- /bug-reports/unicode_print_error/src/unicode_print_error.app.src: -------------------------------------------------------------------------------- 1 | {application, unicode_print_error, 2 | [{description, "An OTP library"}, 3 | {vsn, "0.1.0"}, 4 | {registered, []}, 5 | {applications, 6 | [kernel, 7 | stdlib 8 | ]}, 9 | {env,[]}, 10 | {modules, []}, 11 | 12 | {licenses, ["Apache 2.0"]}, 13 | {links, []} 14 | ]}. 15 | -------------------------------------------------------------------------------- /bug-reports/unicode_print_error/src/unicode_print_error.erl: -------------------------------------------------------------------------------- 1 | -module(unicode_print_error). 2 | 3 | -export([]). 4 | -------------------------------------------------------------------------------- /c/.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | # Libraries 11 | *.lib 12 | *.a 13 | *.la 14 | *.lo 15 | 16 | # Shared objects (inc. Windows DLLs) 17 | *.dll 18 | *.so 19 | *.so.* 20 | *.dylib 21 | 22 | # Executables 23 | *.exe 24 | *.out 25 | *.app 26 | *.i*86 27 | *.x86_64 28 | *.hex 29 | 30 | # Debug files 31 | *.dSYM/ 32 | -------------------------------------------------------------------------------- /c/README.md: -------------------------------------------------------------------------------- 1 | Learning C 2 | ========== 3 | 4 | Oh er... This one isn't functional... 5 | 6 | ## Notes 7 | 8 | * [Make tutorial][make-tutorial] 9 | 10 | [make-tutorial]: http://mrbook.org/blog/tutorials/make/ 11 | -------------------------------------------------------------------------------- /c/a_modern_approach/README.md: -------------------------------------------------------------------------------- 1 | K .N. King - C Programming: A Modern Approach 2 | ============================================= 3 | -------------------------------------------------------------------------------- /c/a_modern_approach/chapter-02/00_scanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | // Take an int from user input and store it in i 6 | int i; 7 | puts("Gimmie an int"); 8 | scanf("%d", &i); 9 | printf("You gave me a %d\n", i); 10 | 11 | // Take a float from user input and store it in f 12 | float f; 13 | puts("Gimmie a float"); 14 | scanf("%f", &f); 15 | printf("You gave me a %f\n", f); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /c/a_modern_approach/chapter-02/ex1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf("Hello, world!\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /c/a_modern_approach/chapter-02/ex2.c: -------------------------------------------------------------------------------- 1 | // Directive used here 2 | #include "stdio.h" 3 | 4 | int main(void) 5 | { 6 | // printf statement used here 7 | printf("Parkinson's Law:\nWork expands so as to \n"); 8 | printf("fill the time\n"); 9 | printf("available for its completion.\n\n"); 10 | 11 | // return statement used here 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /c/a_modern_approach/chapter-02/ex3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf(" *\n"); 6 | printf(" *\n"); 7 | printf(" *\n"); 8 | printf("* *\n"); 9 | printf(" * *\n"); 10 | printf(" *\n"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /c/a_modern_approach/chapter-02/ex5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Calculate the volume of a sphere with a 10 meter radius. 5 | // v = 4/3 pi r^3 6 | 7 | int main(void) 8 | { 9 | int radius = 10.0; 10 | float volume = (4.0 / 3.0) * M_PI * pow(radius, 3); 11 | 12 | printf("%f\n", volume); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /c/exercism/hamming/build/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /c/exercism/hamming/src/hamming.c: -------------------------------------------------------------------------------- 1 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) 2 | 3 | int compute(char *x, int x_size, char *y, int y_size) 4 | { 5 | int distance = 0; 6 | int i = MIN(x_size, y_size); 7 | while (i--) { 8 | if (x[i] != y[i]) { distance++; } 9 | } 10 | return distance; 11 | } 12 | -------------------------------------------------------------------------------- /c/exercism/hamming/src/hamming.h: -------------------------------------------------------------------------------- 1 | #ifndef _HAMMING_H 2 | #define _HAMMING_H 3 | 4 | int compute(char *x, int x_size, char *y, int y_size); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /c/scratch/backwards_while.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | char name[] = "Louis Adam Pilfold."; 6 | int i = sizeof(name) / sizeof(name[0]); 7 | 8 | while(i--) { 9 | printf("%c", name[i]); 10 | } 11 | printf("\n"); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /c/scratch/factorial.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int factorial(int n) 5 | { 6 | int fac = 1; 7 | while (n > 0) { 8 | fac *= n; 9 | n--; 10 | } 11 | return fac; 12 | } 13 | 14 | 15 | int main(void) 16 | { 17 | int i; 18 | for (i = -10; i <= 10; ++i) { 19 | printf("%d! == %d\n", i, factorial(i)); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /c/tdd/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf("Hello, world!\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /clojure/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | classes 3 | .DS_Store 4 | *.jar 5 | .lein-deps-sum 6 | .lein-plugins 7 | .lein-repl-history 8 | lib 9 | releases 10 | target 11 | .nrepl-port 12 | -------------------------------------------------------------------------------- /clojure/README.md: -------------------------------------------------------------------------------- 1 | Learning Clojure 2 | ================ 3 | -------------------------------------------------------------------------------- /clojure/overtone-gentle-intro/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | *.log 11 | -------------------------------------------------------------------------------- /clojure/overtone-gentle-intro/README.md: -------------------------------------------------------------------------------- 1 | # overtone-gentle-intro 2 | 3 | Let's take [this Supercollider 4 | guide](https://github.com/brunoruviaro/A_Gentle_Introduction_To_SuperCollider) 5 | and translate it into Overtone. 6 | -------------------------------------------------------------------------------- /clojure/overtone-gentle-intro/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to overtone-gentle-intro 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /clojure/overtone-gentle-intro/project.clj: -------------------------------------------------------------------------------- 1 | (defproject overtone-gentle-intro "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :dependencies [[org.clojure/clojure "1.6.0"] 5 | [overtone "0.9.1"]] 6 | :main ^:skip-aot overtone-gentle-intro.core 7 | :target-path "target/%s" 8 | :profiles {:uberjar {:aot :all}}) 9 | -------------------------------------------------------------------------------- /clojure/overtone-gentle-intro/test/overtone_gentle_intro/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns overtone-gentle-intro.core-test 2 | (:require [clojure.test :refer :all] 3 | [overtone-gentle-intro.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /clojure/overtone-scratch/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /clojure/overtone-scratch/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to overtone-scratch 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /clojure/overtone-scratch/project.clj: -------------------------------------------------------------------------------- 1 | (defproject overtone-scratch "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.7.0"] 7 | [overtone "0.9.1"]] 8 | :main ^:skip-aot overtone-scratch.core 9 | :target-path "target/%s" 10 | :profiles {:uberjar {:aot :all}}) 11 | -------------------------------------------------------------------------------- /clojure/overtone-scratch/src/overtone_scratch/core.clj: -------------------------------------------------------------------------------- 1 | (ns overtone-scratch.core 2 | (:use [overtone.live] 3 | [overtone.inst.piano]) 4 | (:gen-class)) 5 | -------------------------------------------------------------------------------- /clojure/overtone-scratch/test/overtone_scratch/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns overtone-scratch.core-test 2 | (:require [clojure.test :refer :all] 3 | [overtone-scratch.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /clojure/quil-experiments/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | -------------------------------------------------------------------------------- /clojure/quil-experiments/README.md: -------------------------------------------------------------------------------- 1 | # quil-experiments 2 | 3 | * http://en.wikipedia.org/wiki/Voronoi_diagram 4 | -------------------------------------------------------------------------------- /clojure/quil-experiments/project.clj: -------------------------------------------------------------------------------- 1 | (defproject quil-experiments "0.1.0-SNAPSHOT" 2 | :description "Learning Quil" 3 | :url "http://github.com/lpil/learning-clojure" 4 | :dependencies [[org.clojure/clojure "1.6.0"] 5 | [quil "2.2.4"]]) 6 | -------------------------------------------------------------------------------- /clojure/quil-experiments/src/quil_experiments/two/core.clj: -------------------------------------------------------------------------------- 1 | (ns quil-experiments.two.core 2 | (:require [quil.core :as q] 3 | [quil.middleware :as m] 4 | [quil-experiments.two.dynamic :as dynamic])) 5 | 6 | (q/defsketch quil-experiments 7 | :title "Hello, Quil!" 8 | :size [500 500] 9 | :setup dynamic/setup 10 | :update dynamic/update 11 | :draw dynamic/draw 12 | :middleware [m/fun-mode]) 13 | -------------------------------------------------------------------------------- /clojure/test_test/README.md: -------------------------------------------------------------------------------- 1 | # test_test 2 | 3 | The project uses [Midje](https://github.com/marick/Midje/). 4 | 5 | ## How to run the tests 6 | 7 | `lein midje` will run all tests. 8 | 9 | `lein midje namespace.*` will run only tests beginning with "namespace.". 10 | 11 | `lein midje :autotest` will run all the tests indefinitely. It sets up a 12 | watcher on the code files. If they change, only the relevant tests will be 13 | run again. 14 | -------------------------------------------------------------------------------- /clojure/test_test/project.clj: -------------------------------------------------------------------------------- 1 | (defproject test_test "0.0.1-SNAPSHOT" 2 | :description "Cool new project to do things and stuff" 3 | :dependencies [[org.clojure/clojure "1.7.0"]] 4 | :profiles {:dev {:dependencies [[midje "1.5.1"]]}}) 5 | 6 | -------------------------------------------------------------------------------- /clojure/test_test/src/test_test/core.clj: -------------------------------------------------------------------------------- 1 | (ns test_test.core) 2 | 3 | ;;; This is an incorrect implementation, such as might be written by 4 | ;;; someone who was used to a Lisp in which an empty list is equal to 5 | ;;; nil. 6 | ; (defn first-element [sequence default] 7 | ; (if (nil? sequence) 8 | ; default 9 | ; (first sequence))) 10 | 11 | ;;; Hey look, a better one! 12 | (defn first-element [collection default] 13 | (if (empty? collection) 14 | default 15 | (first collection))) 16 | -------------------------------------------------------------------------------- /crystal/sum/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.cr] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /crystal/sum/.gitignore: -------------------------------------------------------------------------------- 1 | /docs/ 2 | /lib/ 3 | /bin/ 4 | /.shards/ 5 | *.dwarf 6 | 7 | # Libraries don't need dependency lock 8 | # Dependencies will be locked in application that uses them 9 | /shard.lock 10 | -------------------------------------------------------------------------------- /crystal/sum/.travis.yml: -------------------------------------------------------------------------------- 1 | language: crystal 2 | -------------------------------------------------------------------------------- /crystal/sum/shard.yml: -------------------------------------------------------------------------------- 1 | name: sum 2 | version: 0.1.0 3 | 4 | authors: 5 | - Louis Pilfold 6 | 7 | crystal: 0.26.1 8 | 9 | license: MIT 10 | -------------------------------------------------------------------------------- /crystal/sum/spec/spec_helper.cr: -------------------------------------------------------------------------------- 1 | require "spec" 2 | require "../src/sum" 3 | -------------------------------------------------------------------------------- /crystal/sum/spec/sum_spec.cr: -------------------------------------------------------------------------------- 1 | require "./spec_helper" 2 | 3 | describe Sum do 4 | # TODO: Write tests 5 | 6 | it "unwrap" do 7 | Just.new(1).unwrap(2).should eq(1) 8 | Nothing(Int32).new.unwrap(2).should eq(2) 9 | end 10 | 11 | it "map" do 12 | Just.new(1).map(->(x : Int32) { x + 1 }).unwrap(0).should eq(2) 13 | Nothing(Int32).new.map(->(x : Int32) { x + 1 }).unwrap(0).should eq(0) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /do/rolling/.gitignore: -------------------------------------------------------------------------------- 1 | secret 2 | .terraform 3 | -------------------------------------------------------------------------------- /do/rolling/README.md: -------------------------------------------------------------------------------- 1 | # DigitalOcean Rolling 2 | 3 | ```sh 4 | export DIGITALOCEAN_TOKEN="token goes here" 5 | 6 | terraform init 7 | terraform plan 8 | terraform apply 9 | ``` 10 | -------------------------------------------------------------------------------- /do/rolling/dev/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true 4 | do 5 | version=$(curl --max-time 1 --silent $1 --stderr -) 6 | 7 | if [ "$version" == "" ]; then 8 | echo "$(date -u) Service Unavailable" 9 | else 10 | echo "$(date -u) $version" 11 | fi 12 | 13 | sleep 0.1 14 | done 15 | -------------------------------------------------------------------------------- /elixir/.gitignore: -------------------------------------------------------------------------------- 1 | **/_build 2 | **/deps 3 | -------------------------------------------------------------------------------- /elixir/README.md: -------------------------------------------------------------------------------- 1 | Learning Elixir 2 | =============== 3 | -------------------------------------------------------------------------------- /elixir/anagram/README.md: -------------------------------------------------------------------------------- 1 | # Anagram 2 | 3 | Write a program that, given a word and a list of possible anagrams, selects 4 | the correct sublist. 5 | 6 | Given `"listen"` and a list of candidates like `"enlists" "google" 7 | "inlets" "banana"` the program should return a list containing 8 | `"inlets"`. 9 | 10 | 11 | ## Source 12 | 13 | Inspired by the Extreme Startup game [view source](https://github.com/rchatley/extreme_startup) 14 | -------------------------------------------------------------------------------- /elixir/baraxx/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["mix.exs", "apps/*/mix.exs", "apps/*/{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /elixir/baraxx/README.md: -------------------------------------------------------------------------------- 1 | # Baraxx 2 | 3 | **TODO: Add description** 4 | 5 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/core/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/core/lib/core.ex: -------------------------------------------------------------------------------- 1 | defmodule Core do 2 | @moduledoc """ 3 | Documentation for Core. 4 | """ 5 | 6 | @doc """ 7 | Hello world. 8 | 9 | ## Examples 10 | 11 | iex> Core.hello 12 | :world 13 | 14 | """ 15 | def hello do 16 | :world 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/core/test/core_test.exs: -------------------------------------------------------------------------------- 1 | defmodule CoreTest do 2 | use ExUnit.Case 3 | doctest Core 4 | 5 | test "greets the world" do 6 | assert Core.hello() == :world 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/core/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/web/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/web/README.md: -------------------------------------------------------------------------------- 1 | # Baraxx 2 | 3 | A test Raxx based web app 4 | 5 | ```sh 6 | # Start app 7 | iex -S mix 8 | 9 | # Build a docker image 10 | docker build . -t baraxx 11 | 12 | # Run a docker container 13 | docker run -p 4000:4000 -it --rm baraxx console 14 | ``` 15 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/web/config/config.exs: -------------------------------------------------------------------------------- 1 | use Mix.Config 2 | 3 | config :web, enable_web_server: Mix.env() != :test 4 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/web/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start(capture_log: true) 2 | -------------------------------------------------------------------------------- /elixir/baraxx/apps/web/test/web_test.exs: -------------------------------------------------------------------------------- 1 | defmodule WebTest do 2 | use ExUnit.Case 3 | doctest Web 4 | end 5 | -------------------------------------------------------------------------------- /elixir/delegate-genserver-call/test/del_test.exs: -------------------------------------------------------------------------------- 1 | defmodule DelTest do 2 | use ExUnit.Case 3 | doctest Del 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/delegate-genserver-call/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/elixir_appengine/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /elixir/elixir_appengine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM bitwalker/alpine-elixir:1.7.1 2 | 3 | # Set exposed ports 4 | EXPOSE 8080 5 | ENV PORT=8080 \ 6 | MIX_ENV=prod 7 | 8 | # Add current Mix project 9 | ADD . /app 10 | WORKDIR /app 11 | 12 | CMD mix run --no-halt 13 | -------------------------------------------------------------------------------- /elixir/elixir_appengine/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: custom 2 | env: flex 3 | 4 | manual_scaling: 5 | instances: 1 6 | resources: 7 | cpu: 1 8 | memory_gb: 0.5 9 | disk_size_gb: 10 10 | -------------------------------------------------------------------------------- /elixir/elixir_appengine/mix.lock: -------------------------------------------------------------------------------- 1 | %{ 2 | "elli": {:hex, :elli, "3.1.0", "3b0c46b549bac00db06ff79a87b69a7fe06f3b24e7e06858ff6ccd9654276785", [:rebar3], [], "hexpm"}, 3 | } 4 | -------------------------------------------------------------------------------- /elixir/elixir_appengine/test/app_test.exs: -------------------------------------------------------------------------------- 1 | defmodule AppTest do 2 | use ExUnit.Case 3 | doctest App 4 | 5 | test "greets the world" do 6 | assert App.hello() == :world 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/elixir_appengine/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/exq-explore/test/exqy_test.exs: -------------------------------------------------------------------------------- 1 | defmodule ExqyTest do 2 | use ExUnit.Case 3 | doctest Exqy 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/exq-explore/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/first_app/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /deps 3 | erl_crash.dump 4 | *.ez 5 | -------------------------------------------------------------------------------- /elixir/first_app/README.md: -------------------------------------------------------------------------------- 1 | # FirstApp 2 | 3 | [An Introduction to Mix]( 4 | http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html) 5 | -------------------------------------------------------------------------------- /elixir/first_app/lib/first_app.ex: -------------------------------------------------------------------------------- 1 | defmodule FirstApp do 2 | end 3 | -------------------------------------------------------------------------------- /elixir/first_app/test/first_app_test.exs: -------------------------------------------------------------------------------- 1 | defmodule FirstAppTest do 2 | use ExUnit.Case 3 | 4 | test "the truth" do 5 | assert 1 + 1 == 2 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /elixir/first_app/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/README.md: -------------------------------------------------------------------------------- 1 | Gilded Rose Refactoring Kata 2 | ============================ 3 | 4 | https://github.com/emilybache/GildedRose-Refactoring-Kata 5 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/config/config.exs: -------------------------------------------------------------------------------- 1 | use Mix.Config 2 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/lib/gilded_rose.ex: -------------------------------------------------------------------------------- 1 | defmodule GildedRose do 2 | def update_quality(items) do 3 | Enum.map(items, &update_item/1) 4 | end 5 | 6 | def update_item(item) do 7 | GildedRose.Update.update(item) 8 | end 9 | end 10 | 11 | defprotocol GildedRose.Update do 12 | def update(item) 13 | end 14 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/lib/item/brie.ex: -------------------------------------------------------------------------------- 1 | defmodule Item.Brie do 2 | defstruct Item.fields 3 | end 4 | 5 | defimpl GildedRose.Update, for: Item.Brie do 6 | 7 | def update(%{ quality: 0 } = item) do 8 | item 9 | end 10 | 11 | def update(%{ quality: q } = item) when 49 < q do 12 | item 13 | end 14 | 15 | def update(item) do 16 | %{ item | quality: item.quality + 1 } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/lib/item/plain.ex: -------------------------------------------------------------------------------- 1 | defmodule Item.Plain do 2 | defstruct Item.fields 3 | end 4 | 5 | defimpl GildedRose.Update, for: Item.Plain do 6 | 7 | def update(%{ quality: 0 } = item) do 8 | item 9 | end 10 | 11 | def update(%{ sell_in: s } = item) when s < 0 do 12 | item 13 | end 14 | 15 | def update(item) do 16 | %{ item | quality: item.quality - 1 } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/lib/item/sulfuras.ex: -------------------------------------------------------------------------------- 1 | defmodule Item.Sulfuras do 2 | defstruct Item.fields 3 | end 4 | 5 | defimpl GildedRose.Update, for: Item.Sulfuras do 6 | 7 | def update(item) do 8 | item 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule GildedRose.Mixfile do 2 | use Mix.Project 3 | 4 | def project do 5 | [ app: :gilded_rose, 6 | version: "0.0.1", 7 | elixir: "~> 1.0", 8 | deps: deps, 9 | ] 10 | end 11 | 12 | defp deps do 13 | [ {:mix_test_watch, "~> 0.2", only: :dev} # Automatic test runner 14 | ] 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/mix.lock: -------------------------------------------------------------------------------- 1 | %{"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []}, 2 | "mix_test_watch": {:hex, :mix_test_watch, "0.2.6", "9fcc2b1b89d1594c4a8300959c19d50da2f0ff13642c8f681692a6e507f92cab", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, optional: false]}]}} 3 | -------------------------------------------------------------------------------- /elixir/gilded-rose-refactoring-kata/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/lyse-sockets/.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps 9 | 10 | # Where 3rd-party dependencies like ExDoc output generated docs. 11 | /doc 12 | 13 | # If the VM crashes, it generates a dump, let's ignore it too. 14 | erl_crash.dump 15 | 16 | # Also ignore archive artifacts (built via "mix archive.build"). 17 | *.ez 18 | -------------------------------------------------------------------------------- /elixir/lyse-sockets/lib/sockets.ex: -------------------------------------------------------------------------------- 1 | defmodule Sockets do 2 | end 3 | -------------------------------------------------------------------------------- /elixir/lyse-sockets/test/sockets_test.exs: -------------------------------------------------------------------------------- 1 | defmodule SocketsTest do 2 | use ExUnit.Case 3 | doctest Sockets 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/lyse-sockets/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/lyse_concurrent_app/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /cover 3 | /deps 4 | erl_crash.dump 5 | *.ez 6 | -------------------------------------------------------------------------------- /elixir/lyse_concurrent_app/README.md: -------------------------------------------------------------------------------- 1 | LYSE: Designing a Concurrent Application 2 | ======================================== 3 | 4 | http://learnyousomeerlang.com/designing-a-concurrent-application 5 | -------------------------------------------------------------------------------- /elixir/lyse_concurrent_app/lib/lyse.ex: -------------------------------------------------------------------------------- 1 | defmodule LYSE do 2 | @moduledoc false 3 | end 4 | -------------------------------------------------------------------------------- /elixir/lyse_concurrent_app/mix.lock: -------------------------------------------------------------------------------- 1 | %{"dogma": {:hex, :dogma, "0.0.11"}, 2 | "fs": {:hex, :fs, "0.9.2"}, 3 | "mix_test_watch": {:hex, :mix_test_watch, "0.2.5"}, 4 | "poison": {:hex, :poison, "1.5.2"}} 5 | -------------------------------------------------------------------------------- /elixir/lyse_concurrent_app/test/lyse_test.exs: -------------------------------------------------------------------------------- 1 | defmodule LYSETest do 2 | use ExUnit.Case 3 | doctest LYSE 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/lyse_concurrent_app/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/lyse_kitty_server/.gitignore: -------------------------------------------------------------------------------- 1 | /_build 2 | /cover 3 | /deps 4 | erl_crash.dump 5 | *.ez 6 | -------------------------------------------------------------------------------- /elixir/lyse_kitty_server/README.md: -------------------------------------------------------------------------------- 1 | # Kitty 2 | 3 | **TODO: Add description** 4 | 5 | ## Installation 6 | 7 | If [available in Hex](https://hex.pm/docs/publish), the package can be installed as: 8 | 9 | 1. Add kitty to your list of dependencies in `mix.exs`: 10 | 11 | def deps do 12 | [{:kitty, "~> 0.0.1"}] 13 | end 14 | 15 | 2. Ensure kitty is started before your application: 16 | 17 | def application do 18 | [applications: [:kitty]] 19 | end 20 | 21 | -------------------------------------------------------------------------------- /elixir/lyse_kitty_server/lib/kitty.ex: -------------------------------------------------------------------------------- 1 | defmodule Kitty do 2 | use Application 3 | 4 | defstruct name: "", colour: "", description: "" 5 | 6 | def start(_type, _args) do 7 | import Supervisor.Spec, warn: false 8 | 9 | children = [ 10 | worker(Kitty.Server, []), 11 | ] 12 | 13 | opts = [strategy: :one_for_one, name: Kitty.Supervisor] 14 | Supervisor.start_link(children, opts) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /elixir/lyse_kitty_server/test/kitty_test.exs: -------------------------------------------------------------------------------- 1 | defmodule KittyTest do 2 | use ExUnit.Case 3 | doctest Kitty 4 | 5 | test "the truth" do 6 | assert 1 + 1 == 2 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /elixir/lyse_kitty_server/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/next_break_fits/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /elixir/next_break_fits/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elixir/reactive/README.md: -------------------------------------------------------------------------------- 1 | Reactive 2 | ======== 3 | 4 | Recreating some of the code from the Scala Reactive programming MOOC, but with 5 | a language that is nice and good. :3 6 | -------------------------------------------------------------------------------- /elixir/scratch/01.exs: -------------------------------------------------------------------------------- 1 | defmodule Foo do 2 | def head([]) do 3 | nil 4 | end 5 | 6 | def head([x|_]) do 7 | x 8 | end 9 | end 10 | 11 | IO.puts Foo.head([1,2,3,4]) 12 | -------------------------------------------------------------------------------- /elixir/scratch/02-UPCASE.exs: -------------------------------------------------------------------------------- 1 | IO.puts "I'M GOING TO SHOUT EVERYTHING BACK AT YOU. 2 | " 3 | 4 | stream = IO.stream(:stdio, :line) 5 | for line <- stream, into: stream do 6 | String.upcase(line) <> "\n" 7 | end 8 | -------------------------------------------------------------------------------- /elixir/scratch/char-stream.exs: -------------------------------------------------------------------------------- 1 | IO.puts "What is the input string?" 2 | 3 | stream = IO.stream(:stdio, :line) 4 | 5 | for line <- stream, into: stream do 6 | word = String.trim(line) 7 | count = String.length(word) 8 | """ 9 | "#{word}" has #{count} characters. 10 | 11 | What is the input string? 12 | """ 13 | end 14 | -------------------------------------------------------------------------------- /elixir/scratch/hanoi.exs: -------------------------------------------------------------------------------- 1 | defmodule Hanoi do 2 | @doc """ 3 | Solve the towers of Hanoi, moving rings from `a` to `b` 4 | """ 5 | def solve(_, a \\ "a", b \\ "b", c \\ "c") 6 | def solve(0, _, _, _) do 7 | [] 8 | end 9 | 10 | def solve(tower_height, a, b, c) do 11 | x = tower_height - 1 12 | 13 | solve(x, a, c, b) ++ 14 | ["Move one ring from #{a} to #{b}"] ++ 15 | solve(x, c, b, a) 16 | end 17 | end 18 | 19 | Hanoi.solve(3) 20 | -------------------------------------------------------------------------------- /elixir/scratch/largest_divisible.exs: -------------------------------------------------------------------------------- 1 | defmodule LargestDivisible do 2 | defp divisable?(num, divider) do 3 | rem(num, divider) == 0 4 | end 5 | 6 | @doc """ 7 | Finds the largest number divisable by `divider` that is less than `num` 8 | """ 9 | def find(num, divider) when divider > num do 10 | raise "divider larger than num" 11 | end 12 | def find(num, divider) do 13 | Enum.find (num - 1)..1, 14 | &divisable?(&1, divider) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /elixir/streamy_data/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /elixir/streamy_data/lib/streamy_data.ex: -------------------------------------------------------------------------------- 1 | defmodule StreamyData do 2 | @moduledoc """ 3 | Documentation for StreamyData. 4 | """ 5 | 6 | @doc """ 7 | Hello world. 8 | 9 | ## Examples 10 | 11 | iex> StreamyData.hello() 12 | :world 13 | 14 | """ 15 | def hello do 16 | :world 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /elixir/streamy_data/mix.lock: -------------------------------------------------------------------------------- 1 | %{ 2 | "stream_data": {:hex, :stream_data, "0.4.2", "fa86b78c88ec4eaa482c0891350fcc23f19a79059a687760ddcf8680aac2799b", [:mix], [], "hexpm"}, 3 | } 4 | -------------------------------------------------------------------------------- /elixir/streamy_data/test/streamy_data_test.exs: -------------------------------------------------------------------------------- 1 | defmodule StreamyDataTest do 2 | use ExUnit.Case 3 | doctest StreamyData 4 | 5 | use ExUnitProperties 6 | 7 | property "bin1 <> bin2 always starts with bin1" do 8 | check all bin1 <- binary(), 9 | bin2 <- binary() do 10 | assert String.starts_with?(bin1 <> bin2, bin1) 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /elixir/streamy_data/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /elm/.gitignore: -------------------------------------------------------------------------------- 1 | elm-stuff/ 2 | repl-temp-* 3 | node_modules 4 | -------------------------------------------------------------------------------- /elm/README.md: -------------------------------------------------------------------------------- 1 | Learning Elm 2 | ============ 3 | -------------------------------------------------------------------------------- /elm/buttons/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "5.1.1 <= v < 6.0.0", 12 | "elm-lang/html": "2.0.0 <= v < 3.0.0" 13 | }, 14 | "elm-version": "0.18.0 <= v < 0.19.0" 15 | } 16 | -------------------------------------------------------------------------------- /elm/checkbox/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0", 12 | "elm-lang/html": "1.0.0 <= v < 2.0.0" 13 | }, 14 | "elm-version": "0.17.0 <= v < 0.18.0" 15 | } 16 | -------------------------------------------------------------------------------- /elm/counter-pair/.gitignore: -------------------------------------------------------------------------------- 1 | index.html 2 | -------------------------------------------------------------------------------- /elm/counter-pair/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0", 12 | "elm-lang/html": "1.0.0 <= v < 2.0.0" 13 | }, 14 | "elm-version": "0.17.0 <= v < 0.18.0" 15 | } 16 | -------------------------------------------------------------------------------- /elm/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0" 12 | }, 13 | "elm-version": "0.17.0 <= v < 0.18.0" 14 | } -------------------------------------------------------------------------------- /elm/fields/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0", 12 | "elm-lang/html": "1.0.0 <= v < 2.0.0" 13 | }, 14 | "elm-version": "0.17.0 <= v < 0.18.0" 15 | } 16 | -------------------------------------------------------------------------------- /elm/form/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0", 12 | "elm-lang/html": "1.0.0 <= v < 2.0.0" 13 | }, 14 | "elm-version": "0.17.0 <= v < 0.18.0" 15 | } 16 | -------------------------------------------------------------------------------- /elm/hello-world/README.md: -------------------------------------------------------------------------------- 1 | Hello World 2 | =========== 3 | 4 | ```sh 5 | elm package install 6 | 7 | elm reactor 8 | ``` 9 | -------------------------------------------------------------------------------- /elm/hello-world/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0", 12 | "elm-lang/html": "1.0.0 <= v < 2.0.0" 13 | }, 14 | "elm-version": "0.17.0 <= v < 0.18.0" 15 | } -------------------------------------------------------------------------------- /elm/json/Makefile: -------------------------------------------------------------------------------- 1 | BIN=./node_modules/.bin 2 | 3 | ELM_TEST=$(BIN)/elm-test 4 | 5 | help: 6 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 7 | 8 | test: ## Run the frontend tests 9 | $(ELM_TEST) 10 | 11 | .PHONY: \ 12 | test \ 13 | help 14 | -------------------------------------------------------------------------------- /elm/json/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /elm-stuff/ 2 | -------------------------------------------------------------------------------- /elm/json/tests/TestRunner.elm: -------------------------------------------------------------------------------- 1 | port module Main exposing (..) 2 | 3 | import Tests 4 | import Test.Runner.Node exposing (run) 5 | import Json.Encode exposing (Value) 6 | 7 | 8 | main : Program Never 9 | main = 10 | run emit Tests.all 11 | 12 | 13 | port emit : ( String, Value ) -> Cmd msg 14 | -------------------------------------------------------------------------------- /elm/markdown/README.md: -------------------------------------------------------------------------------- 1 | Markdown 2 | ======== 3 | 4 | ```sh 5 | elm package install 6 | 7 | elm reactor 8 | ``` 9 | -------------------------------------------------------------------------------- /elm/random/elm-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "summary": "helpful summary of your project, less than 80 characters", 4 | "repository": "https://github.com/user/project.git", 5 | "license": "BSD3", 6 | "source-directories": [ 7 | "." 8 | ], 9 | "exposed-modules": [], 10 | "dependencies": { 11 | "elm-lang/core": "4.0.1 <= v < 5.0.0", 12 | "elm-lang/html": "1.0.0 <= v < 2.0.0" 13 | }, 14 | "elm-version": "0.17.0 <= v < 0.18.0" 15 | } 16 | -------------------------------------------------------------------------------- /erlang/lumen_test/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.iml 3 | *.o 4 | *.plt 5 | *.swo 6 | *.swp 7 | *~ 8 | .erlang.cookie 9 | .eunit 10 | .idea 11 | .rebar 12 | .rebar3 13 | _* 14 | _build 15 | docs 16 | ebin 17 | erl_crash.dump 18 | gen 19 | log 20 | logs 21 | rebar3.crashdump 22 | -------------------------------------------------------------------------------- /erlang/lumen_test/init.erl: -------------------------------------------------------------------------------- 1 | -module(init). 2 | -export([start/0]). 3 | 4 | start() -> 5 | erlang:display(hello_lumen). 6 | -------------------------------------------------------------------------------- /fsharp/hello-world/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | -------------------------------------------------------------------------------- /fsharp/hello-world/Program.fs: -------------------------------------------------------------------------------- 1 | // Learn more about F# at http://fsharp.org 2 | 3 | open System 4 | 5 | [] 6 | let main argv = 7 | printfn "Hello World from F#!" 8 | 0 // return an integer exit code 9 | -------------------------------------------------------------------------------- /fsharp/hello-world/hello-world.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp2.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /gcp/Makefile: -------------------------------------------------------------------------------- 1 | help: 2 | @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 3 | .PHONY: help 4 | 5 | include infra/deployment.mk 6 | -------------------------------------------------------------------------------- /gcp/README.md: -------------------------------------------------------------------------------- 1 | # Goggles 2 | 3 | zey do nothing! 4 | -------------------------------------------------------------------------------- /gcp/gcp-simple-deploy/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform 2 | -------------------------------------------------------------------------------- /gcp/gcp-simple-deploy/README.md: -------------------------------------------------------------------------------- 1 | # GCP Simple Deploy 2 | 3 | App deployed to GCP instance group behind a load balancer. 4 | 5 | Managed with terraform. 6 | 7 | 8 | ## Usage 9 | 10 | ```sh 11 | gcloud init 12 | bin/deploy dev init 13 | bin/deploy dev plan 14 | bin/deploy dev apply 15 | bin/deploy dev destroy 16 | ``` 17 | -------------------------------------------------------------------------------- /gcp/gcp-simple-deploy/modules/app/outputs.tf: -------------------------------------------------------------------------------- 1 | # output "service_ip" { 2 | # value = "${google_compute_forwarding_rule.app.ip_address}" 3 | # } 4 | -------------------------------------------------------------------------------- /gcp/gcp-simple-deploy/modules/app/variables.tf: -------------------------------------------------------------------------------- 1 | variable "env" { 2 | type = "string" 3 | } 4 | 5 | variable "project" { 6 | type = "string" 7 | } 8 | 9 | variable "region" { 10 | type = "string" 11 | } 12 | 13 | variable "replicas" { 14 | type = "string" 15 | } 16 | -------------------------------------------------------------------------------- /gleam/bubbles/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.iml 3 | *.o 4 | *.plt 5 | *.swo 6 | *.swp 7 | *~ 8 | .erlang.cookie 9 | .eunit 10 | .idea 11 | .rebar 12 | .rebar3 13 | _* 14 | _build 15 | docs 16 | ebin 17 | erl_crash.dump 18 | gen 19 | log 20 | logs 21 | rebar3.crashdump 22 | -------------------------------------------------------------------------------- /gleam/bubbles/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "bubbles" 2 | -------------------------------------------------------------------------------- /gleam/bubbles/rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [debug_info]}. 2 | {src_dirs, ["src", "gen/src"]}. 3 | 4 | {profiles, [ 5 | {test, [{src_dirs, ["src", "test", "gen/src", "gen/test"]}]} 6 | ]}. 7 | 8 | {project_plugins, [rebar_gleam]}. 9 | 10 | {deps, [ 11 | {gleam_stdlib, "0.11.0"} 12 | ]}. 13 | -------------------------------------------------------------------------------- /gleam/bubbles/src/bubbles.app.src: -------------------------------------------------------------------------------- 1 | {application, bubbles, 2 | [{description, "A Gleam program"}, 3 | {vsn, "1.0.0"}, 4 | {registered, []}, 5 | {applications, 6 | [kernel, 7 | stdlib, 8 | gleam_stdlib 9 | ]}, 10 | {env,[]}, 11 | {modules, []}, 12 | 13 | {include_files, ["gleam.toml", "gen"]}, 14 | {licenses, ["Apache 2.0"]}, 15 | {links, []} 16 | ]}. 17 | -------------------------------------------------------------------------------- /gleam/bubbles/test/bubbles_test.gleam: -------------------------------------------------------------------------------- 1 | import bubbles 2 | import gleam/should 3 | -------------------------------------------------------------------------------- /gleam/clippy/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.iml 3 | *.o 4 | *.plt 5 | *.swo 6 | *.swp 7 | *~ 8 | .erlang.cookie 9 | .eunit 10 | .idea 11 | .rebar 12 | .rebar3 13 | _* 14 | _build 15 | docs 16 | ebin 17 | erl_crash.dump 18 | gen 19 | log 20 | logs 21 | rebar3.crashdump 22 | -------------------------------------------------------------------------------- /gleam/clippy/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "clippy" 2 | -------------------------------------------------------------------------------- /gleam/clippy/rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [debug_info]}. 2 | {src_dirs, ["src", "gen/src"]}. 3 | 4 | {profiles, [ 5 | {test, [{src_dirs, ["src", "test", "gen/src", "gen/test"]}]} 6 | ]}. 7 | 8 | {project_plugins, [rebar_gleam]}. 9 | 10 | {deps, [ 11 | {gleam_stdlib, "0.8.0"}, 12 | {gleam_httpc, {git, "https://github.com/gleam-experiments/httpc"}} 13 | ]}. 14 | -------------------------------------------------------------------------------- /gleam/clippy/src/clippy.app.src: -------------------------------------------------------------------------------- 1 | {application, clippy, 2 | [{description, "A Gleam program"}, 3 | {vsn, "1.0.0"}, 4 | {registered, []}, 5 | {applications, 6 | [kernel, 7 | stdlib, 8 | gleam_stdlib, 9 | gleam_httpc, 10 | ssl, 11 | inets 12 | ]}, 13 | {env,[]}, 14 | {modules, []}, 15 | 16 | {licenses, ["Apache 2.0"]}, 17 | {links, []} 18 | ]}. 19 | -------------------------------------------------------------------------------- /gleam/clippy/test/clippy_test.gleam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/gleam/clippy/test/clippy_test.gleam -------------------------------------------------------------------------------- /glsl/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.pid 3 | *.seed 4 | .lock-wscript 5 | .node_repl_history 6 | .npm 7 | .nyc_output 8 | logs 9 | node_modules 10 | npm-debug.log* 11 | -------------------------------------------------------------------------------- /glsl/README.md: -------------------------------------------------------------------------------- 1 | Learning GLSL 2 | ============= 3 | -------------------------------------------------------------------------------- /glsl/shader-school/00-intro-0/hello.glsl: -------------------------------------------------------------------------------- 1 | float brightness() { 2 | return 1.0; 3 | } 4 | 5 | //Do not change this line 6 | #pragma glslify: export(brightness) 7 | -------------------------------------------------------------------------------- /glsl/shader-school/01-intro-1/hello.glsl: -------------------------------------------------------------------------------- 1 | highp float sum(highp float x, highp float y) { 2 | return x + y; 3 | } 4 | 5 | //Do not change this line 6 | #pragma glslify: export(sum) 7 | -------------------------------------------------------------------------------- /glsl/shader-school/02-intro-2/sides.glsl: -------------------------------------------------------------------------------- 1 | void sideLengths( 2 | highp float hypotenuse, 3 | highp float angleInDegrees, 4 | out highp float opposite, 5 | out highp float adjacent 6 | ) { 7 | 8 | float theta = radians(angleInDegrees); 9 | opposite = hypotenuse * sin(theta); 10 | adjacent = hypotenuse * cos(theta); 11 | } 12 | 13 | //Do not change this line 14 | #pragma glslify: export(sideLengths) 15 | -------------------------------------------------------------------------------- /glsl/shader-school/03-intro-3/vectors.glsl: -------------------------------------------------------------------------------- 1 | highp vec2 func(highp vec2 a, highp vec2 b) { 2 | 3 | //TODO: Implement the exercise here 4 | 5 | return vec2(1, 0); 6 | } 7 | 8 | //Do not change this line 9 | #pragma glslify: export(func) -------------------------------------------------------------------------------- /glsl/shader-school/04-intro-4/box.glsl: -------------------------------------------------------------------------------- 1 | bool inBox(highp vec2 lo, highp vec2 hi, highp vec2 p) { 2 | 3 | //Test if the point p is inside the box bounded by [lo, hi] 4 | 5 | return false; 6 | } 7 | 8 | 9 | //Do not change this line or the name of the above function 10 | #pragma glslify: export(inBox) 11 | -------------------------------------------------------------------------------- /glsl/shader-school/05-intro-5/mandelbrot.glsl: -------------------------------------------------------------------------------- 1 | bool mandelbrot(highp vec2 c) { 2 | 3 | //Test if the point c is inside the mandelbrot set after 100 iterations 4 | vec2 z = vec2(0.0); 5 | 6 | return false; 7 | } 8 | 9 | 10 | //Do not change this line or the name of the above function 11 | #pragma glslify: export(mandelbrot) 12 | -------------------------------------------------------------------------------- /glsl/shader-school/06-intro-6/mpow.glsl: -------------------------------------------------------------------------------- 1 | mat2 matrixPower(highp mat2 m, int n) { 2 | 3 | //Raise the matrix m to nth power 4 | 5 | // For example: 6 | // 7 | // matrixPower(m, 2) = m * m 8 | // 9 | 10 | return mat2(1.0); 11 | } 12 | 13 | //Do not change this line or the name of the above function 14 | #pragma glslify: export(matrixPower) -------------------------------------------------------------------------------- /glsl/shader-school/07-frag-1/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | #define CIRCLE_COLOR vec4(1.0, 0.4313, 0.3411, 1.0) 4 | #define OUTSIDE_COLOR vec4(0.3804, 0.7647, 1.0, 1.0) 5 | 6 | void main() { 7 | 8 | //TODO: Replace this with a function that draws a circle at (256.5,256.5) with radius 128 9 | 10 | if(gl_FragCoord.y > 256.0) { 11 | gl_FragColor = CIRCLE_COLOR; 12 | } else { 13 | gl_FragColor = OUTSIDE_COLOR; 14 | } 15 | } -------------------------------------------------------------------------------- /glsl/shader-school/08-frag-2/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | void main() { 4 | 5 | //TODO: Replace this with a function that draws a checkerboard 6 | 7 | discard; 8 | } -------------------------------------------------------------------------------- /glsl/shader-school/09-frag-3/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform sampler2D texture; 4 | uniform vec2 screenSize; 5 | 6 | void main() { 7 | vec2 coord = gl_FragCoord.xy / screenSize; 8 | 9 | //TODO: Swap red and blue color channels of image 10 | 11 | gl_FragColor = texture2D(texture, coord); 12 | } 13 | -------------------------------------------------------------------------------- /glsl/shader-school/10-vert-1/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform float theta; 4 | 5 | attribute vec2 position; 6 | 7 | void main() { 8 | 9 | //TODO: rotate position by theta radians about the origin 10 | 11 | gl_Position = vec4(position, 0, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /glsl/shader-school/11-vert-2/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | void main() { 4 | gl_FragColor = vec4(1,1,1,1); 5 | } -------------------------------------------------------------------------------- /glsl/shader-school/11-vert-2/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | attribute vec4 position; 4 | attribute vec3 color; 5 | 6 | void main() { 7 | gl_Position = position; 8 | } 9 | -------------------------------------------------------------------------------- /glsl/shader-school/12-geom-1/transforms.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | attribute vec3 position; 4 | 5 | uniform mat4 model, view, projection; 6 | 7 | void main() { 8 | 9 | //TODO: Apply the model-view-projection matrix to `position` 10 | 11 | gl_Position = vec4(position, 1); 12 | } -------------------------------------------------------------------------------- /glsl/shader-school/13-geom-2/translate.glsl: -------------------------------------------------------------------------------- 1 | highp mat4 translate(highp vec3 p) { 2 | 3 | //TODO: Construct a matrix, m, which translates all points so that p is at the origin. 4 | 5 | return mat4(1, 0, 0, 0, 6 | 0, 1, 0, 0, 7 | 0, 0, 1, 0, 8 | 0, 0, 0, 1); 9 | } 10 | 11 | //Do not remove this line 12 | #pragma glslify: export(translate) -------------------------------------------------------------------------------- /glsl/shader-school/14-geom-3/scale.glsl: -------------------------------------------------------------------------------- 1 | highp mat4 scale(highp vec3 p) { 2 | 3 | //TODO: Return a matrix that scales each axis about the origin by a factor of p.x/p.y/p.z 4 | 5 | return mat4(1, 0, 0, 0, 6 | 0, 1, 0, 0, 7 | 0, 0, 1, 0, 8 | 0, 0, 0, 1); 9 | } 10 | 11 | #pragma glslify: export(scale) -------------------------------------------------------------------------------- /glsl/shader-school/15-geom-4/reflect.glsl: -------------------------------------------------------------------------------- 1 | highp mat4 reflection(highp vec3 n) { 2 | 3 | //TODO: Return a matrix that reflects all points about the plane passing through the origin with normal n 4 | 5 | return mat4(1, 0, 0, 0, 6 | 0, 1, 0, 0, 7 | 0, 0, 1, 0, 8 | 0, 0, 0, 1); 9 | } 10 | 11 | #pragma glslify: export(reflection) -------------------------------------------------------------------------------- /glsl/shader-school/16-geom-5/rotate.glsl: -------------------------------------------------------------------------------- 1 | highp mat4 rotation(highp vec3 n, highp float theta) { 2 | 3 | //TODO: Using Rodrigues' formula, find a matrix which performs a rotation about the axis n by theta radians 4 | 5 | return mat4(1, 0, 0, 0, 6 | 0, 1, 0, 0, 7 | 0, 0, 1, 0, 8 | 0, 0, 0, 1); 9 | } 10 | 11 | #pragma glslify: export(rotation) -------------------------------------------------------------------------------- /glsl/shader-school/17-light-1/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform mat4 model, view, projection; 4 | uniform vec3 ambient; 5 | 6 | void main() { 7 | gl_FragColor = vec4(1,1,1,1); 8 | } -------------------------------------------------------------------------------- /glsl/shader-school/17-light-1/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec3 position; 4 | uniform mat4 model, view, projection; 5 | uniform vec3 ambient; 6 | 7 | void main() { 8 | gl_Position = vec4(position, 1); 9 | } 10 | -------------------------------------------------------------------------------- /glsl/shader-school/18-light-2/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform mat4 model; 4 | uniform mat4 view; 5 | uniform mat4 projection; 6 | 7 | uniform mat4 inverseModel; 8 | uniform mat4 inverseView; 9 | uniform mat4 inverseProjection; 10 | 11 | uniform vec3 ambient; 12 | uniform vec3 diffuse; 13 | uniform vec3 lightDirection; 14 | 15 | void main() { 16 | gl_FragColor = vec4(1,1,1,1); 17 | } -------------------------------------------------------------------------------- /glsl/shader-school/18-light-2/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec3 position; 4 | attribute vec3 normal; 5 | 6 | uniform mat4 model; 7 | uniform mat4 view; 8 | uniform mat4 projection; 9 | 10 | uniform mat4 inverseModel; 11 | uniform mat4 inverseView; 12 | uniform mat4 inverseProjection; 13 | 14 | uniform vec3 ambient; 15 | uniform vec3 diffuse; 16 | uniform vec3 lightDirection; 17 | 18 | void main() { 19 | gl_Position = vec4(position, 1); 20 | } 21 | -------------------------------------------------------------------------------- /glsl/shader-school/19-light-3/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform mat4 model, view, projection; 4 | uniform mat4 inverseModel, inverseView, inverseProjection; 5 | uniform vec3 ambient, diffuse, specular, lightDirection; 6 | uniform float shininess; 7 | 8 | void main() { 9 | gl_FragColor = vec4(1,1,1,1); 10 | } -------------------------------------------------------------------------------- /glsl/shader-school/19-light-3/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec3 position, normal; 4 | uniform mat4 model, view, projection; 5 | uniform mat4 inverseModel, inverseView, inverseProjection; 6 | uniform vec3 ambient, diffuse, specular, lightDirection; 7 | uniform float shininess; 8 | 9 | void main() { 10 | gl_Position = vec4(position, 1); 11 | } 12 | -------------------------------------------------------------------------------- /glsl/shader-school/20-light-4/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform mat4 model; 4 | uniform mat4 view; 5 | uniform mat4 projection; 6 | 7 | uniform mat4 inverseModel; 8 | uniform mat4 inverseView; 9 | uniform mat4 inverseProjection; 10 | 11 | uniform vec3 ambient; 12 | uniform vec3 diffuse; 13 | uniform vec3 specular; 14 | 15 | uniform vec3 lightPosition; 16 | 17 | uniform float shininess; 18 | 19 | void main() { 20 | gl_FragColor = vec4(1,1,1,1); 21 | } -------------------------------------------------------------------------------- /glsl/shader-school/20-light-4/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec3 position; 4 | attribute vec3 normal; 5 | 6 | uniform mat4 model; 7 | uniform mat4 view; 8 | uniform mat4 projection; 9 | 10 | uniform mat4 inverseModel; 11 | uniform mat4 inverseView; 12 | uniform mat4 inverseProjection; 13 | 14 | uniform vec3 lightPosition; 15 | 16 | void main() { 17 | gl_Position = vec4(position, 1); 18 | } 19 | -------------------------------------------------------------------------------- /glsl/shader-school/21-light-5/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | #pragma glslify: PointLight = require(./light.glsl) 4 | 5 | uniform mat4 model; 6 | uniform mat4 view; 7 | uniform mat4 projection; 8 | 9 | uniform mat4 inverseModel; 10 | uniform mat4 inverseView; 11 | uniform mat4 inverseProjection; 12 | 13 | uniform vec3 ambient; 14 | 15 | uniform PointLight lights[4]; 16 | 17 | void main() { 18 | gl_FragColor = vec4(1,1,1,1); 19 | } -------------------------------------------------------------------------------- /glsl/shader-school/21-light-5/light.glsl: -------------------------------------------------------------------------------- 1 | //This is the light datatype 2 | struct PointLight { 3 | vec3 diffuse; 4 | vec3 specular; 5 | vec3 position; 6 | float shininess; 7 | }; 8 | 9 | //Export the point light data type 10 | #pragma glslify: export(PointLight) -------------------------------------------------------------------------------- /glsl/shader-school/21-light-5/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | #pragma glslify: PointLight = require(./light.glsl) 4 | 5 | attribute vec3 position; 6 | attribute vec3 normal; 7 | 8 | uniform mat4 model; 9 | uniform mat4 view; 10 | uniform mat4 projection; 11 | 12 | uniform mat4 inverseModel; 13 | uniform mat4 inverseView; 14 | uniform mat4 inverseProjection; 15 | 16 | uniform vec3 ambient; 17 | 18 | uniform PointLight lights[4]; 19 | 20 | void main() { 21 | gl_Position = vec4(position, 1); 22 | } 23 | -------------------------------------------------------------------------------- /glsl/shader-school/22-npr-1/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform mat4 model; 4 | uniform mat4 view; 5 | uniform mat4 projection; 6 | 7 | uniform mat4 inverseModel; 8 | uniform mat4 inverseView; 9 | uniform mat4 inverseProjection; 10 | 11 | uniform vec3 diffuse; 12 | uniform vec3 lightDirection; 13 | uniform float numBands; 14 | 15 | void main() { 16 | gl_FragColor = vec4(1,1,1,1); 17 | } -------------------------------------------------------------------------------- /glsl/shader-school/22-npr-1/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec3 position; 4 | attribute vec3 normal; 5 | 6 | uniform mat4 model; 7 | uniform mat4 view; 8 | uniform mat4 projection; 9 | 10 | uniform mat4 inverseModel; 11 | uniform mat4 inverseView; 12 | uniform mat4 inverseProjection; 13 | 14 | uniform vec3 diffuse; 15 | uniform vec3 lightDirection; 16 | uniform float numBands; 17 | 18 | void main() { 19 | gl_Position = vec4(position,1); 20 | } 21 | -------------------------------------------------------------------------------- /glsl/shader-school/23-npr-2/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform mat4 model; 4 | uniform mat4 view; 5 | uniform mat4 projection; 6 | 7 | uniform mat4 inverseModel; 8 | uniform mat4 inverseView; 9 | uniform mat4 inverseProjection; 10 | 11 | uniform vec3 warm; 12 | uniform vec3 cool; 13 | uniform vec3 lightDirection; 14 | 15 | void main() { 16 | gl_FragColor = vec4(1,1,1,1); 17 | } -------------------------------------------------------------------------------- /glsl/shader-school/23-npr-2/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec3 position; 4 | attribute vec3 normal; 5 | 6 | uniform mat4 model; 7 | uniform mat4 view; 8 | uniform mat4 projection; 9 | 10 | uniform mat4 inverseModel; 11 | uniform mat4 inverseView; 12 | uniform mat4 inverseProjection; 13 | 14 | uniform vec3 warm; 15 | uniform vec3 cool; 16 | uniform vec3 lightDirection; 17 | 18 | void main() { 19 | gl_Position = vec4(position,1); 20 | } 21 | -------------------------------------------------------------------------------- /glsl/shader-school/24-gpgpu-1/life.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform sampler2D prevState; 4 | uniform vec2 stateSize; 5 | 6 | float state(vec2 coord) { 7 | return texture2D(prevState, fract(coord / stateSize)).r; 8 | } 9 | 10 | void main() { 11 | vec2 coord = gl_FragCoord.xy; 12 | 13 | 14 | //TODO: Compute the next state for the cell at coord 15 | float s = state(coord); 16 | 17 | gl_FragColor = vec4(s,s,s, 1.0); 18 | } 19 | -------------------------------------------------------------------------------- /glsl/shader-school/27-prims-1/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | void main() { 4 | gl_FragColor = vec4(1,1,1,1); 5 | } -------------------------------------------------------------------------------- /glsl/shader-school/27-prims-1/vertex.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | attribute vec3 position, color; 4 | attribute float size; 5 | 6 | uniform mat4 model, view, projection; 7 | 8 | void main() { 9 | gl_Position = projection * view * model * vec4(position, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /glsl/shader-school/28-prims-2/fragment.glsl: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform vec3 frontColor, backColor; 4 | 5 | void main() { 6 | gl_FragColor = vec4(1,1,1,1); 7 | } -------------------------------------------------------------------------------- /glsl/shader-school/29-playground-flocking/position.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform sampler2D positions; 4 | uniform sampler2D speeds; 5 | 6 | #define SIZE 64.0 7 | 8 | void main() { 9 | vec2 currentIndex = gl_FragCoord.xy / vec2(SIZE); 10 | vec2 position = texture2D(positions, currentIndex).xy; 11 | vec2 speed = texture2D(speeds, currentIndex).xy; 12 | 13 | position += speed; 14 | 15 | gl_FragColor.xy = position; 16 | gl_FragColor.zw = vec2(1.0); 17 | } 18 | -------------------------------------------------------------------------------- /glsl/shader-school/29-playground-flocking/triangle.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | attribute vec2 position; 4 | 5 | void main() { 6 | gl_Position = vec4(position.xy, 0.0, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /glsl/shader-school/30-playground-gpgpu/render.glsl: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform sampler2D state[3]; //State buffer 4 | uniform vec2 screenSize; //Size of screen buffer 5 | uniform vec2 mousePosition; //Position of mouse 6 | uniform bool mouseDown[3]; //Test if mouse left, right, middle is down 7 | uniform float time; //Time since start 8 | 9 | void main() { 10 | gl_FragColor = vec4(texture2D(state[0], gl_FragCoord.xy / screenSize).rgb, 1.0); 11 | } -------------------------------------------------------------------------------- /glsl/shader-school/Makefile: -------------------------------------------------------------------------------- 1 | help: ## Prints help for targets with comments 2 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 3 | 4 | start: ## Start the server 5 | ./node_modules/shader-school/index.js 6 | 7 | .PHONY: \ 8 | help \ 9 | run 10 | -------------------------------------------------------------------------------- /glsl/shader-school/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "school", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "shader-school": "^1.1.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /go/.gitignore: -------------------------------------------------------------------------------- 1 | main 2 | vendor 3 | -------------------------------------------------------------------------------- /go/aws-lambda-http-shim/.gitignore: -------------------------------------------------------------------------------- 1 | # Serverless directories 2 | .serverless 3 | 4 | # golang output binary directory 5 | bin -------------------------------------------------------------------------------- /go/aws-lambda-http-shim/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | go get github.com/aws/aws-lambda-go/lambda 3 | env GOOS=linux go build -ldflags="-s -w" -o bin/handler src/main.go 4 | -------------------------------------------------------------------------------- /go/aws-lambda-http-shim/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda HTTP 2 | 3 | ```sh 4 | make 5 | npx serverless deploy 6 | curl -X POST $URL_FROM_DEPLOY_OUTPUT -d "hi there!" 7 | ``` 8 | -------------------------------------------------------------------------------- /go/aws-lambda-http-shim/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-lambda-http 2 | 3 | provider: 4 | name: aws 5 | runtime: go1.x 6 | 7 | package: 8 | exclude: 9 | - ./** 10 | include: 11 | - ./bin/** 12 | 13 | functions: 14 | shim_service: 15 | handler: bin/handler 16 | events: 17 | - http: 18 | path: / 19 | method: ANY 20 | - http: 21 | path: /{any+} 22 | method: ANY 23 | -------------------------------------------------------------------------------- /go/aws-lambda-http/.gitignore: -------------------------------------------------------------------------------- 1 | # Serverless directories 2 | .serverless 3 | 4 | # golang output binary directory 5 | bin -------------------------------------------------------------------------------- /go/aws-lambda-http/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | go get github.com/aws/aws-lambda-go/lambda 3 | env GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go 4 | env GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go -------------------------------------------------------------------------------- /go/aws-lambda-http/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda HTTP 2 | 3 | ```sh 4 | make 5 | npx serverless deploy 6 | curl -X POST $URL_FROM_DEPLOY_OUTPUT -d "hi there!" 7 | ``` 8 | -------------------------------------------------------------------------------- /go/aws-lambda-http/world/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/aws/aws-lambda-go/lambda" 5 | ) 6 | 7 | type Response struct { 8 | Message string `json:"message"` 9 | } 10 | 11 | func Handler() (Response, error) { 12 | return Response{ 13 | Message: "Okay so your other function also executed successfully!", 14 | }, nil 15 | } 16 | 17 | func main() { 18 | lambda.Start(Handler) 19 | } 20 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } 4 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/.buffalo.dev.yml: -------------------------------------------------------------------------------- 1 | app_root: . 2 | ignored_folders: 3 | - vendor 4 | - log 5 | - logs 6 | - assets 7 | - public 8 | - grifts 9 | - tmp 10 | - bin 11 | - node_modules 12 | - .sass-cache 13 | included_extensions: 14 | - .go 15 | - .env 16 | build_path: tmp 17 | build_delay: 200ns 18 | binary_name: coke-build 19 | command_flags: [] 20 | enable_colors: true 21 | log_name: buffalo 22 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | checks: 3 | method-lines: 4 | config: 5 | threshold: 100 6 | plugins: 7 | fixme: 8 | enabled: true 9 | gofmt: 10 | enabled: true 11 | golint: 12 | enabled: true 13 | govet: 14 | enabled: true 15 | exclude_patterns: 16 | - grifts/**/* 17 | - "**/*_test.go" 18 | - "*_test.go" 19 | - "**_test.go" 20 | - logs/* 21 | - public/* 22 | - templates/* 23 | - "**/node_modules/" 24 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.log 3 | bin/ 4 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | **/*.log 3 | **/*.sqlite 4 | .idea/ 5 | bin/ 6 | tmp/ 7 | node_modules/ 8 | .sass-cache/ 9 | *-packr.go 10 | public/assets/ 11 | .vscode/ 12 | .grifter/ 13 | .env 14 | **/.DS_Store 15 | *.pid 16 | coverage 17 | coverage.data 18 | .svn 19 | .console_history 20 | .sass-cache/* 21 | .jhw-cache/ 22 | jhw.* 23 | *.sublime* 24 | dist/ 25 | generated/ 26 | .vendor/ 27 | 28 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/actions/home.go: -------------------------------------------------------------------------------- 1 | package actions 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gobuffalo/buffalo" 7 | ) 8 | 9 | // HomeHandler is a default handler to serve up 10 | // a home page. 11 | func HomeHandler(c buffalo.Context) error { 12 | return c.Render(http.StatusOK, r.HTML("index.html")) 13 | } 14 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/assets/css/application.scss: -------------------------------------------------------------------------------- 1 | @import "~bootstrap/scss/bootstrap.scss"; 2 | @import "~@fortawesome/fontawesome-free/css/all.min.css"; 3 | 4 | @import "buffalo"; 5 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/go/buffalo-tutorial/assets/images/favicon.ico -------------------------------------------------------------------------------- /go/buffalo-tutorial/assets/js/application.js: -------------------------------------------------------------------------------- 1 | require("expose-loader?$!expose-loader?jQuery!jquery"); 2 | require("bootstrap/dist/js/bootstrap.bundle.js"); 3 | require("@fortawesome/fontawesome-free/js/all.js"); 4 | 5 | $(() => { 6 | 7 | }); 8 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/config/buffalo-app.toml: -------------------------------------------------------------------------------- 1 | name = "coke" 2 | bin = "bin/coke" 3 | vcs = "git" 4 | with_pop = true 5 | with_sqlite = false 6 | with_dep = false 7 | with_webpack = true 8 | with_nodejs = true 9 | with_yarn = true 10 | with_docker = true 11 | with_grifts = true 12 | as_web = true 13 | as_api = false 14 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/config/buffalo-plugins.toml: -------------------------------------------------------------------------------- 1 | [[plugin]] 2 | binary = "buffalo-auth" 3 | go_get = "github.com/gobuffalo/buffalo-auth" 4 | 5 | [[plugin]] 6 | binary = "buffalo-pop" 7 | go_get = "github.com/gobuffalo/buffalo-pop/v2" 8 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/database.yml: -------------------------------------------------------------------------------- 1 | --- 2 | development: 3 | dialect: postgres 4 | database: coke_development 5 | user: postgres 6 | password: postgres 7 | host: 127.0.0.1 8 | pool: 5 9 | 10 | test: 11 | url: {{envOr "TEST_DATABASE_URL" "postgres://postgres:postgres@127.0.0.1:5432/coke_test?sslmode=disable"}} 12 | 13 | production: 14 | url: {{envOr "DATABASE_URL" "postgres://postgres:postgres@127.0.0.1:5432/coke_production?sslmode=disable"}} 15 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/grifts/db.go: -------------------------------------------------------------------------------- 1 | package grifts 2 | 3 | import ( 4 | "github.com/markbates/grift/grift" 5 | ) 6 | 7 | var _ = grift.Namespace("db", func() { 8 | 9 | grift.Desc("seed", "Seeds a database") 10 | grift.Add("seed", func(c *grift.Context) error { 11 | // Add DB seeding stuff here 12 | return nil 13 | }) 14 | 15 | }) 16 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/grifts/init.go: -------------------------------------------------------------------------------- 1 | package grifts 2 | 3 | import ( 4 | "coke/actions" 5 | 6 | "github.com/gobuffalo/buffalo" 7 | ) 8 | 9 | func init() { 10 | buffalo.Grifts(actions.App()) 11 | } 12 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/inflections.json: -------------------------------------------------------------------------------- 1 | { 2 | "singular": "plural" 3 | } 4 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/locales/all.en-us.yaml: -------------------------------------------------------------------------------- 1 | # For more information on using i18n see: https://github.com/nicksnyder/go-i18n 2 | - id: welcome_greeting 3 | translation: "Welcome to Buffalo (EN)" 4 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/migrations/20200606115610_create_users.down.fizz: -------------------------------------------------------------------------------- 1 | drop_table("users") -------------------------------------------------------------------------------- /go/buffalo-tutorial/migrations/20200606115610_create_users.up.fizz: -------------------------------------------------------------------------------- 1 | create_table("users"){ 2 | t.Column("id", "uuid", {"primary": true}) 3 | t.Column("email", "string", {}) 4 | t.Column("password_hash", "string", {}) 5 | 6 | 7 | } -------------------------------------------------------------------------------- /go/buffalo-tutorial/models/models.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/gobuffalo/envy" 7 | "github.com/gobuffalo/pop/v5" 8 | ) 9 | 10 | // DB is a connection to your database to be used 11 | // throughout your application. 12 | var DB *pop.Connection 13 | 14 | func init() { 15 | var err error 16 | env := envy.Get("GO_ENV", "development") 17 | DB, err = pop.Connect(env) 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | pop.Debug = env == "development" 22 | } 23 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/models/models_test.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gobuffalo/packr/v2" 7 | "github.com/gobuffalo/suite/v3" 8 | ) 9 | 10 | type ModelSuite struct { 11 | *suite.Model 12 | } 13 | 14 | func Test_ModelSuite(t *testing.T) { 15 | model, err := suite.NewModelWithFixtures(packr.New("app:models:test:fixtures", "../fixtures")) 16 | if err != nil { 17 | t.Fatal(err) 18 | } 19 | 20 | as := &ModelSuite{ 21 | Model: model, 22 | } 23 | suite.Run(t, as) 24 | } 25 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [require("autoprefixer")] 3 | }; 4 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: / 3 | -------------------------------------------------------------------------------- /go/buffalo-tutorial/templates/_flash.plush.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | <%= for (k, messages) in flash { %> 4 | <%= for (msg) in messages { %> 5 | 11 | <% } %> 12 | <% } %> 13 |
14 |
15 | -------------------------------------------------------------------------------- /go/calculator/.gitignore: -------------------------------------------------------------------------------- 1 | calculator 2 | -------------------------------------------------------------------------------- /go/calculator/Makefile: -------------------------------------------------------------------------------- 1 | calculator: src/*.go 2 | go build src/calculator.go 3 | 4 | build-watch: 5 | find -name '*.go' | entr go build src/calculator.go 6 | .PHONY: build-watch 7 | 8 | test-watch: 9 | find -name '*.go' | entr go test ./... 10 | .PHONY: test-watch 11 | -------------------------------------------------------------------------------- /go/calculator/src/calculator_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | -------------------------------------------------------------------------------- /go/flags/.gitignore: -------------------------------------------------------------------------------- 1 | fake-sonic-pi-tool 2 | -------------------------------------------------------------------------------- /go/hello-world/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | fmt.Println("Hello, sailor!") 9 | } 10 | -------------------------------------------------------------------------------- /go/http-client/.gitignore: -------------------------------------------------------------------------------- 1 | furl 2 | -------------------------------------------------------------------------------- /go/http-server/Makefile: -------------------------------------------------------------------------------- 1 | run: 2 | find -name '*.go' | entr -r go run main.go 3 | .PHONY: run 4 | -------------------------------------------------------------------------------- /go/http-server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | http.HandleFunc("/", handleRoot) 10 | 11 | fmt.Println("Listening on port 8000...") 12 | err := http.ListenAndServe(":8000", nil) 13 | if err != nil { 14 | panic(err) 15 | } 16 | } 17 | 18 | func handleRoot(w http.ResponseWriter, r *http.Request) { 19 | fmt.Println("handleRoot called") 20 | w.Write([]byte("Hello there!")) 21 | } 22 | -------------------------------------------------------------------------------- /go/interface-visitor/.gitignore: -------------------------------------------------------------------------------- 1 | calculator 2 | -------------------------------------------------------------------------------- /go/interface-visitor/Makefile: -------------------------------------------------------------------------------- 1 | calculator: src/*.go 2 | go build src/calculator.go 3 | 4 | build-watch: 5 | find -name '*.go' | entr go build src/calculator.go 6 | .PHONY: build-watch 7 | 8 | test-watch: 9 | find -name '*.go' | entr go test ./... 10 | .PHONY: test-watch 11 | -------------------------------------------------------------------------------- /go/interface-visitor/src/calculator_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | -------------------------------------------------------------------------------- /go/shared-value/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | i := 0 10 | fmt.Println("Hi") 11 | 12 | go func() { 13 | for { 14 | time.Sleep(800000000) 15 | fmt.Println("Other goroutine incrementing i") 16 | i += 1 17 | } 18 | }() 19 | 20 | for { 21 | time.Sleep(100000000) 22 | fmt.Printf("%d\n", i) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /go/simple-server/.gitignore: -------------------------------------------------------------------------------- 1 | simple-server 2 | -------------------------------------------------------------------------------- /go/simple-server/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build 2 | FROM golang:alpine AS builder 3 | RUN apk update && apk add --no-cache git 4 | RUN adduser -D -g '' appuser 5 | WORKDIR /tmp/simple-server 6 | COPY . . 7 | RUN go mod download 8 | RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /simple-server 9 | 10 | # Release 11 | FROM scratch 12 | COPY --from=builder /etc/passwd /etc/passwd 13 | COPY --from=builder /simple-server /simple-server 14 | USER appuser 15 | ENTRYPOINT ["/simple-server"] 16 | -------------------------------------------------------------------------------- /go/simple-server/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lpil/learning/go/simple-server 2 | 3 | go 1.12 4 | 5 | require ( 6 | golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect 7 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092 // indirect 8 | golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5 // indirect 9 | golang.org/x/text v0.3.2 // indirect 10 | golang.org/x/tools v0.0.0-20190523174634-38d8bcfa38af // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /go/simple-server/simple-server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | ) 8 | 9 | func handler(w http.ResponseWriter, r *http.Request) { 10 | fmt.Fprintf(w, "Hello, world!") 11 | } 12 | 13 | func main() { 14 | http.HandleFunc("/", handler) 15 | log.Fatal(http.ListenAndServe(":3000", nil)) 16 | } 17 | -------------------------------------------------------------------------------- /go/test-runner/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lpil/learning/go/test-runner 2 | 3 | go 1.12 4 | 5 | require github.com/sirupsen/logrus v1.4.2 6 | -------------------------------------------------------------------------------- /go/test-runner/internal/check/one.go: -------------------------------------------------------------------------------- 1 | package check 2 | 3 | type One struct{} 4 | 5 | func (_ One) Name() string { 6 | return "Number One" 7 | } 8 | 9 | func (_ One) Description() string { 10 | return "The first one, etc etc" 11 | } 12 | 13 | func (_ One) Exec() CheckResult { 14 | return CheckPass{} 15 | } 16 | -------------------------------------------------------------------------------- /go/test-wrapper/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lpil/learning/go/test-wrapper 2 | 3 | go 1.12 4 | 5 | require golang.org/x/tools/gopls v0.1.1 // indirect 6 | -------------------------------------------------------------------------------- /go/testing/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | fmt.Println("Hello, tester!") 9 | } 10 | 11 | func Add(a int, b int) int { 12 | return a + b 13 | } 14 | -------------------------------------------------------------------------------- /go/workflow-graph/bin/brook: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/go/workflow-graph/bin/brook -------------------------------------------------------------------------------- /go/workflow-graph/go.mod: -------------------------------------------------------------------------------- 1 | module brook 2 | 3 | go 1.12 4 | 5 | require github.com/stretchr/testify v1.4.0 6 | -------------------------------------------------------------------------------- /go/workflow-graph/internal/pkg/database/link.go: -------------------------------------------------------------------------------- 1 | package database 2 | 3 | type Link struct { 4 | ParentId int 5 | ChildId int 6 | } 7 | -------------------------------------------------------------------------------- /go/workflow-graph/internal/pkg/workflow/step.go: -------------------------------------------------------------------------------- 1 | package workflow 2 | 3 | type Step interface { 4 | Visit(StepVisitor) error 5 | } 6 | 7 | type StepVisitor interface { 8 | VisitTranscode(StepTranscode) error 9 | VisitCheckSize(StepCheckSize) error 10 | } 11 | -------------------------------------------------------------------------------- /go/workflow-graph/internal/pkg/workflow/step_check_size.go: -------------------------------------------------------------------------------- 1 | package workflow 2 | 3 | type StepCheckSize struct { 4 | } 5 | 6 | // StepCheckSize implements the Step interface 7 | 8 | func (step StepCheckSize) Visit(visitor StepVisitor) error { 9 | return visitor.VisitCheckSize(step) 10 | } 11 | 12 | // StepCheckSize can be ran to check the size of a video 13 | 14 | func (step StepCheckSize) CheckVideoSize(inputFilePath string) error { 15 | return nil 16 | } 17 | -------------------------------------------------------------------------------- /haskell/.gitignore: -------------------------------------------------------------------------------- 1 | **/*cabal*sandbox* 2 | **/tmp.csd 3 | **/*.oi 4 | */*.h 5 | **/dist/* 6 | .stack-work 7 | -------------------------------------------------------------------------------- /haskell/HiAgainWorld.hs: -------------------------------------------------------------------------------- 1 | module HiAgainWorld where 2 | 3 | import Data.Function ((&)) 4 | 5 | 6 | inc :: Num n => n -> n 7 | inc x = 8 | x + 1 9 | 10 | 11 | main :: IO () 12 | main = 13 | 0 14 | & iterate inc 15 | & map show 16 | & map putStrLn 17 | & take 50 18 | & sequence_ 19 | -------------------------------------------------------------------------------- /haskell/beautiful-concurrency/README.md: -------------------------------------------------------------------------------- 1 | # beautiful-concurrency 2 | 3 | https://www.schoolofhaskell.com/school/advanced-haskell/beautiful-concurrency/ 4 | -------------------------------------------------------------------------------- /haskell/beautiful-concurrency/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /haskell/brent-yorgeys-cis194/01-introduction/README.md: -------------------------------------------------------------------------------- 1 | http://www.seas.upenn.edu/~cis194/fall14/lectures/01-intro.html 2 | -------------------------------------------------------------------------------- /haskell/brent-yorgeys-cis194/02-working-with-lists/README.md: -------------------------------------------------------------------------------- 1 | There was no lecture this week 2 | -------------------------------------------------------------------------------- /haskell/brent-yorgeys-cis194/03-algebraic-data-types/README.md: -------------------------------------------------------------------------------- 1 | http://www.seas.upenn.edu/~cis194/fall14/lectures/03-ADTs.html 2 | -------------------------------------------------------------------------------- /haskell/brent-yorgeys-cis194/README.md: -------------------------------------------------------------------------------- 1 | # upenn.edu CIS 194: Introduction to Haskell 2 | 3 | http://www.seas.upenn.edu/~cis194/ 4 | 5 | http://www.seas.upenn.edu/~cis194/fall14/ 6 | 7 | http://www.seas.upenn.edu/~cis194/spring13/ 8 | -------------------------------------------------------------------------------- /haskell/bricky/README.md: -------------------------------------------------------------------------------- 1 | # bricky 2 | -------------------------------------------------------------------------------- /haskell/bricky/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /haskell/bricky/src/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib 2 | ( someFunc 3 | ) where 4 | 5 | someFunc :: IO () 6 | someFunc = putStrLn "someFunc" 7 | -------------------------------------------------------------------------------- /haskell/bricky/test/Spec.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = putStrLn "Test suite not yet implemented" 3 | -------------------------------------------------------------------------------- /haskell/csound-expression/tut-01-intro.lhs: -------------------------------------------------------------------------------- 1 | github.com/anton-k/csound-expression/blob/master/tutorial/chapters/Intro.md 2 | 3 | > module Intro where 4 | > import Csound.Base 5 | 6 | Lets play a sine wave at 440 7 | 8 | > zero :: IO () 9 | > zero = dac $ osc 440 10 | 11 | Magic! 12 | -------------------------------------------------------------------------------- /haskell/edx-fp101x/04-hw-03.hs: -------------------------------------------------------------------------------- 1 | module HW where 2 | 3 | factors :: Integral t => t -> [t] 4 | factors n = [i | i <-[1..n], (mod n i) == 0] 5 | 6 | -- perfects :: Integral t => t -> [t] 7 | -- perfects n = [x | x <- [1..n], isPerfect x ] 8 | -- where isPerfect num = sum (factors num) == num 9 | 10 | perfects :: Integral t => t -> [t] 11 | perfects n = [x | x <- [1..n], isPerfect x ] 12 | where isPerfect num = sum (init (factors num)) == num 13 | -------------------------------------------------------------------------------- /haskell/edx-fp101x/04-hw-05.hs: -------------------------------------------------------------------------------- 1 | module HW where 2 | 3 | find :: (Eq a) => a -> [(a,b)] -> [b] 4 | find k t = [v | (k', v) <- t, k == k'] 5 | 6 | positions :: (Eq a) => a -> [a] -> [Int] 7 | 8 | positions x xs = find x (zip xs [0..n]) 9 | where 10 | n = length xs - 1 11 | -------------------------------------------------------------------------------- /haskell/edx-fp101x/04-hw-07.hs: -------------------------------------------------------------------------------- 1 | module HW where 2 | 3 | import Data.Char 4 | 5 | let2int :: Char -> Int 6 | let2int c = ord c - ord 'a' 7 | 8 | int2let :: Int -> Char 9 | int2let n = chr (ord 'a' + n) 10 | 11 | shift :: Int -> Char -> Char 12 | shift n c 13 | | isLower c = int2let $ (let2int c + n) `mod` 26 14 | | isUpper c = toUpper $ int2let $ (let2int (toLower c) + n) `mod` 26 15 | | otherwise = c 16 | 17 | encode :: Int -> String -> String 18 | encode n xs = [shift n x | x <- xs] 19 | -------------------------------------------------------------------------------- /haskell/edx-fp101x/04-hw-13.hs: -------------------------------------------------------------------------------- 1 | module HW where 2 | 3 | divides :: Int -> Int -> Bool 4 | divides n divisor = mod n divisor == 0 5 | 6 | divisors :: Int -> [Int] 7 | divisors x = [d | d <- [1..x], x `divides` d] 8 | -------------------------------------------------------------------------------- /haskell/edx-fp101x/06-hw-05.hs: -------------------------------------------------------------------------------- 1 | module HW where 2 | 3 | import Prelude hiding (map) 4 | 5 | map :: (a -> b) -> [a] -> [b] 6 | 7 | -- -- Incorrect: foldr doesn't work on infinite lists 8 | -- map f = foldr (\x xs -> xs ++ [f x]) [] 9 | 10 | -- -- Incorrect: foldr, doesn't f all 11 | -- map f = foldr (\x xs -> f x ++ xs) [] 12 | 13 | map f = foldl (\xs x -> f x : xs) [] 14 | 15 | map f = foldl (\xs x -> f x ++ [f xs]) [] 16 | -------------------------------------------------------------------------------- /haskell/edx-fp101x/README.md: -------------------------------------------------------------------------------- 1 | # edX DelftX FP101x 2 | 3 | https://www.edx.org/course/delftx/delftx-fp101x-introduction-functional-2126 4 | -------------------------------------------------------------------------------- /haskell/fizzbuzz.hs: -------------------------------------------------------------------------------- 1 | module FizzBuzz where 2 | 3 | fizzbuzz :: (Show a, Integral a) => a -> String 4 | fizzbuzz x = unlines $ map fb [1..x] 5 | where 6 | fb y 7 | | mod y 15 == 0 = "FizzBuzz" 8 | | mod y 5 == 0 = "Fizz" 9 | | mod y 3 == 0 = "Buzz" 10 | | otherwise = show x 11 | -------------------------------------------------------------------------------- /haskell/hanoi.hs: -------------------------------------------------------------------------------- 1 | module Hanoi where 2 | 3 | type Peg = String 4 | type Move = (Peg, Peg) 5 | 6 | hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] 7 | hanoi 0 _ _ _ = [] 8 | hanoi num a b c = hanoi (num - 1) a c b ++ 9 | [(a, b)] ++ 10 | hanoi (num - 1) c b a 11 | -------------------------------------------------------------------------------- /haskell/haskell-exchange-2018.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/haskell/haskell-exchange-2018.md -------------------------------------------------------------------------------- /haskell/hsc3-play/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import System.Process 4 | import Sound.SC3 5 | 6 | main :: IO () 7 | main = do 8 | system "scsynth -u 57110 &" 9 | system "sleep 5" 10 | system "jack_connect SuperCollider:out_1 system:playback_1" 11 | system "jack_connect SuperCollider:out_2 system:playback_2" 12 | putStrLn "Bleep bloop" 13 | -------------------------------------------------------------------------------- /haskell/hsc3-play/README.md: -------------------------------------------------------------------------------- 1 | # hsc3-play 2 | 3 | ``` 4 | scsynth -u 57110 5 | ``` 6 | 7 | http://rd.slavepianos.org/?t=hsc3-texts&e=lhs/hsc3-tutorial.lhs 8 | -------------------------------------------------------------------------------- /haskell/hsc3-play/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /haskell/largestDivisible.hs: -------------------------------------------------------------------------------- 1 | module LargestDivisible where 2 | 3 | largestDivisible :: (Integral a) => a -> a -> a 4 | largestDivisible x divider 5 | | divider > x = -1 6 | | otherwise = head $ filter divisable [x, (x - 1)..x] 7 | where 8 | divisable y = mod y divider == 0 9 | -------------------------------------------------------------------------------- /haskell/magic.lhs: -------------------------------------------------------------------------------- 1 | 'You can run this with ruby, coffee -l, runhaskell, or python3. Magic.' 2 | '''' 3 | 4 | puts 'Hello from Ruby!' 5 | 6 | __END__ 7 | 8 | console.log 'Hello from Coffeescript!' 9 | 10 | > main = putStrLn "Hello from Haskell!" 11 | 12 | ''' 13 | 14 | print("Hello from Python!") 15 | -------------------------------------------------------------------------------- /haskell/megaparse/README.md: -------------------------------------------------------------------------------- 1 | # megaparse 2 | 3 | add description of megaparse here -------------------------------------------------------------------------------- /haskell/megaparse/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /haskell/megaparse/test/Spec.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF hspec-discover #-} 2 | -------------------------------------------------------------------------------- /haskell/okc.hs: -------------------------------------------------------------------------------- 1 | module Okc where 2 | 3 | -- What is next in this series? 1, 4, 10, 19, 31, _ 4 | 5 | seq1 :: (Eq a, Num a) => a -> a 6 | seq1 1 = 1 7 | seq1 x = seq1 (x - 1) + (x - 1) * 3 8 | 9 | -- print $ seq1 6 10 | -- 46 11 | -------------------------------------------------------------------------------- /haskell/prelude-remake/abs.hs: -------------------------------------------------------------------------------- 1 | module Abs where 2 | 3 | import Prelude hiding (abs) 4 | 5 | abs :: Ord a => Num a => a -> a 6 | abs x 7 | | x < 0 = -x 8 | | otherwise = x 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/all.hs: -------------------------------------------------------------------------------- 1 | module All where 2 | 3 | import Prelude hiding (all) 4 | 5 | all :: (a -> Bool) -> [a] -> Bool 6 | all _ [] = True 7 | all f (x:xs) 8 | | f x = all f xs 9 | | otherwise = False 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/ampamp.hs: -------------------------------------------------------------------------------- 1 | module AmpAmp where 2 | 3 | import Prelude hiding ((&&)) 4 | 5 | -- We define it like this to prevent evaluation of the second param 6 | 7 | (&&) :: Bool -> Bool -> Bool 8 | (&&) True x = x 9 | (&&) False _ = False 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/and.hs: -------------------------------------------------------------------------------- 1 | module And where 2 | 3 | import Prelude hiding (and) 4 | 5 | and :: [Bool] -> Bool 6 | and = foldr1 (&&) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/any.hs: -------------------------------------------------------------------------------- 1 | module Any where 2 | 3 | import Prelude hiding (any) 4 | 5 | any :: (a -> Bool) -> [a] -> Bool 6 | any _ [] = False 7 | any f (x:xs) 8 | | f x = True 9 | | otherwise = any f xs 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/bangBang.hs: -------------------------------------------------------------------------------- 1 | module BangBang where 2 | 3 | import Prelude hiding ((!!)) 4 | 5 | (!!) :: [a] -> Int -> a 6 | (!!) (x:_) 0 = x 7 | (!!) (_:xs) n = (!!) xs $ n - 1 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/concat.hs: -------------------------------------------------------------------------------- 1 | module Concat where 2 | 3 | import Prelude hiding (concat) 4 | 5 | concat :: [[a]] -> [a] 6 | concat = foldr1 (++) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/curry.hs: -------------------------------------------------------------------------------- 1 | module Curry where 2 | 3 | import Prelude hiding (curry) 4 | 5 | curry :: ((a, b) -> c) -> a -> b -> c 6 | curry f a b = f (a, b) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/cycle.hs: -------------------------------------------------------------------------------- 1 | module Cycle where 2 | 3 | import Prelude hiding (cycle) 4 | 5 | cycle :: [a] -> [a] 6 | cycle [] = error "Prelude.cycle: empty list" 7 | cycle xs = loop where loop = xs ++ loop 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/div.hs: -------------------------------------------------------------------------------- 1 | module Div where 2 | 3 | import Prelude hiding (div) 4 | 5 | div :: (Num a, Ord a) => a -> a -> a 6 | div x y = loop x y 0 7 | where 8 | loop n d acc 9 | | n < d = acc 10 | | otherwise = loop (n - d) d (acc + 1) 11 | -------------------------------------------------------------------------------- /haskell/prelude-remake/dot.hs: -------------------------------------------------------------------------------- 1 | module Dot where 2 | 3 | import Prelude hiding ((.)) 4 | 5 | (.) :: (b -> c) -> (a -> b) -> a -> c 6 | (.) x y z = x (y z) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/drop.hs: -------------------------------------------------------------------------------- 1 | module Drop where 2 | 3 | import Prelude hiding (drop) 4 | 5 | drop :: Int -> [a] -> [a] 6 | drop _ [] = [] 7 | drop 0 xs = xs 8 | drop n (_:xs) = drop (n - 1) xs 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/dropWhile.hs: -------------------------------------------------------------------------------- 1 | module DropWhile where 2 | 3 | import Prelude hiding (dropWhile) 4 | 5 | dropWhile :: (a -> Bool) -> [a] -> [a] 6 | dropWhile _ [] = [] 7 | dropWhile f xxs@(x:xs) 8 | | f x = dropWhile f xs 9 | | otherwise = xxs 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/elem.hs: -------------------------------------------------------------------------------- 1 | module Elem where 2 | 3 | import Prelude hiding (elem) 4 | 5 | elem :: Eq a => a -> [a] -> Bool 6 | elem _ [] = False 7 | elem y (x:xs) 8 | | y == x = True 9 | | otherwise = elem y xs 10 | 11 | elem2 :: Eq a => a -> [a] -> Bool 12 | elem2 x = any (== x) 13 | -------------------------------------------------------------------------------- /haskell/prelude-remake/even.hs: -------------------------------------------------------------------------------- 1 | module Even where 2 | 3 | import Prelude hiding (even) 4 | 5 | even :: Integral a => a -> Bool 6 | even x = mod x 2 == 0 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/filter.hs: -------------------------------------------------------------------------------- 1 | module Filter where 2 | 3 | import Prelude hiding (filter) 4 | 5 | -- Explicit recursion 6 | filter :: (a -> Bool) -> [a] -> [a] 7 | filter _ [] = [] 8 | filter f (x:xs) 9 | | f x = x : filter f xs 10 | | otherwise = filter f xs 11 | 12 | -- Fold 13 | filter1 :: (a -> Bool) -> [a] -> [a] 14 | filter1 f = foldl fil [] 15 | where 16 | fil acc x 17 | | f x = x : acc 18 | | otherwise = acc 19 | -------------------------------------------------------------------------------- /haskell/prelude-remake/flip.hs: -------------------------------------------------------------------------------- 1 | module Flip where 2 | 3 | import Prelude hiding (flip) 4 | 5 | flip :: (a -> b -> c) -> b -> a -> c 6 | flip f a b = f b a 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/fst.hs: -------------------------------------------------------------------------------- 1 | module Fst where 2 | 3 | import Prelude hiding (fst) 4 | 5 | fst :: (a, b) -> a 6 | fst (x, _) = x 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/hat.hs: -------------------------------------------------------------------------------- 1 | module Hat where 2 | 3 | import Prelude hiding ((^)) 4 | 5 | (^) :: (Num a, Integral b) => a -> b -> a 6 | _ ^ 0 = 1 7 | n ^ x 8 | | x < 0 = error "Negative exponent" 9 | | otherwise = n * n ^ (x - 1) 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/head.hs: -------------------------------------------------------------------------------- 1 | module Head where 2 | 3 | import Prelude hiding (head) 4 | 5 | head :: [a] -> a 6 | head [] = error "Prelude.head: empty list" 7 | head (x:_) = x 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/id.hs: -------------------------------------------------------------------------------- 1 | module ID where 2 | 3 | import Prelude hiding (id) 4 | 5 | id :: a -> a 6 | id x = x 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/init.hs: -------------------------------------------------------------------------------- 1 | module Init where 2 | 3 | import Prelude hiding (init) 4 | 5 | init :: [a] -> [a] 6 | init [] = error "init: empty list" 7 | init [_] = [] 8 | init (x:xs) = x : init xs 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/iterate.hs: -------------------------------------------------------------------------------- 1 | module Iterate where 2 | 3 | import Prelude hiding (iterate) 4 | 5 | iterate :: (a -> a) -> a -> [a] 6 | iterate f x = x : iterate f (f x) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/last.hs: -------------------------------------------------------------------------------- 1 | module Last where 2 | 3 | import Prelude hiding (last) 4 | 5 | last :: [a] -> a 6 | last [] = error "last: empty list" 7 | last [x] = x 8 | last (_:xs) = last xs 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/length.hs: -------------------------------------------------------------------------------- 1 | module Length where 2 | 3 | import Prelude hiding (length) 4 | 5 | length :: Integral b => [a] -> b 6 | length xs = 7 | let loop [] count = count 8 | loop (_:ys) count = loop ys $ succ count 9 | in loop xs 0 10 | 11 | -- I think this builds up a lot of thunks and uses a lot of memory. 12 | length2 :: Integral b => [a] -> b 13 | length2 = foldr (\_ count -> succ count) 0 14 | -------------------------------------------------------------------------------- /haskell/prelude-remake/lookup.hs: -------------------------------------------------------------------------------- 1 | module Lookup where 2 | 3 | import Prelude hiding (lookup) 4 | 5 | lookup :: Eq a => a -> [(a, b)] -> Maybe b 6 | lookup _ [] = Nothing 7 | lookup x ((key, val):rest) 8 | | x == key = Just val 9 | | otherwise = lookup x rest 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/map.hs: -------------------------------------------------------------------------------- 1 | module Map where 2 | 3 | import Prelude hiding (map) 4 | 5 | -- Explicit recursion 6 | map :: (a -> b) -> [a] -> [b] 7 | map _ [] = [] 8 | map f (x:xs) = f x : map f xs 9 | 10 | -- Foldl 11 | map1 :: (a -> b) -> [a] -> [b] 12 | map1 f xs = reverse $ foldl comp [] xs 13 | where 14 | comp acc x = f x : acc 15 | -------------------------------------------------------------------------------- /haskell/prelude-remake/min.hs: -------------------------------------------------------------------------------- 1 | module Min where 2 | 3 | import Prelude hiding (min) 4 | 5 | min :: Ord a => a -> a -> a 6 | min x y 7 | | x > y = y 8 | | otherwise = x 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/minimum.hs: -------------------------------------------------------------------------------- 1 | module Minimum where 2 | 3 | import Prelude hiding (minimum) 4 | 5 | minimum :: Ord a => [a] -> a 6 | minimum = foldr1 min 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/negate.hs: -------------------------------------------------------------------------------- 1 | module Negate where 2 | 3 | import Prelude hiding (negate) 4 | 5 | negate :: Num a => a -> a 6 | negate = (0 -) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/not.hs: -------------------------------------------------------------------------------- 1 | module Not where 2 | 3 | import Prelude hiding (not) 4 | 5 | not :: Bool -> Bool 6 | not True = False 7 | not False = True 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/notElem.hs: -------------------------------------------------------------------------------- 1 | module NotElem where 2 | 3 | import Prelude hiding (notElem) 4 | 5 | notElem :: Eq a => a -> [a] -> Bool 6 | notElem x = all (/= x) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/null.hs: -------------------------------------------------------------------------------- 1 | module Null where 2 | 3 | import Prelude hiding (null) 4 | 5 | null :: [a] -> Bool 6 | null [] = True 7 | null _ = False 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/odd.hs: -------------------------------------------------------------------------------- 1 | module Odd where 2 | 3 | import Prelude hiding (odd) 4 | 5 | odd :: Integral a => a -> Bool 6 | odd = not . even 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/or.hs: -------------------------------------------------------------------------------- 1 | module Or where 2 | 3 | import Prelude hiding (or) 4 | 5 | or :: [Bool] -> Bool 6 | or = foldr1 (||) 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/otherwise.hs: -------------------------------------------------------------------------------- 1 | module Otherwise where 2 | 3 | import Prelude hiding (otherwise) 4 | 5 | otherwise :: Bool 6 | otherwise = True 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/pipepipe.hs: -------------------------------------------------------------------------------- 1 | module PipePipe where 2 | 3 | import Prelude hiding ((||)) 4 | 5 | -- We define it like this to prevent evaluation of the second param 6 | 7 | (||) :: Bool -> Bool -> Bool 8 | (||) True _ = True 9 | (||) False x = x 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/product.hs: -------------------------------------------------------------------------------- 1 | module Product where 2 | 3 | import Prelude hiding (product) 4 | 5 | product :: Num a => [a] -> a 6 | product [] = 1 7 | product (x:xs) = product xs * x 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/repeat.hs: -------------------------------------------------------------------------------- 1 | module Repeat where 2 | 3 | import Prelude hiding (repeat) 4 | 5 | repeat :: a -> [a] 6 | repeat x = 7 | let loop xs = x : loop xs 8 | in loop [] 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/reverse.hs: -------------------------------------------------------------------------------- 1 | module Reverse where 2 | 3 | import Prelude hiding (reverse) 4 | 5 | reverse :: [a] -> [a] 6 | reverse = foldl (flip (:)) [] 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/sum.hs: -------------------------------------------------------------------------------- 1 | module Sum where 2 | 3 | import Prelude hiding (sum) 4 | 5 | sum :: Num a => [a] -> a 6 | sum [] = 0 7 | sum (x:xs) = x + sum xs 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/tail.hs: -------------------------------------------------------------------------------- 1 | module Tail where 2 | 3 | import Prelude hiding (tail) 4 | 5 | tail :: [a] -> [a] 6 | tail [] = error "tail: empty list" 7 | tail (_:xs) = xs 8 | -------------------------------------------------------------------------------- /haskell/prelude-remake/takeWhile.hs: -------------------------------------------------------------------------------- 1 | module TakeWhile where 2 | 3 | import Prelude hiding (takeWhile) 4 | 5 | takeWhile :: (a -> Bool) -> [a] -> [a] 6 | takeWhile _ [] = [] 7 | takeWhile f (x:xs) 8 | | not $ f x = [] 9 | | otherwise = x : takeWhile f xs 10 | -------------------------------------------------------------------------------- /haskell/prelude-remake/uncurry.hs: -------------------------------------------------------------------------------- 1 | module Uncurry where 2 | 3 | import Prelude hiding (uncurry) 4 | 5 | uncurry :: (a -> b -> c) -> (a, b) -> c 6 | uncurry f (x, y) = f x y 7 | -------------------------------------------------------------------------------- /haskell/prelude-remake/until.hs: -------------------------------------------------------------------------------- 1 | module Until where 2 | 3 | import Prelude hiding (until) 4 | 5 | until :: (a -> Bool) -> (a -> a) -> a -> a 6 | until p f x 7 | | p x = x 8 | | otherwise = until p f $ f x 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/unzip.hs: -------------------------------------------------------------------------------- 1 | module Unzip where 2 | 3 | import Prelude hiding (unzip) 4 | 5 | unzip :: [(a, b)] -> ([a], [b]) 6 | unzip xs = 7 | let split (y, z) (ys, zs) = (y:ys, z:zs) 8 | in foldr split ([], []) xs 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/zip.hs: -------------------------------------------------------------------------------- 1 | module Zip where 2 | 3 | import Prelude hiding (zip) 4 | 5 | zip :: [a] -> [b] -> [(a, b)] 6 | zip _ [] = [] 7 | zip [] _ = [] 8 | zip (x:xs) (y:ys) = (x, y) : zip xs ys 9 | -------------------------------------------------------------------------------- /haskell/prelude-remake/zipWith.hs: -------------------------------------------------------------------------------- 1 | module ZipWith where 2 | 3 | import Prelude hiding (zipWith) 4 | 5 | zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] 6 | zipWith _ [] _ = [] 7 | zipWith _ _ [] = [] 8 | zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys 9 | -------------------------------------------------------------------------------- /haskell/quicksort.hs: -------------------------------------------------------------------------------- 1 | module Quicksort where 2 | 3 | quicksort :: (Ord a) => [a] -> [a] 4 | quicksort [] = [] 5 | quicksort (x:xs) = smaller ++ [x] ++ bigger 6 | where 7 | smaller = quicksort $ filter (<= x) xs 8 | bigger = quicksort $ filter (> x) xs 9 | -------------------------------------------------------------------------------- /haskell/testing/spec/head-spec.hs: -------------------------------------------------------------------------------- 1 | import Test.Hspec 2 | import Test.QuickCheck 3 | 4 | main :: IO () 5 | main = hspec spec 6 | 7 | spec :: Spec 8 | spec = describe "Prelude.head" $ do 9 | it "returns the first element of a list" $ 10 | head [23 ..] `shouldBe` (23 :: Int) 11 | 12 | it "returns the first element of an *arbitrary* list" $ 13 | property $ \x xs -> head (x:xs) == (x :: Int) 14 | 15 | it "throws an exception if used with an empty list" $ 16 | head [] `shouldThrow` anyException 17 | -------------------------------------------------------------------------------- /haskell/thinking-functionally/.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work 2 | -------------------------------------------------------------------------------- /haskell/thinking-functionally/README.md: -------------------------------------------------------------------------------- 1 | Thinking Functionally With Haskell, by Richard Bird 2 | -------------------------------------------------------------------------------- /haskell/thinking-functionally/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /haskell/thinking-functionally/app/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Lib 4 | 5 | main :: IO () 6 | main = someFunc 7 | -------------------------------------------------------------------------------- /haskell/thinking-functionally/src/Lib.hs: -------------------------------------------------------------------------------- 1 | module Lib 2 | ( someFunc 3 | ) where 4 | 5 | someFunc :: IO () 6 | someFunc = putStrLn "someFunc" 7 | -------------------------------------------------------------------------------- /haskell/thinking-functionally/test/Spec.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF hspec-discover #-} 2 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/README.md: -------------------------------------------------------------------------------- 1 | # Turtle Tutorial 2 | 3 | https://hackage.haskell.org/package/turtle-1.0.1/docs/Turtle-Tutorial.html 4 | 5 | ### Dependencies 6 | 7 | ``` 8 | turtle 9 | ``` 10 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/eight.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | main :: IO ExitCode 8 | main = do 9 | mkdir "test" 10 | shell "tar czf test.tar.gz test" empty 11 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/five.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | datePwd = do 8 | dir <- pwd 9 | result <- datefile dir 10 | return result 11 | 12 | main = do 13 | time <- datePwd 14 | print time 15 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/four.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | main = do 8 | dir <- pwd 9 | time <- datefile dir 10 | print time 11 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/one.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | main :: IO () 8 | main = echo "Hello, world!" 9 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/seven.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | datePwd :: IO UTCTime 8 | datePwd = do 9 | dir <- pwd 10 | datefile dir 11 | 12 | main :: IO () 13 | main = do 14 | timeVal <- datePwd 15 | print timeVal 16 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/six.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | datePwd = do 8 | dir <- pwd 9 | datefile dir 10 | 11 | main = do 12 | time <- datePwd 13 | print time 14 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/three.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | main = do 8 | echo "Hello!" 9 | echo "World!" 10 | -------------------------------------------------------------------------------- /haskell/turtle-tutorial/two.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | {-# LANGUAGE OverloadedStrings #-} 4 | 5 | import Turtle 6 | 7 | str = "Hello!" 8 | 9 | main = echo str 10 | -------------------------------------------------------------------------------- /idris/.gitignore: -------------------------------------------------------------------------------- 1 | *.ibc 2 | *.o 3 | *.js 4 | -------------------------------------------------------------------------------- /idris/misc/HelloWorld.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | 3 | main : IO () 4 | -- main = putStrLn "Hello, world!" 5 | -- main = putStrLn ?greeting 6 | -- main = putStrLn 'x' 7 | -- main = putStrLn (?convert 'x') 8 | main = putStrLn (cast 'x') 9 | -------------------------------------------------------------------------------- /idris/misc/Pipeline.idr: -------------------------------------------------------------------------------- 1 | module Pipeline 2 | 3 | infixl 9 |> 4 | infixr 0 <| 5 | 6 | %access public export 7 | 8 | 9 | ||| Pipeline style function application 10 | (|>) : a -> (a -> b) -> b 11 | a |> f = f a 12 | 13 | 14 | ||| Backwards pipeline style function application 15 | (<|) : (a -> b) -> a -> b 16 | f <| a = f a 17 | -------------------------------------------------------------------------------- /idris/misc/Repl.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | 3 | main : IO () 4 | main = 5 | repl "What's up?\n" (\x => x ++ "? Cool.\n") 6 | -------------------------------------------------------------------------------- /javascript/.gitignore: -------------------------------------------------------------------------------- 1 | codeabbey/input.txt 2 | node_modules/* 3 | */node_modules/* 4 | *.log 5 | -------------------------------------------------------------------------------- /javascript/codeabbey/000-sum-a-b.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | // var input = '3 5'; 4 | var input = '3797420 2064975'; 5 | 6 | var output = input 7 | .split(' ') 8 | .reduce( 9 | function(acc, e) { return acc + parseInt(e, 10); }, 10 | 0); 11 | 12 | console.log(output); 13 | -------------------------------------------------------------------------------- /javascript/codeabbey/001-sum-in-loop.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var fs, input, output; 4 | 5 | fs = require('fs'); 6 | input = fs.readFileSync('./input.txt', 'utf8') 7 | .split('\n') 8 | .slice(1, -1) 9 | [0] 10 | .split(' '); 11 | 12 | 13 | output = input.reduce( 14 | function(acc, e) { return acc + parseInt(e, 10); }, 15 | 0); 16 | 17 | console.log(output); 18 | -------------------------------------------------------------------------------- /javascript/codeabbey/002-sums-in-loop.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var fs, input, output; 4 | 5 | fs = require('fs'); 6 | input = fs.readFileSync('./input.txt', 'utf8') 7 | .split('\n') 8 | .slice(1, -1) 9 | .map(function(e) { return e.split(' '); }); 10 | 11 | output = input.map(function(nums) { 12 | return nums.reduce( 13 | function(acc, e) { return acc + parseInt(e, 10); }, 14 | 0); 15 | }).join(' '); 16 | 17 | console.log(output); 18 | -------------------------------------------------------------------------------- /javascript/codeabbey/007-far-to-cel.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var input, output; 4 | 5 | input = require('fs') 6 | .readFileSync('./input.txt', 'utf8') 7 | .split(' ') 8 | .slice(1) 9 | .map(function(num) { 10 | return parseInt(num, 10); 11 | }); 12 | 13 | output = input.map(function(fahrenheit) { 14 | return Math.round( 15 | (fahrenheit - 32) * (5/9) 16 | ); 17 | }).join(' '); 18 | 19 | console.log(output); 20 | -------------------------------------------------------------------------------- /javascript/codeabbey/011-dice-rolling.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var input, output; 4 | 5 | input = require('fs') 6 | .readFileSync('./input.txt', 'utf8') 7 | .split('\n') 8 | .slice(1, -1) 9 | .map(function(num) { 10 | return parseFloat(num); 11 | }); 12 | 13 | output = input.map(function(num) { 14 | return Math.floor(num * 6) + 1; 15 | }).join(' '); 16 | 17 | console.log(output); 18 | -------------------------------------------------------------------------------- /javascript/codeabbey/README.md: -------------------------------------------------------------------------------- 1 | # CodeAbbey 2 | 3 | http://www.codeabbey.com/ 4 | -------------------------------------------------------------------------------- /javascript/deno/server-example.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S deno run --allow-net 2 | 3 | import { serve } from "https://deno.land/std@0.71.0/http/server.ts"; 4 | 5 | const s = serve({ port: 8000 }); 6 | console.log("http://localhost:8000/"); 7 | for await (const req of s) { 8 | req.respond({ body: "Hello World\n" }); 9 | } 10 | -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/categories/bookmarks/create/bookmark-create.js: -------------------------------------------------------------------------------- 1 | angular.module('categories.bookmarks.create', []); 2 | -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/categories/bookmarks/create/bookmark-create.tmpl.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/javascript/egghead-angular/11-ui-router-state-params/app/categories/bookmarks/create/bookmark-create.tmpl.html -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/categories/bookmarks/edit/bookmark-edit.js: -------------------------------------------------------------------------------- 1 | angular.module('categories.bookmarks.edit', []); 2 | -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/categories/bookmarks/edit/bookmark-edit.tmpl.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/javascript/egghead-angular/11-ui-router-state-params/app/categories/bookmarks/edit/bookmark-edit.tmpl.html -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/categories/categories.tmpl.html: -------------------------------------------------------------------------------- 1 |

Categories

2 | 12 | -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/common/models/bookmarks-model.js: -------------------------------------------------------------------------------- 1 | angular.module('myApp.models.bookmarks', []); 2 | -------------------------------------------------------------------------------- /javascript/egghead-angular/11-ui-router-state-params/app/common/models/categories-model.js: -------------------------------------------------------------------------------- 1 | angular.module('myApp.models.categories', []); 2 | -------------------------------------------------------------------------------- /javascript/egghead-angular/README.md: -------------------------------------------------------------------------------- 1 | # Egghead.oi AngularJS 2 | 3 | [Getting Started](https://egghead.io/series/angularjs-app-from-scratch-getting-started): 4 | 00-06 5 | 6 | [Application Architecture](https://egghead.io/series/angularjs-application-architecture): 7 | 07+ 8 | -------------------------------------------------------------------------------- /javascript/egghead-angular/server.sh: -------------------------------------------------------------------------------- 1 | ruby -run -e httpd . -p 9090 2 | -------------------------------------------------------------------------------- /javascript/nodeschool-bug-clinic/00-intake.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | console.log('i am okay'); 4 | console.error('i am so incredibly not okay'); 5 | -------------------------------------------------------------------------------- /javascript/nodeschool-bug-clinic/01-triage.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require('fs'); 4 | 5 | var peach = function (obj) { 6 | // trace the message "traced" 7 | console.log(obj); 8 | }; 9 | 10 | var bowser = function (callback) { 11 | fs.readFile(process.argv[2], { encoding : 'utf8' }, callback); 12 | }; 13 | 14 | var koopa = function (error, file) { 15 | // handle error by printing something to stderr 16 | 17 | peach(JSON.parse(file)); 18 | }; 19 | 20 | bowser(koopa); 21 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/00-hello-world.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | console.log('HELLO WORLD'); 4 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/01-baby-steps.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | console.log( 4 | process.argv 5 | .slice(2) 6 | .reduce(function(acc, e) { 7 | return acc + parseInt(e, 10); 8 | }, 0) 9 | ); 10 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/02-my-first-io.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | console.log( 4 | require('fs') 5 | .readFileSync(process.argv[2], 'utf8') 6 | .split('\n') 7 | .length - 1 8 | ); 9 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/03-my-first-async-io.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('fs') 4 | .readFile(process.argv[2], 'utf8', function(err, data) { 5 | if (err) { throw err; } 6 | console.log(data.split('\n').length -1); 7 | }); 8 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/04-filtered-ls.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('fs').readdir(process.argv[2], function(err, files) { 4 | if (err) { throw err; } 5 | console.log( 6 | files.filter(function(file) { 7 | return require('path').extname(file) === '.' + process.argv[3]; 8 | } 9 | ).join('\n')); 10 | }); 11 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/05-make-it-modular.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // main 4 | 5 | require('./05-z-module')(process.argv[2], 6 | process.argv[3], 7 | function(err, data) { 8 | if (err) { throw err; } 9 | console.log(data.join('\n')); 10 | }); 11 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/05-z-module.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // module 4 | 5 | module.exports = function(dir, fileExt, callback) { 6 | require('fs').readdir(dir, function(err, files) { 7 | if (err) { return callback(err); } 8 | 9 | var filtered = files.filter(function(file) { 10 | return require('path').extname(file) === '.' + fileExt; }); 11 | 12 | return callback(err, filtered); 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/06-http-client.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('http').get(process.argv[2], function(response) { 4 | response.setEncoding('utf8'); 5 | 6 | response.on('data', console.log); 7 | response.on('error', console.error); 8 | }); 9 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/07-http-collect.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('http').get(process.argv[2], function(response) { 4 | var datas = []; 5 | 6 | response.setEncoding('utf8'); 7 | response.on('error', console.error); 8 | 9 | response.on('data', function(data) { datas.push(data); }); 10 | response.on('end', function() { 11 | var out = datas.join(''); 12 | console.log(out.length); 13 | console.log(out); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/10-http-file-server.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require('fs'); 4 | 5 | require('http') 6 | .createServer(function(request, response) { 7 | fs.createReadStream(process.argv[3]) 8 | .pipe(response); 9 | }) 10 | .listen(process.argv[2]); 11 | -------------------------------------------------------------------------------- /javascript/nodeschool-learnyounode/README.md: -------------------------------------------------------------------------------- 1 | # learnyounode 2 | 3 | http://nodeschool.io/#learnyounode 4 | 5 | https://github.com/rvagg/learnyounode 6 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/00-bleep-boop.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | console.log('beep boop'); 4 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/01-meet-pipe.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('fs').createReadStream(process.argv[2]) 4 | .pipe(process.stdout); 5 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/02-input-output.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | process.stdin 4 | .pipe(process.stdout); 5 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/03-transform.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | process.stdin 4 | .on('data', function(data) { 5 | process.stdout 6 | .write(data.toString().toUpperCase()); 7 | }); 8 | 9 | // Or with the through module 10 | 11 | // var thruFilter = require('through')(function(buf) { 12 | // this.queue(buf.toString().toUpperCase()); 13 | // }); 14 | // process.stdin 15 | // .pipe(thruFilter) 16 | // .pipe(process.stdout); 17 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/05-concat.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var concat = require('concat-stream'); 4 | 5 | process.stdin 6 | .pipe(concat(function(buffer) { 7 | process.stdout 8 | .write(buffer.toString() 9 | .split('') 10 | .reverse() 11 | .join('') + '\n'); 12 | })); 13 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/06-http-server.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var http = require('http'); 4 | 5 | http.createServer(function(req, res) { 6 | req.setEncoding('utf8'); 7 | 8 | req.on('error', console.error); 9 | req.on('end', function() { res.end(); }); 10 | 11 | req.on('data', function(data) { 12 | if (req.method === 'POST') { 13 | res.write(data.toUpperCase()); 14 | } 15 | }); 16 | } 17 | ).listen(process.argv[2]); 18 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/07-http-client.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var request = require('request'); 4 | 5 | process.stdin 6 | .pipe(request.post('http://localhost:8000')) 7 | .pipe(process.stdout); 8 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/08-websockets.js: -------------------------------------------------------------------------------- 1 | var stream = require('websocket-stream')('ws://localhost:8000'); 2 | 3 | stream.end('hello\n'); 4 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/09-html-stream.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var trumpet = require('trumpet'), 4 | tr = trumpet(), 5 | through = require('through'), 6 | loud; 7 | 8 | loud = tr.select('.loud').createStream(); 9 | 10 | loud.pipe(through(function(data) { 11 | this.queue(data.toString().toUpperCase()); 12 | })) 13 | .pipe(loud); 14 | 15 | process.stdin.pipe(tr).pipe(process.stdout); 16 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/10-duplexer.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var spawn = require('child_process').spawn; 4 | 5 | module.exports = function(cmd, args) { 6 | var child = spawn(cmd, args); 7 | 8 | return require('duplexer')(child.stdin, child.stdout); 9 | }; 10 | -------------------------------------------------------------------------------- /javascript/nodeschool-stream-adventure/README.md: -------------------------------------------------------------------------------- 1 | # stream-adventure 2 | 3 | http://nodeschool.io/ 4 | 5 | https://github.com/substack/stream-adventure 6 | -------------------------------------------------------------------------------- /kubernetes/cheap/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform 2 | -------------------------------------------------------------------------------- /kubernetes/cheap/infra/modules/infra/outputs.tf: -------------------------------------------------------------------------------- 1 | # output "service_ip" { 2 | # value = "${google_compute_forwarding_rule.app.ip_address}" 3 | # } 4 | -------------------------------------------------------------------------------- /kubernetes/cheap/infra/modules/infra/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | type = "string" 3 | } 4 | 5 | variable "env" { 6 | type = "string" 7 | } 8 | -------------------------------------------------------------------------------- /kubernetes/cheap/k8s/env/dev/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | backend "remote" { 3 | organization = "lpil" 4 | 5 | workspaces { 6 | name = "learning-k8s-cheap--k8s--dev" 7 | } 8 | } 9 | } 10 | 11 | provider "kubernetes" { 12 | version = "~> 1.6" 13 | } 14 | 15 | provider "template" { 16 | version = "~> 2.1" 17 | } 18 | 19 | provider "null" { 20 | version = "~> 2.1" 21 | } 22 | 23 | module "infra" { 24 | source = "../../modules/app" 25 | env = "dev" 26 | } 27 | -------------------------------------------------------------------------------- /kubernetes/cheap/k8s/modules/app/app_ingress.template.yml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: app-ingress 5 | namespace: ${NAMESPACE} 6 | spec: 7 | backend: 8 | serviceName: ${SERVICE_NAME} 9 | servicePort: ${SERVICE_PORT} 10 | -------------------------------------------------------------------------------- /kubernetes/cheap/k8s/modules/app/variables.tf: -------------------------------------------------------------------------------- 1 | variable "env" { 2 | type = "string" 3 | } 4 | -------------------------------------------------------------------------------- /kubernetes/kuard/bin/book-services-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | kubectl run alpaca-prod \ 4 | --image=gcr.io/kuar-demo/kuard-amd64:1 \ 5 | --replicas=3 \ 6 | --port=8080 \ 7 | --labels="ver=1,app=alpaca,env=prod" 8 | 9 | kubectl expose deployment alpaca-prod 10 | 11 | kubectl run bandicoot-prod \ 12 | --image=gcr.io/kuar-demo/kuard-amd64:2 \ 13 | --replicas=2 \ 14 | --port=8080 \ 15 | --labels="ver=1,app=bandicoot,env=prod" 16 | 17 | kubectl expose deployment bandicoot-prod 18 | -------------------------------------------------------------------------------- /kubernetes/kuard/my-config.yml: -------------------------------------------------------------------------------- 1 | # A ConfigMap object that holds some configuration values we can inject into 2 | # pods so that they can be configured for different environments. 3 | # 4 | apiVersion: v1 5 | kind: ConfigMap 6 | metadata: 7 | name: my-config 8 | data: 9 | another-param: another-value 10 | extra-param: extra-value 11 | my-config.txt: | 12 | # Hey look this is a multi-line value! 13 | # How exciting. 14 | parameter1 = value1 15 | parameter2 = value2 16 | -------------------------------------------------------------------------------- /lua/hello_world.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local thing = {name = "lua"} 4 | 5 | function thing.greet() 6 | print(thing.name) 7 | end 8 | 9 | thing.greet() 10 | -------------------------------------------------------------------------------- /music/README.md: -------------------------------------------------------------------------------- 1 | # Learning Music 2 | -------------------------------------------------------------------------------- /music/miller-puckette-book/README.md: -------------------------------------------------------------------------------- 1 | # Miller Puckette - The Theory and Technique of Electronic Music 2 | -------------------------------------------------------------------------------- /music/miller-puckette-book/p_020_additive.pd: -------------------------------------------------------------------------------- 1 | #N canvas 962 24 958 566 12; 2 | -------------------------------------------------------------------------------- /music/miller-puckette-book/p_020_dbtoorms.pd: -------------------------------------------------------------------------------- 1 | #N canvas 962 24 958 566 12; 2 | #X obj 26 20 osc~ 440; 3 | #X obj 24 129 *~ 0; 4 | #X obj 24 178 dac~; 5 | #X floatatom 52 54 5 0 0 0 - - -; 6 | #X obj 51 84 dbtorms; 7 | #X floatatom 80 129 5 0 0 0 - - -; 8 | #X connect 0 0 1 0; 9 | #X connect 1 0 2 0; 10 | #X connect 1 0 2 1; 11 | #X connect 3 0 4 0; 12 | #X connect 4 0 1 1; 13 | #X connect 4 0 5 0; 14 | -------------------------------------------------------------------------------- /nix/hello-world/shell.nix: -------------------------------------------------------------------------------- 1 | # 2 | # $ nix-shell 3 | # $ nix-shell --pure 4 | # 5 | 6 | { pkgs ? import {} }: 7 | 8 | with pkgs; 9 | 10 | mkShell { 11 | buildInputs = [ 12 | hello 13 | ]; 14 | } 15 | -------------------------------------------------------------------------------- /nix/nix-ssh-deploy/README.md: -------------------------------------------------------------------------------- 1 | # A Nix project 2 | 3 | I'm not a fan of NixOS' lack of state management, so let's just use a shell 4 | script and SSH to push new config to a server. 5 | 6 | Create a NixOS server (possibly using DigitalOcean and nix-infect) and then 7 | run `bin/deploy.sh`. 8 | 9 | Run `nix-channel --add https://nixos.org/channels/nixos-19.03 nixos` on the 10 | remote. 11 | -------------------------------------------------------------------------------- /nix/nix-ssh-deploy/bin/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | HOST=165.22.117.176 6 | USER=root 7 | ADDR=$USER@$HOST 8 | REMOTE_NIXOS_DIR=/etc/nixos 9 | LOCAL_SRC=./src/* 10 | 11 | scp -r $LOCAL_SRC $ADDR:$REMOTE_NIXOS_DIR 12 | ssh $ADDR nixos-rebuild switch 13 | -------------------------------------------------------------------------------- /nix/nix-ssh-deploy/src/hardware-configuration.nix: -------------------------------------------------------------------------------- 1 | { ... }: 2 | { 3 | imports = [ ]; 4 | boot.loader.grub.device = "/dev/vda"; 5 | fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; 6 | } 7 | -------------------------------------------------------------------------------- /ocaml/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib 3 | _build 4 | -------------------------------------------------------------------------------- /ocaml/README.md: -------------------------------------------------------------------------------- 1 | # Learning OCaml 2 | 3 | ```sh 4 | # Install the Bucklescript platform 5 | npm i -g bs-platform 6 | 7 | # Create new ReasonML project 8 | bsb -init my-first-app -theme basic-reason 9 | ``` 10 | -------------------------------------------------------------------------------- /ocaml/hello-bucklescript/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.obj 3 | *.out 4 | *.compile 5 | *.native 6 | *.byte 7 | *.cmo 8 | *.annot 9 | *.cmi 10 | *.cmx 11 | *.cmt 12 | *.cmti 13 | *.cma 14 | *.a 15 | *.cmxa 16 | *.obj 17 | *~ 18 | *.annot 19 | *.cmj 20 | *.bak 21 | *.mlast 22 | *.mliast 23 | .vscode 24 | .merlin 25 | lib 26 | -------------------------------------------------------------------------------- /ocaml/hello-bucklescript/README.md: -------------------------------------------------------------------------------- 1 | # Basic Reason Template 2 | 3 | Hello! This project allows you to quickly get started with Reason and 4 | BuckleScript. If you wanted a more sophisticated version, try the `react` 5 | template (`bsb -theme react -init .`). 6 | 7 | # Build 8 | ``` 9 | npm run build 10 | ``` 11 | 12 | # Build + Watch 13 | 14 | ``` 15 | npm run watch 16 | ``` 17 | -------------------------------------------------------------------------------- /ocaml/hello-bucklescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "clean": "bsb -clean-world", 6 | "build": "bsb -make-world", 7 | "watch": "bsb -make-world -w" 8 | }, 9 | "keywords": [ 10 | "BuckleScript" 11 | ], 12 | "license": "MIT", 13 | "devDependencies": { 14 | "bs-platform": "1.8.1" 15 | } 16 | } -------------------------------------------------------------------------------- /ocaml/hello-bucklescript/src/demo.re: -------------------------------------------------------------------------------- 1 | Js.log "Hello, BuckleScript and Reason!"; 2 | -------------------------------------------------------------------------------- /ocaml/hello-jbuilder/hello_world.ml: -------------------------------------------------------------------------------- 1 | ;; print_endline "Hello, world!" 2 | -------------------------------------------------------------------------------- /ocaml/hello-jbuilder/jbuild: -------------------------------------------------------------------------------- 1 | (jbuild_version 1) 2 | 3 | ;; This declare the hello_world executable implemented by hello_world.ml 4 | (executables 5 | ((names (hello_world test_mod)) 6 | (libraries (alcotest)))) 7 | 8 | (alias 9 | ((name runtest) 10 | (deps (test_mod.exe)) 11 | (action (run ${<})))) 12 | -------------------------------------------------------------------------------- /ocaml/jbuilder-reason/Makefile: -------------------------------------------------------------------------------- 1 | help: 2 | @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 3 | .PHONY: help 4 | 5 | watch: 6 | bin/watch.sh jbuilder build src/main.exe 7 | .PHONY: watch 8 | -------------------------------------------------------------------------------- /ocaml/jbuilder-reason/bin/watch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Runs a commend ever time a file is edited 4 | # Requires entr to be installed 5 | 6 | while true 7 | do 8 | ls -d src/* | entr -c -d $@ 9 | done 10 | -------------------------------------------------------------------------------- /ocaml/jbuilder-reason/src/Main.re: -------------------------------------------------------------------------------- 1 | open Core; 2 | 3 | let merge = (acc, x) => acc ++ sprintf("%d", x); 4 | 5 | [1, 2, 3] 6 | |> List.fold(~init="", ~f=merge) 7 | |> printf("Printing a message: %s\n") 8 | |> List.rev 9 | -------------------------------------------------------------------------------- /ocaml/jbuilder-reason/src/jbuild: -------------------------------------------------------------------------------- 1 | (executable 2 | ((name main) 3 | (libraries (core)) 4 | (preprocess (pps (ppx_jane))))) 5 | -------------------------------------------------------------------------------- /ocaml/real-world-mod-and-programs/Counter.ml: -------------------------------------------------------------------------------- 1 | open Core 2 | 3 | type t = (string, int) List.Assoc.t 4 | 5 | let empty = [] 6 | 7 | let get counter key = 8 | List.Assoc.find ~equal:( = ) counter key |> Option.value ~default:0 9 | 10 | 11 | let inc counter key = 12 | key |> get counter |> succ |> List.Assoc.add ~equal:( = ) counter key 13 | 14 | 15 | let to_list x = x 16 | -------------------------------------------------------------------------------- /ocaml/real-world-mod-and-programs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: run 2 | run: _build/default/program.exe 3 | _build/default/program.exe 4 | 5 | _build/default/program.exe: $(wildcard *.ml) $(wildcard *.mli) 6 | jbuilder build program.exe 7 | -------------------------------------------------------------------------------- /ocaml/real-world-mod-and-programs/jbuild: -------------------------------------------------------------------------------- 1 | (jbuild_version 1) 2 | 3 | ;; This declare the hello_world executable implemented by hello_world.ml 4 | (executables 5 | ((names (program)) 6 | (libraries (core)))) 7 | -------------------------------------------------------------------------------- /ocaml/real-world-mod-and-programs/program.ml: -------------------------------------------------------------------------------- 1 | open Core 2 | 3 | let x = Counter.empty 4 | 5 | let () = 6 | In_channel.fold_lines stdin ~init:Counter.empty ~f:Counter.inc 7 | |> Counter.to_list 8 | |> List.sort ~cmp:(fun (_, x) (_, y) -> Int.descending x y) 9 | |> Fn.flip List.take 10 10 | |> List.iter ~f:(fun (line, count) -> printf "%3d: %s\n" count line) 11 | -------------------------------------------------------------------------------- /ocaml/tut/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.obj 3 | *.out 4 | *.compile 5 | *.native 6 | *.byte 7 | *.cmo 8 | *.annot 9 | *.cmi 10 | *.cmx 11 | *.cmt 12 | *.cmti 13 | *.cma 14 | *.a 15 | *.cmxa 16 | *.obj 17 | *~ 18 | *.annot 19 | *.cmj 20 | *.bak 21 | lib/bs 22 | *.mlast 23 | *.mliast 24 | .vscode 25 | .merlin -------------------------------------------------------------------------------- /ocaml/tut/README.md: -------------------------------------------------------------------------------- 1 | # Basic Reason Template 2 | 3 | Hello! This project allows you to quickly get started with Reason and BuckleScript. If you wanted a more sophisticated version, try the `react` template (`bsb -theme react -init .`). 4 | 5 | # Build 6 | ``` 7 | npm run build 8 | ``` 9 | 10 | # Build + Watch 11 | 12 | ``` 13 | npm run watch 14 | ``` 15 | 16 | 17 | # Editor 18 | If you use `vscode`, Press `Windows + Shift + B` it will build automatically 19 | -------------------------------------------------------------------------------- /ocaml/tut/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tut", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "clean": "bsb -clean-world", 6 | "build": "bsb -make-world", 7 | "watch": "bsb -make-world -w" 8 | }, 9 | "keywords": [ 10 | "BuckleScript" 11 | ], 12 | "license": "MIT", 13 | "devDependencies": { 14 | "bs-platform": "1.9.0" 15 | } 16 | } -------------------------------------------------------------------------------- /ocaml/tut/src/basics.re: -------------------------------------------------------------------------------- 1 | let average a b => (a +. b) /. 2.0; 2 | 3 | let add_int_float a b => float_of_int a +. b; 4 | 5 | let rec range a b => 6 | if (a > b) { 7 | [] 8 | } else { 9 | [a, ...range (a + 1) b] 10 | }; 11 | 12 | let positive_sum a b => { 13 | let a = max a 0; 14 | let b = max b 0; 15 | a + b 16 | }; 17 | 18 | let give_me_a_three _ => 3; 19 | -------------------------------------------------------------------------------- /ocaml/tut/src/demo.re: -------------------------------------------------------------------------------- 1 | Js.log "Hello, BuckleScript and Reason!"; 2 | -------------------------------------------------------------------------------- /ocaml/tut/src/modules_a.re: -------------------------------------------------------------------------------- 1 | let integer = 1; 2 | -------------------------------------------------------------------------------- /ocaml/tut/src/modules_b.re: -------------------------------------------------------------------------------- 1 | let integer = Modules_a.integer; 2 | 3 | let nested_integer = Modules.Nested.integer; 4 | -------------------------------------------------------------------------------- /ocaml/tut/src/using_map.re: -------------------------------------------------------------------------------- 1 | module User = Map.Make String; 2 | 3 | let run () => { 4 | let users = 5 | User.empty |> User.add "Fred" "sugarplums" |> User.add "Tom" "ilovelucy" |> 6 | User.add "mark" "ocamlrules" |> 7 | User.add "pete" "linux"; 8 | users 9 | }; 10 | -------------------------------------------------------------------------------- /purescript/README.md: -------------------------------------------------------------------------------- 1 | # Learning Purescript 2 | -------------------------------------------------------------------------------- /purescript/connect-n/.gitignore: -------------------------------------------------------------------------------- 1 | /bower_components/ 2 | /node_modules/ 3 | /.pulp-cache/ 4 | /output/ 5 | /generated-docs/ 6 | /.psc* 7 | /.purs* 8 | /.psa* 9 | -------------------------------------------------------------------------------- /purescript/connect-n/src/Main.purs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Prelude 4 | import Control.Monad.Eff (Eff) 5 | import Control.Monad.Eff.Console (CONSOLE, log) 6 | 7 | main :: forall e. Eff (console :: CONSOLE | e) Unit 8 | main = do 9 | log "Hello sailor!" 10 | -------------------------------------------------------------------------------- /purescript/connect-n/test/Main.purs: -------------------------------------------------------------------------------- 1 | module Test.Main where 2 | 3 | import Prelude 4 | import Control.Monad.Eff (Eff) 5 | import Test.Unit.Main (runTest) 6 | import Test.Unit (suite) 7 | import Test.Connect as Connect 8 | 9 | main :: Eff _ Unit 10 | main = runTest do 11 | suite "tests" do 12 | Connect.tests 13 | -------------------------------------------------------------------------------- /purescript/express/.gitignore: -------------------------------------------------------------------------------- 1 | /bower_components/ 2 | /node_modules/ 3 | /.pulp-cache/ 4 | /output/ 5 | /generated-docs/ 6 | /.psc* 7 | /.purs* 8 | /.psa* 9 | -------------------------------------------------------------------------------- /purescript/express/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "express", 3 | "ignore": [ 4 | "**/.*", 5 | "node_modules", 6 | "bower_components", 7 | "output" 8 | ], 9 | "dependencies": { 10 | "purescript-express": "^0.6.0" 11 | }, 12 | "devDependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /purescript/express/src/Main.js: -------------------------------------------------------------------------------- 1 | exports.makeRequestHandler = function(psApp) { 2 | const express = require("express"); 3 | const expressApp = express(); 4 | psApp.value0(expressApp)(); 5 | return expressApp; 6 | }; 7 | -------------------------------------------------------------------------------- /purescript/express/src/function.js: -------------------------------------------------------------------------------- 1 | const app = require("./Main").app; 2 | 3 | exports.handle = app.handle; 4 | -------------------------------------------------------------------------------- /purescript/express/test/Main.purs: -------------------------------------------------------------------------------- 1 | module Test.Main where 2 | 3 | import Prelude 4 | import Control.Monad.Eff (Eff) 5 | import Control.Monad.Eff.Console (CONSOLE, log) 6 | 7 | main :: forall e. Eff (console :: CONSOLE | e) Unit 8 | main = do 9 | log "You should add some tests." 10 | -------------------------------------------------------------------------------- /purescript/express/test/test-handle-server.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const Main = require("../output/Main"); 3 | 4 | const port = process.env.PORT || 3000; 5 | const app = express(); 6 | 7 | app.all("*", Main.requestHandler); 8 | 9 | app.listen(port, error => { 10 | if (error) { 11 | console.error(error.message); 12 | process.exit(1); 13 | } else { 14 | console.log(`listening on localhost:${port}`); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /purescript/hello-world/.gitignore: -------------------------------------------------------------------------------- 1 | /bower_components/ 2 | /node_modules/ 3 | /.pulp-cache/ 4 | /output/ 5 | /.psc* 6 | /.psa* 7 | -------------------------------------------------------------------------------- /purescript/hello-world/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "ignore": [ 4 | "**/.*", 5 | "node_modules", 6 | "bower_components", 7 | "output" 8 | ], 9 | "dependencies": { 10 | "purescript-prelude": "^2.1.0", 11 | "purescript-console": "^2.0.0" 12 | }, 13 | "devDependencies": { 14 | "purescript-psci-support": "^2.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /purescript/hello-world/src/Main.purs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Prelude 4 | import Control.Monad.Eff (Eff) 5 | import Control.Monad.Eff.Console (CONSOLE, log) 6 | 7 | main :: forall e. Eff (console :: CONSOLE | e) Unit 8 | main = do 9 | log "Hello sailor!" 10 | -------------------------------------------------------------------------------- /purescript/hello-world/test/Main.purs: -------------------------------------------------------------------------------- 1 | module Test.Main where 2 | 3 | import Prelude 4 | import Control.Monad.Eff (Eff) 5 | import Control.Monad.Eff.Console (CONSOLE, log) 6 | 7 | main :: forall e. Eff (console :: CONSOLE | e) Unit 8 | main = do 9 | log "You should add some tests." 10 | -------------------------------------------------------------------------------- /ruby/.gitignore: -------------------------------------------------------------------------------- 1 | codeabbey/data* 2 | -------------------------------------------------------------------------------- /ruby/chef/chef-guide/.gitignore: -------------------------------------------------------------------------------- 1 | motd 2 | -------------------------------------------------------------------------------- /ruby/chef/chef-guide/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.0 2 | -------------------------------------------------------------------------------- /ruby/chef/chef-guide/0-goodbye.rb: -------------------------------------------------------------------------------- 1 | file 'motd' do 2 | action :delete 3 | end 4 | -------------------------------------------------------------------------------- /ruby/chef/chef-guide/0-hello.rb: -------------------------------------------------------------------------------- 1 | file 'motd' do 2 | content 'hello chef' 3 | end 4 | -------------------------------------------------------------------------------- /ruby/chef/chef-guide/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'chef' 4 | -------------------------------------------------------------------------------- /ruby/chef/chef-guide/README.md: -------------------------------------------------------------------------------- 1 | https://learn.chef.io/ubuntu/configure-a-resource/ 2 | 3 | chef-apply file.rb 4 | -------------------------------------------------------------------------------- /ruby/codeabbey/000_sum_ab.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | puts ARGV[0].to_f + ARGV[1].to_f 5 | -------------------------------------------------------------------------------- /ruby/codeabbey/001_sum_in_loop.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | puts ARGF.file.read.split("\n")[1].split(' ').reduce(0) { |a, e| a + e.to_f } 5 | -------------------------------------------------------------------------------- /ruby/codeabbey/002_sums_in_loop.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n").map do |line| 5 | nums = line.split(' ') 6 | if nums.size == 2 7 | nums[0].to_i + nums[1].to_i 8 | else 9 | nil 10 | end 11 | end.compact.join ' ' 12 | puts x 13 | -------------------------------------------------------------------------------- /ruby/codeabbey/003_min_of_two.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n").map do |line| 5 | nums = line.split(' ') 6 | if nums.size == 2 7 | nums.map { |e| e.to_i }.min 8 | else 9 | nil 10 | end 11 | end.compact.join ' ' 12 | puts x 13 | -------------------------------------------------------------------------------- /ruby/codeabbey/004_min_of_three.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n").map do |line| 5 | nums = line.split(' ') 6 | if nums.size == 3 7 | nums.map { |e| e.to_i }.min 8 | else 9 | nil 10 | end 11 | end.compact.join ' ' 12 | puts x 13 | -------------------------------------------------------------------------------- /ruby/codeabbey/005_max_of_array.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split(' ').map { |e| e.to_i } 5 | puts "#{x.max} #{x.min}" 6 | -------------------------------------------------------------------------------- /ruby/codeabbey/006_rounding.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n").map do |e| 5 | nums = e.split(' ') 6 | nums.size == 2 ? (nums[0].to_f / nums[1].to_f).round : nil 7 | end.compact.join ' ' 8 | puts x 9 | -------------------------------------------------------------------------------- /ruby/codeabbey/007_fahrenheit_to_celsius.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | nums = ARGF.file.read.split(' ') 5 | nums.shift 6 | nums.map! do |e| 7 | ((e.to_f - 32) * (5.0 / 9.0)).round 8 | end 9 | puts nums.join ' ' 10 | -------------------------------------------------------------------------------- /ruby/codeabbey/008_vowel_count.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n") 5 | x.shift 6 | puts x.map { |e| e.scan(/[aeiouy]/).size }.join ' ' 7 | -------------------------------------------------------------------------------- /ruby/codeabbey/009_median_of_three.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split "\n" 5 | x.shift 6 | x.map! do |e| 7 | e.split(' ').map { |n| n.to_i }.sort[1] 8 | end 9 | puts x.join ' ' 10 | -------------------------------------------------------------------------------- /ruby/codeabbey/010_bmi.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split "\n" 5 | x.shift 6 | x.map! do |e| 7 | e = e.split(' ') 8 | bmi = e[0].to_f / (e[1].to_f**2) 9 | if bmi < 18.5 10 | 'under' 11 | elsif bmi < 25 12 | 'normal' 13 | elsif bmi < 30 14 | 'over' 15 | else 16 | 'obese' 17 | end 18 | end 19 | puts x.join ' ' 20 | -------------------------------------------------------------------------------- /ruby/codeabbey/011_dice_rolling.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split "\n" 5 | x.shift 6 | puts x.map { |e| (e.to_f * 6).floor + 1 }.join ' ' 7 | -------------------------------------------------------------------------------- /ruby/codeabbey/012_weighted_sum_of_digits.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ').map do |e| 5 | a = 0 6 | e.scan(/./).each.with_index do |r, i| 7 | a += r.to_i * (i + 1) 8 | end 9 | a 10 | end.join ' ' 11 | puts x 12 | -------------------------------------------------------------------------------- /ruby/codeabbey/013_sum_of_digits.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | def sum_digits(num) 5 | def rec_sum(accumulator, num) 6 | return accumulator + num if num < 10 7 | accumulator += num % 10 8 | rec_sum accumulator, num / 10 9 | end 10 | rec_sum 0, num 11 | end 12 | 13 | x = ARGF.file.read.split "\n" 14 | x.shift 15 | x.map! do |e| 16 | e = e.split ' ' 17 | e[0].to_i * e[1].to_i + e[2].to_i 18 | end 19 | puts x.map { |e| sum_digits(e) }.join ' ' 20 | -------------------------------------------------------------------------------- /ruby/codeabbey/014_array_checksum.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ').map do |e| 5 | e.to_i 6 | end.reduce(0) do |a, e| 7 | ((a + e) * 113) % 10000007 8 | end 9 | puts x 10 | -------------------------------------------------------------------------------- /ruby/codeabbey/015_average_of_an_array.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split "\n" 5 | x.shift 6 | x.map! do |r| 7 | r = r.split(' ')[0..-2] 8 | (r.reduce(0) { |a, e| a + e.to_f } / r.size).round 9 | end 10 | puts x.join ' ' 11 | -------------------------------------------------------------------------------- /ruby/codeabbey/016_array_counters.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = [] 5 | ARGF.file.read.split("\n")[1].split(' ').each do |e| 6 | e = e.to_i - 1 7 | x[e] = x[e] ? x[e] + 1 : 1 8 | end 9 | puts x.join ' ' 10 | -------------------------------------------------------------------------------- /ruby/codeabbey/017_modular_calculator.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split "\n" 5 | start = x.shift.to_i 6 | x = x.reduce(start) do |a, e| 7 | e = e.split ' ' 8 | a.public_send e[0].to_sym, e[1].to_i 9 | end 10 | puts x 11 | -------------------------------------------------------------------------------- /ruby/codeabbey/018_bubble_sort.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ').map { |e| e.to_i } 5 | passes, swaps = 0, 0 6 | sorted = false 7 | until sorted 8 | clean_pass = true 9 | (0..x.size - 2).each do |e| 10 | if x[e] > x[e + 1] 11 | swaps += 1 12 | clean_pass = false 13 | x[e], x[e + 1] = x[e + 1], x[e] 14 | end 15 | end 16 | passes += 1 17 | sorted = true if clean_pass 18 | end 19 | puts "#{passes} #{swaps}" 20 | -------------------------------------------------------------------------------- /ruby/codeabbey/019_neumanns_rng.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ').map { |e| e.to_i } 5 | x.map! do |e| 6 | loops = 0 7 | chain = [] 8 | until chain.include? e 9 | chain << e 10 | loops += 1 11 | e **= 2 12 | # to_str, add leading zeros to get 8 chars if needed 13 | e = format('%08d', e) 14 | e = e[2..5].to_i 15 | end 16 | loops 17 | end 18 | puts x.join ' ' 19 | -------------------------------------------------------------------------------- /ruby/codeabbey/020_collatz_sequence.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ').map { |e| e.to_i } 5 | x.map! do |e| 6 | chain = [e] 7 | until chain.include? 1 8 | e = e.even? ? e / 2 : e * 3 + 1 9 | chain << e 10 | end 11 | chain.size - 1 12 | end 13 | puts x.join ' ' 14 | -------------------------------------------------------------------------------- /ruby/codeabbey/022_fibonacci_seq.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.to_i } 5 | x.map! do |e| 6 | if e == 0 7 | 0 8 | elsif e == 1 9 | 1 10 | else 11 | step, num, prev_num = 0, 0, 1 12 | until num == e 13 | step += 1 14 | num, prev_num = prev_num + num, num 15 | end 16 | step 17 | end 18 | end 19 | puts x.join ' ' 20 | -------------------------------------------------------------------------------- /ruby/codeabbey/023_greatest_common_denom.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | def g_c_d(a, b) 5 | x = [a, b].min 6 | x -= 1 until a % x == 0 && b % x == 0 7 | x 8 | end 9 | 10 | def l_c_m(a, b) 11 | x = [a, b].max 12 | x += 1 until x % a == 0 && x % b == 0 13 | x 14 | end 15 | 16 | x = ARGF.file.read.split("\n").map { |e| e.split ' ' } 17 | x.shift 18 | x.map! do |e| 19 | e.map! { |r| r.to_i } 20 | "(#{g_c_d(e[0], e[1])} #{l_c_m(e[0], e[1])})" 21 | end 22 | puts x.join ' ' 23 | -------------------------------------------------------------------------------- /ruby/codeabbey/024_sort_with_indexes.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ') 5 | x.map!.with_index { |e, i| [i + 1, e.to_i] } 6 | x.sort! { |e, r| e[1] <=> r[1] } 7 | x.map! { |e| e[0] } 8 | puts x.join ' ' 9 | -------------------------------------------------------------------------------- /ruby/codeabbey/025_joe_problem.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | args = ARGF.file.read.split(' ').map { |e| e.to_i } 5 | grp = (1..args[0]).to_a 6 | until grp.size == 1 7 | grp.rotate! args[1] - 1 8 | grp.delete_at 0 9 | end 10 | puts grp[0] 11 | -------------------------------------------------------------------------------- /ruby/codeabbey/026_smoothing_weather.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1].split(' ').map { |e| e.to_f } 5 | y = [] 6 | x.each.with_index do |e, i| 7 | if i == 0 || i == x.size - 1 8 | y << e 9 | else 10 | y << (x[i - 1] + e + x[i + 1]) / 3 11 | end 12 | end 13 | puts y.join ' ' 14 | -------------------------------------------------------------------------------- /ruby/codeabbey/028_bubble_in_array.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split(' ')[0..-2].map { |e| e.to_i } 5 | swaps = 0 6 | x.size.times do |i| 7 | next if i == x.size - 1 8 | if x[i] > x[i + 1] 9 | x[i], x[i + 1] = x[i + 1], x[i] 10 | swaps += 1 11 | end 12 | end 13 | checksum = x.reduce(0) { |a, e| ((a + e) * 113) % 10_000_007 } 14 | puts "#{swaps} #{checksum}" 15 | -------------------------------------------------------------------------------- /ruby/codeabbey/031_arithmetic_prog.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.split ' ' } 5 | x.map! do |e| 6 | e.map! { |r| r.to_i } 7 | start, step_size, steps = e[0], e[1], e[2] 8 | final = start + step_size * (steps - 1) 9 | (steps * (start + final)) / 2 10 | end 11 | puts x.join ' ' 12 | -------------------------------------------------------------------------------- /ruby/codeabbey/032_triangles.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.split ' ' } 5 | x.map! do |e| 6 | e.map! { |r| r.to_i }.sort! 7 | e[0] + e[1] > e[2] ? 1 : 0 8 | end 9 | puts x.join ' ' 10 | -------------------------------------------------------------------------------- /ruby/codeabbey/033_herons_square_root.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.split } 5 | x.map! do |e| 6 | e.map! { |r| r.to_i } 7 | root = 1 8 | e[1].times do 9 | division_result = e[0].to_f / root 10 | root = (root + division_result) / 2 11 | end 12 | root 13 | end 14 | puts x.join ' ' 15 | -------------------------------------------------------------------------------- /ruby/codeabbey/035_two_printers.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.split ' ' } 5 | x.map! do |e| 6 | e.map! { |r| r.to_i } 7 | pages0 = ((e[1] * e[2]).to_f / (e[0] + e[1])).ceil 8 | pages1 = ((e[0] * e[2]).to_f / (e[0] + e[1])).ceil 9 | [pages0 * e[0], pages1 * e[1]].min 10 | end 11 | puts x.join ' ' 12 | -------------------------------------------------------------------------------- /ruby/codeabbey/036_reverse_a_string.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read 5 | y = '' 6 | (x.size - 1).downto 0 do |e| 7 | y << x[e] 8 | end 9 | puts y 10 | -------------------------------------------------------------------------------- /ruby/codeabbey/037_rotate_string.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.split ' ' } 5 | x.map! do |e| 6 | e[1].split('').rotate(e[0].to_i).join '' 7 | end 8 | puts x.join ' ' 9 | -------------------------------------------------------------------------------- /ruby/codeabbey/038_savings_calc.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding: utf-8 3 | 4 | x = ARGF.file.read.split("\n")[1..-1].map { |e| e.split ' ' } 5 | x.map! do |e| 6 | e.map! { |r| r.to_i } 7 | e[0], e[1], e[2] = e[0] * 100, e[1] * 100, (1 + e[2] / 100.0) 8 | years = 0 9 | until e[0] > e[1] 10 | years += 1 11 | e[0] = (e[0] * e[2]).floor 12 | end 13 | years 14 | end 15 | puts x.join ' ' 16 | -------------------------------------------------------------------------------- /ruby/james_erb/main.rb: -------------------------------------------------------------------------------- 1 | require 'erb' 2 | 3 | name = 'Tim' 4 | years = 6 5 | company = "Bob's Burgers" 6 | 7 | document = 8 | "This is the CV of <%= name %> 9 | 10 | They worked for <%= years %> years at <%= company %>" 11 | 12 | puts ERB.new(document).result 13 | -------------------------------------------------------------------------------- /ruby/katas/anagram.rb: -------------------------------------------------------------------------------- 1 | # http://codekata.com/kata/kata06-anagrams/ 2 | 3 | words = File.readlines('wordlist.txt') 4 | 5 | groups = {} 6 | 7 | words.each do |word| 8 | word = word.chomp 9 | begin 10 | key = word.downcase.split('').sort.join('') 11 | groups[key] = groups.fetch(key, []) << word 12 | rescue 13 | nil 14 | end 15 | end 16 | 17 | File.open('out.txt', 'w') do |f| 18 | groups.values.each do |e| 19 | f.puts e.join(' ') 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /ruby/rspec/tutsplus/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rspec' 4 | -------------------------------------------------------------------------------- /ruby/rspec/tutsplus/README.md: -------------------------------------------------------------------------------- 1 | http://code.tutsplus.com/tutorials/ruby-for-newbies-testing-with-rspec--net-21297 2 | -------------------------------------------------------------------------------- /ruby/rspec/tutsplus/book.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | class Book 4 | attr_reader :title, :author, :category 5 | 6 | def initialize(title, author, category) 7 | @title = title 8 | @author = author 9 | @category = category 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /ruby/rspec/tutsplus/library.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | class Library 4 | def initialize(books = []) 5 | @books = books 6 | end 7 | 8 | def books 9 | @books.length 10 | end 11 | 12 | def get_books_in_category(category) 13 | @books.select { |book| book.category == category } 14 | end 15 | 16 | def get_book(title) 17 | @books.find { |book| book.title == title } 18 | end 19 | 20 | def add_book(book) 21 | @books << book 22 | self 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /ruby/rspec/tutsplus/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative '../library' 4 | require_relative '../book' 5 | -------------------------------------------------------------------------------- /ruby/sonic-pi/01-bleeps.rb: -------------------------------------------------------------------------------- 1 | notes = ( 2 | scale(:c2, :minor_pentatonic, num_octaves: 5) + 3 | scale(:c2, :minor_pentatonic, num_octaves: 5).reverse 4 | ) 5 | 6 | 2.times do 7 | with_fx :echo do 8 | use_synth :sine 9 | play_pattern_timed( 10 | notes, 11 | 0.125, 12 | release: 0.1 13 | ) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /_yardoc/ 4 | /coverage/ 5 | /doc/ 6 | /pkg/ 7 | /spec/reports/ 8 | /tmp/ 9 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: ruby 4 | cache: bundler 5 | rvm: 6 | - 2.3.7 7 | before_install: gem install bundler -v 2.0.2 8 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Specify your gem's dependencies in ice_cream.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rake/testtask" 3 | 4 | Rake::TestTask.new(:test) do |t| 5 | t.libs << "test" 6 | t.libs << "lib" 7 | t.test_files = FileList["test/**/*_test.rb"] 8 | end 9 | 10 | task :default => :test 11 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "ice_cream" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start(__FILE__) 15 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/lib/ice_cream/version.rb: -------------------------------------------------------------------------------- 1 | # typed: strong 2 | module IceCream 3 | VERSION = "0.1.0" 4 | end 5 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/sorbet/config: -------------------------------------------------------------------------------- 1 | --dir 2 | . 3 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/test/ice_cream_test.rb: -------------------------------------------------------------------------------- 1 | # typed: true 2 | require 'test_helper' 3 | 4 | class IceCreamTest < Minitest::Test 5 | def test_that_it_has_a_version_number 6 | refute_nil ::IceCream::VERSION 7 | end 8 | 9 | def test_it_does_something_useful 10 | assert false 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # typed: strict 2 | $LOAD_PATH.unshift File.expand_path("../lib", __dir__) 3 | require "ice_cream" 4 | 5 | require "minitest/autorun" 6 | -------------------------------------------------------------------------------- /ruby/sorbet/ice_cream/watch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | watchexec -e rb "echo;echo;echo;bundle exec srb tc" 4 | -------------------------------------------------------------------------------- /rust/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | 3 | *.dll 4 | *.o 5 | *.rlib 6 | *.so 7 | 8 | /target/ 9 | **/target/ 10 | -------------------------------------------------------------------------------- /rust/README.md: -------------------------------------------------------------------------------- 1 | # Learning Rust 2 | 3 | http://www.rust-lang.org/ 4 | -------------------------------------------------------------------------------- /rust/actix-web-app/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "acty" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | actix-web = "1.0.0-rc" 9 | -------------------------------------------------------------------------------- /rust/book_take_one/dining_philosophers/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "dining_philosophers" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /rust/book_take_one/dining_philosophers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dining_philosophers" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | -------------------------------------------------------------------------------- /rust/book_take_one/guessing_game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "guessing_game" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | 6 | [dependencies] 7 | 8 | rand="0.3.0" 9 | -------------------------------------------------------------------------------- /rust/book_take_two/guessing_game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "guessing_game" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | 6 | [dependencies] 7 | rand="0.3.0" 8 | -------------------------------------------------------------------------------- /rust/by-example/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "by_example" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /rust/by-example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "by_example" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | -------------------------------------------------------------------------------- /rust/by-example/src/hello_world/formatted_print/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod debug; 2 | pub mod display; 3 | pub mod display_list; 4 | pub mod formatting; 5 | -------------------------------------------------------------------------------- /rust/by-example/src/hello_world/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod formatted_print; 2 | -------------------------------------------------------------------------------- /rust/by-example/src/main.rs: -------------------------------------------------------------------------------- 1 | mod hello_world; 2 | 3 | fn main() { 4 | // hello_world::formatted_print::debug::run(); 5 | // hello_world::formatted_print::display_list::run(); 6 | hello_world::formatted_print::formatting::run(); 7 | } 8 | -------------------------------------------------------------------------------- /rust/error_trait/errorz/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "errorz" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /rust/error_trait/errorz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "errorz" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/ffi-rc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ffi-rc" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/gotham-hello/.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | README.md 3 | doc 4 | docs 5 | target 6 | test 7 | -------------------------------------------------------------------------------- /rust/gotham-hello/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | -------------------------------------------------------------------------------- /rust/gotham-hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "happylabs-api" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | # Web server 9 | gotham = "0.4" 10 | gotham_derive = "0.4" 11 | hyper = "0.12" 12 | 13 | # (de)serialization magic 14 | serde = "1" 15 | serde_derive = "1" 16 | 17 | # mime types 18 | mime = "0.3" 19 | 20 | # Tracing, metrics and logging library 21 | tracing = "0.1" 22 | tracing-subscriber = "0.1" 23 | -------------------------------------------------------------------------------- /rust/gotham-hello/img/happylabs-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/rust/gotham-hello/img/happylabs-logo.png -------------------------------------------------------------------------------- /rust/gotham-hello/src/web/health_check.rs: -------------------------------------------------------------------------------- 1 | use gotham::{handler::IntoResponse, state::State}; 2 | 3 | pub fn get(state: State) -> (State, impl IntoResponse) { 4 | (state, "Still alive!") 5 | } 6 | -------------------------------------------------------------------------------- /rust/gotham-hello/src/web/not_found.rs: -------------------------------------------------------------------------------- 1 | use gotham::{handler::IntoResponse, state::State}; 2 | use hyper::{Response, StatusCode}; 3 | 4 | pub fn handle(state: State) -> (State, impl IntoResponse) { 5 | let resp = Response::builder() 6 | .status(StatusCode::NOT_FOUND) 7 | .body("There's nothing here...".into()) 8 | .unwrap(); 9 | (state, resp) 10 | } 11 | -------------------------------------------------------------------------------- /rust/hello_serde/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_serde" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | 6 | [dependencies] 7 | serde = "1.0" 8 | serde_derive = "1.0" 9 | toml = "0.4" 10 | -------------------------------------------------------------------------------- /rust/lisp-calc/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "lisp_calc" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /rust/lisp-calc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lisp_calc" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | 6 | [lib] 7 | name = "lib" 8 | path = "src/lib.rs" 9 | 10 | [[bin]] 11 | name = "lisp_calc" 12 | path = "src/main.rs" 13 | 14 | [dependencies] 15 | -------------------------------------------------------------------------------- /rust/quickchecker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "quickchecker" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | quickcheck = "0.8" 9 | quickcheck_macros = "0.8" 10 | -------------------------------------------------------------------------------- /rust/salsa_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "salsa_test" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | salsa = { version = "0.14.1", git = "https://github.com/salsa-rs/salsa", rev = "2c44b6e" } 11 | -------------------------------------------------------------------------------- /rust/staticly-linked-scratch-docker-image/.dockerignore: -------------------------------------------------------------------------------- 1 | test 2 | target 3 | Dockerfile 4 | -------------------------------------------------------------------------------- /rust/staticly-linked-scratch-docker-image/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "server-one" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | actix-web = "1.0.0-beta.4" 9 | env_logger = "*" 10 | -------------------------------------------------------------------------------- /rust/too-many-lists/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "too-many-lists" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /rust/too-many-lists/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "too-many-lists" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | -------------------------------------------------------------------------------- /rust/too-many-lists/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod first; 2 | pub mod second; 3 | -------------------------------------------------------------------------------- /rust/too-many-lists/src/second.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lpil/learning/df29f9c5a47344be544b86bf872a01e1a568a81f/rust/too-many-lists/src/second.rs -------------------------------------------------------------------------------- /rust/warp-web-app/.dockerignore: -------------------------------------------------------------------------------- 1 | test 2 | target 3 | Dockerfile 4 | -------------------------------------------------------------------------------- /rust/warp-web-app/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "berry" 3 | version = "0.1.0" 4 | authors = ["Louis Pilfold "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | juniper = "0.12" 9 | juniper_warp = "0.3" 10 | log = "0.4" 11 | pretty_env_logger = "0.3" 12 | warp = "0.1.15" 13 | askama = "0.8" 14 | chrono = "0.4" 15 | serde = { version = "1.0", features = ["derive"] } 16 | -------------------------------------------------------------------------------- /rust/warp-web-app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ekidd/rust-musl-builder:1.34.2 as build 2 | 3 | # Build 4 | COPY . . 5 | RUN cargo build --release 6 | 7 | # Create user 8 | FROM alpine:latest as alpine 9 | RUN addgroup -S appgroup && adduser -S appuser -G appgroup 10 | 11 | # Release 12 | # FROM alpine:latest 13 | FROM scratch 14 | COPY --from=build /home/rust/src/target/x86_64-unknown-linux-musl/release/berry . 15 | COPY --from=alpine /etc/passwd /etc/passwd 16 | USER appuser 17 | ENTRYPOINT ["./berry"] 18 | -------------------------------------------------------------------------------- /rust/warp-web-app/templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Berry 7 | 8 | 9 |
10 | {% block content %}{% endblock %} 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /scala/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.log 3 | target 4 | -------------------------------------------------------------------------------- /scala/README.md: -------------------------------------------------------------------------------- 1 | # Learning Scala 2 | -------------------------------------------------------------------------------- /scala/hello-world/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre-alpine 2 | MAINTAINER Louis Pilfold 3 | 4 | ADD ./target/hello-world.jar . 5 | 6 | RUN adduser -S app 7 | USER app 8 | 9 | CMD ["java", "-jar", "./hello-world.jar"] 10 | -------------------------------------------------------------------------------- /scala/hello-world/README.md: -------------------------------------------------------------------------------- 1 | # Hello, World! 2 | 3 | ```sh 4 | # Compile project and deps to .jar file 5 | sbt assembly 6 | ``` 7 | -------------------------------------------------------------------------------- /scala/hello-world/project/assembly.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4") 2 | -------------------------------------------------------------------------------- /scala/hello-world/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.13 2 | -------------------------------------------------------------------------------- /scala/hello-world/src/main/scala/Main.scala: -------------------------------------------------------------------------------- 1 | object Main extends App { 2 | println("Why hello there!") 3 | } 4 | -------------------------------------------------------------------------------- /sql/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | -------------------------------------------------------------------------------- /sql/README.md: -------------------------------------------------------------------------------- 1 | # Learning SQL 2 | -------------------------------------------------------------------------------- /sql/the-hard-way/README.md: -------------------------------------------------------------------------------- 1 | # Learn SQL the Hard Way 2 | 3 | sqlite3 ex1.db < ex1.sql 4 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex01.sql: -------------------------------------------------------------------------------- 1 | create TABLE person ( 2 | id INTEGER PRIMARY KEY, 3 | first_name TEXT, 4 | last_name TEXT, 5 | age INTEGER 6 | ); 7 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex02.sql: -------------------------------------------------------------------------------- 1 | create TABLE person ( 2 | id INTEGER PRIMARY KEY, 3 | first_name TEXT, 4 | last_name TEXT, 5 | age INTEGER 6 | ); 7 | 8 | create TABLE pet ( 9 | id INTEGER PRIMARY KEY, 10 | name TEXT, 11 | species TEXT, 12 | age INTEGER, 13 | dead INTEGER 14 | ); 15 | 16 | create TABLE person_pet ( 17 | person_id INTEGER, 18 | pet_id INTEGER 19 | ); 20 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex03.sql: -------------------------------------------------------------------------------- 1 | /* Run on db 2 */ 2 | INSERT INTO person (id, first_name, last_name, age) 3 | VALUES (0, "Zed", "Shaw", 37); 4 | 5 | INSERT INTO pet (id, name, species, age, dead) 6 | VALUES (0, "Fluffy", "Unicorn", 1000, 0); 7 | 8 | INSERT INTO pet VALUES (1, "Gigantor", "Robot", 1, 1); 9 | INSERT INTO pet VALUES (2, "Dinbar", "Hopalong", 11, 0); 10 | INSERT INTO pet VALUES (3, "Foop", "Parrot", 23, 0); 11 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex04.sql: -------------------------------------------------------------------------------- 1 | /* Run on db 2 */ 2 | INSERT INTO person_pet (person_id, pet_id) values (0, 0); 3 | INSERT INTO person_pet values (0, 1); 4 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex05.sql: -------------------------------------------------------------------------------- 1 | /* run on db 2 */ 2 | 3 | SELECT * FROM person; 4 | 5 | SELECT name, age FROM pet; 6 | 7 | SELECT first_name, age FROM person WHERE first_name != "Zed"; 8 | 9 | SELECT name, age FROM pet WHERE age > 10; 10 | 11 | SELECT name, age FROM pet WHERE age > 10 AND age < 2000; 12 | 13 | SELECT name, age FROM pet 14 | WHERE age > 10 15 | AND age < 2000 16 | OR name = "Gigantor"; 17 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex06.sql: -------------------------------------------------------------------------------- 1 | /* run on db 2 */ 2 | 3 | SELECT pet.id, pet.name, pet.age, pet.dead 4 | FROM pet, person_pet, person 5 | WHERE pet.id = person_pet.pet_id 6 | AND person_pet.person_id = person.id 7 | AND person.first_name = "Zed"; 8 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex07.sql: -------------------------------------------------------------------------------- 1 | /* run on db2 */ 2 | 3 | /* make sure there's dead pets */ 4 | SELECT name, age FROM pet WHERE dead = 1; 5 | 6 | /* aww poor robot */ 7 | DELETE FROM pet WHERE dead = 1; 8 | 9 | /* make sure the robot is gone */ 10 | SELECT * FROM pet; 11 | 12 | /* let's resurrect the robot */ 13 | INSERT INTO pet VALUES (1, "Gigantor", "Robot", 1, 0); 14 | 15 | /* the robot LIVES! */ 16 | SELECT * FROM pet; 17 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex09.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO pet (id, name, species, age, dead) 2 | VALUES (0, "Fluffy", "Unicorn", 1000, 0); 3 | 4 | SELECT * FROM person; 5 | SELECT * FROM pet; 6 | 7 | UPDATE person SET first_name = "Guy" 8 | WHERE first_name = "Zed"; 9 | 10 | UPDATE pet SET name = "Fancy Pants" 11 | WHERE id = 0; 12 | 13 | SELECT * FROM person; 14 | SELECT * FROM pet; 15 | 16 | /* Change it back to Zed */ 17 | UPDATE person SET first_name = "Zed" 18 | WHERE first_name = "Guy"; 19 | -------------------------------------------------------------------------------- /sql/the-hard-way/ex10.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO person_pet (person_id, pet_id) values (0, 0); 2 | 3 | SELECT * FROM pet; 4 | 5 | UPDATE pet SET name = "Zed's Pet" WHERE id IN ( 6 | SELECT pet_id 7 | FROM pet, person_pet, person 8 | 9 | WHERE person.id = person_pet.person_id 10 | AND pet.id = person_pet.pet_id 11 | AND person.first_name = "Zed" 12 | ); 13 | 14 | SELECT * FROM pet; 15 | -------------------------------------------------------------------------------- /supercollider/.gitignore: -------------------------------------------------------------------------------- 1 | *.aiff 2 | *.flac 3 | *.ogg 4 | *.wav 5 | -------------------------------------------------------------------------------- /supercollider/gentle-intro/README.md: -------------------------------------------------------------------------------- 1 | # [A Gentle Introduction to Supercollider](https://github.com/brunoruviaro/A_Gentle_Introduction_To_SuperCollider) 2 | 3 | Thanks Bruno Ruviaro! 4 | -------------------------------------------------------------------------------- /supercollider/nick-collins-tut/README.md: -------------------------------------------------------------------------------- 1 | Nick Collins' SuperCollider Tutorial 2 | ==================================== 3 | 4 | http://composerprogrammer.com/teaching/supercollider/sctutorial/tutorial.html 5 | -------------------------------------------------------------------------------- /supercollider/nick-collins-tut/vendor/Technicalities/writingclassesexamples/NastySynth.sc: -------------------------------------------------------------------------------- 1 | NastySynth { 2 | classvar <>wackiness=200; 3 | 4 | *ar { arg wackymult=1; 5 | ^CombN.ar( 6 | SinOsc.ar( 7 | LFNoise0.ar(9, wackymult*wackiness, MouseY.kr(100,400)), 8 | 7, 9 | MouseX.kr(0.0,0.75) 10 | ) % 0.3, 11 | 0.3, 12 | 0.3, 13 | 5 14 | ) 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /supercollider/nick-collins-tut/vendor/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #303070; 3 | font-style: normal; 4 | font-weight: normal; 5 | font-family: Monaco,Arial,Helvetica,sans-serif; 6 | text-decoration: none; 7 | font-size: 10px; 8 | } 9 | 10 | h3 { 11 | color: #000000; 12 | font-size: 17px; 13 | } 14 | -------------------------------------------------------------------------------- /supercollider/syntorial/README.md: -------------------------------------------------------------------------------- 1 | # Making Stuff from Syntorial 2 | -------------------------------------------------------------------------------- /supercollider/syntorial/adsr.scd: -------------------------------------------------------------------------------- 1 | TempoClock.default.tempo = 90/60; 2 | 3 | ( 4 | SynthDef(\beep, { |out, preamp = 1, amp = 1| 5 | var adsr = EnvGen.kr(Env.adsr(0.4, 0.7, 0, 0), doneAction: Done.freeSelf); 6 | var noise = SinOsc.ar(freq: 440, mul: adsr); 7 | Out.ar(out, noise ! 2); 8 | }).add; 9 | ) 10 | 11 | ( 12 | k = Pbind(\instrument, \beep, \delta, 1).play(quant: 1); 13 | ) 14 | 15 | k.stop; 16 | -------------------------------------------------------------------------------- /supercollider/syntorial/hello_world.scd: -------------------------------------------------------------------------------- 1 | // 2 | // sclang ./hello_world.scd 3 | // 4 | 5 | "Hello, world!".postln; 6 | 0.exit; 7 | -------------------------------------------------------------------------------- /supercollider/the-supercollider-book/1.1-figure.scd: -------------------------------------------------------------------------------- 1 | "Hello mum"; 2 | 3 | s.stop; 4 | s.boot; 5 | 6 | ( 7 | { 8 | var sines = 5; 9 | var speed = 6; 10 | var f = { |x| 11 | var osc = SinOsc.ar( 12 | freq: (x + 1) * 100, 13 | mul: LFNoise1.kr(speed) + Line.kr(start: 1, end: -1, dur: 30), 14 | ); 15 | Pan2.ar(in: osc, pos: rand2(1.0)) 16 | }; 17 | Mix.fill(sines, f) / sines 18 | }.play; 19 | ) 20 | -------------------------------------------------------------------------------- /supercollider/the-supercollider-book/1.2-seed.scd: -------------------------------------------------------------------------------- 1 | // We can set the thread random seed 2 | thisThread.randSeed = 666; 3 | 4 | // Construct an array by calling this function 10 times 5 | { rand(10.0) }.dup(10); 6 | -------------------------------------------------------------------------------- /supercollider/the-supercollider-book/1.3-figure.scd: -------------------------------------------------------------------------------- 1 | ( 2 | { 3 | var saw = LFSaw.ar(freq: [15, 15.123], iphase: 0, mul: 3, add: 40); 4 | var midiNumber = LFNoise1.ar(freq: 3, mul: 24, add: saw).midicps; 5 | var sine = SinOsc.ar(freq: midiNumber, phase: 0, mul: 0.4); 6 | CombN.ar(sine, maxdelaytime: 3, delaytime: 0.3, decaytime: 1.3) 7 | }.play; 8 | ) 9 | -------------------------------------------------------------------------------- /supercollider/the-supercollider-book/1.6-multichannel-expansion.scd: -------------------------------------------------------------------------------- 1 | ( 2 | { 3 | // Multichannel expansion means that the UGen is expanded into multiple 4 | // channels, one per item in the array. 5 | var freqs = [5, 10, 2, 25, 1, 9, 2]; 6 | var noise = LFNoise0.kr(freq: freqs, mul: 12, add: 14); 7 | Blip.ar(freq: 25, numharm: noise, mul: 0.3) 8 | }.play 9 | ) -------------------------------------------------------------------------------- /supercollider/the-supercollider-book/1.7-figure-1.4.scd: -------------------------------------------------------------------------------- 1 | ( 2 | { 3 | Blip.ar( 4 | freq: TRand.kr(lo: 100, hi: 1000, trig: Impulse.kr(Line.kr(1, 20, 60))), 5 | numharm: TRand.kr(lo: 1, hi: 10, trig: Impulse.kr(Line.kr(1, 20, 60))), 6 | mul: Linen.kr( 7 | gate: Impulse.kr(Line.kr(1, 20, 60)), 8 | attackTime: 0, 9 | susLevel: 0.5, 10 | releaseTime: 1 / Line.kr(1, 20, 60), 11 | ) 12 | ).dup(2) 13 | }.play 14 | ) 15 | -------------------------------------------------------------------------------- /types/README.md: -------------------------------------------------------------------------------- 1 | # Learning Types 2 | -------------------------------------------------------------------------------- /types/algodub/.gitignore: -------------------------------------------------------------------------------- 1 | .rebar3 2 | _* 3 | .eunit 4 | *.o 5 | *.beam 6 | *.plt 7 | *.swp 8 | *.swo 9 | .erlang.cookie 10 | ebin 11 | log 12 | erl_crash.dump 13 | .rebar 14 | logs 15 | _build 16 | .idea 17 | *.iml 18 | rebar3.crashdump 19 | src/algodub_tokenizer.erl 20 | src/algodub_parser.erl 21 | -------------------------------------------------------------------------------- /types/algodub/README.md: -------------------------------------------------------------------------------- 1 | # algodub 2 | 3 | Algorithm W, adapted from [Tom Primožič's OCaml example](https://github.com/tomprimozic/type-systems/tree/master/algorithm_w) 4 | -------------------------------------------------------------------------------- /types/algodub/rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [debug_info]}. 2 | {eunit_tests, [{dir, "test"}, {dir, "src"}]}. 3 | {deps, []}. 4 | 5 | {profiles, [ 6 | {test, [ 7 | {deps, [unite]}, 8 | {eunit_opts, [no_tty, {report, {unite_compact, []}}]} 9 | ]} 10 | ]}. 11 | -------------------------------------------------------------------------------- /types/algodub/rebar.lock: -------------------------------------------------------------------------------- 1 | []. 2 | -------------------------------------------------------------------------------- /types/algodub/src/algodub.app.src: -------------------------------------------------------------------------------- 1 | {application, algodub, 2 | [{description, "An OTP library"}, 3 | {vsn, "0.1.0"}, 4 | {registered, []}, 5 | {applications, 6 | [kernel, 7 | stdlib 8 | ]}, 9 | {env,[]}, 10 | {modules, []}, 11 | 12 | {maintainers, []}, 13 | {licenses, ["Apache 2.0"]}, 14 | {links, []} 15 | ]}. 16 | -------------------------------------------------------------------------------- /viml/hard-way/01.vim: -------------------------------------------------------------------------------- 1 | " Print a message 2 | echo "Hello, world!" 3 | 4 | " Print a message, storing it in messages 5 | echom "Hello, world!" 6 | 7 | " show message history 8 | messages 9 | -------------------------------------------------------------------------------- /viml/hard-way/02.vim: -------------------------------------------------------------------------------- 1 | """"""""""""""""""""" 2 | " Setting options " 3 | """"""""""""""""""""" 4 | 5 | " Boolean options can be on or off. 6 | set number 7 | set nonumber 8 | 9 | " We can toggle them 10 | set number! 11 | 12 | " We can check their status 13 | set number? 14 | 15 | " Options can take values 16 | set numberwidth=10 17 | set numberwidth=4 18 | set numberwidth? 19 | 20 | " Multiple options can be set at once 21 | set number numberwidth=6 22 | -------------------------------------------------------------------------------- /viml/hard-way/03.vim: -------------------------------------------------------------------------------- 1 | """"""""""""""""""" 2 | " Basic mapping " 3 | """"""""""""""""""" 4 | 5 | " We can bind keys to actions 6 | map - dd 7 | 8 | " Trailing comments are not valid here! 9 | map viw " this comment isn't a comment! 10 | -------------------------------------------------------------------------------- /viml/hard-way/04.vim: -------------------------------------------------------------------------------- 1 | """"""""""""""""""" 2 | " Modal mapping " 3 | """"""""""""""""""" 4 | 5 | " We can have different mappings for different modes 6 | 7 | " Normal 8 | nmap \ dd 9 | vmap \ d 10 | imap viwU 11 | -------------------------------------------------------------------------------- /viml/hard-way/05.vim: -------------------------------------------------------------------------------- 1 | """"""""""""""""""""" 2 | " String mappings " 3 | """"""""""""""""""""" 4 | 5 | " We can unmap things 6 | nunmap - 7 | 8 | " Strict mappings prevent the binding from being called by other bindings 9 | nnoremap x dd 10 | 11 | " *Always* use these. 12 | -------------------------------------------------------------------------------- /viml/hard-way/06.vim: -------------------------------------------------------------------------------- 1 | """"""""""""" 2 | " Leaders " 3 | """"""""""""" 4 | 5 | " There are leaders 6 | let leader = "-" 7 | 8 | " Leaders can be made to only apply to certain filetypes 9 | let maplocalleader = "\\" 10 | 11 | " I don't know why this is useful. 12 | -------------------------------------------------------------------------------- /viml/hard-way/07.vim: -------------------------------------------------------------------------------- 1 | """"""""""""""""""" 2 | " Editing vimrc " 3 | """"""""""""""""""" 4 | 5 | " Open vimrc to edit 6 | nnoremap ev :e $MYVIMRC 7 | " Reload vimrc 8 | nnoremap sv :source $MYVIMRC 9 | -------------------------------------------------------------------------------- /viml/hard-way/20.vim: -------------------------------------------------------------------------------- 1 | """""""""""""""""""""" 2 | " Variable scoping " 3 | """""""""""""""""""""" 4 | 5 | " Variables that start with a letter and then a color (i.e. b:foo) 6 | " are scoped varibles. 7 | 8 | " This variable is scoped to the current buffer 9 | let b:hello = "world" 10 | -------------------------------------------------------------------------------- /viml/hard-way/README.md: -------------------------------------------------------------------------------- 1 | http://learnvimscriptthehardway.stevelosh.com/ 2 | --------------------------------------------------------------------------------