Skip to content

Instantly share code, notes, and snippets.

View thiagokokada's full-sized avatar

Thiago Kenji Okada thiagokokada

View GitHub Profile
defmodule Calculator do
def repl(acc \\ 0.0) do
IO.puts("accumulator> #{acc}")
[command, value] = IO.gets("operation> ") |> String.trim() |> String.split()
{value, _} = Float.parse(value) # Convert a string to its float representation
acc |> run_command(command, value) |> repl()
end
defp run_command(acc, command, value) do
case command do
defmodule Calculator do
def repl(acc \\ 0.0, io \\ IO) do
interpret(acc, io) |> repl(io)
end
def interpret(acc, io) do
io.puts("accumulator> #{acc}")
[command, value] = io.gets("operation> ") |> String.trim() |> String.split()
{value, _} = Float.parse(value) # Convert a string to its float representation
run_command(acc, command, value)
defmodule CalculatorTest do
use ExUnit.Case
import ExUnit.CaptureIO
doctest Calculator
describe "+ 1.0" do
defmodule FakeIO do
defdelegate puts(message), to: IO
def gets("operation> "), do: "+ 1.0"
describe "+ 1.0 * 5" do
defmodule FakeIO do
defdelegate puts(message), to: IO
def gets("operation> "), do: "+ 1.0\n"
def gets("operation> "), do: "* 5\n"
end
test "accumulator should be 1.0" do
run = fn -> Calculator.repl(0.0, FakeIO) end
assert capture_io(run) =~ "5.0"
defmodule Calculator do
def repl(acc \\ 0.0, i \\ 0, io \\ IO) do
interpret(acc, i + 1, io) |> repl(i + 1, io)
end
def interpret(acc, i, io) do
io.puts("accumulator> #{acc}")
[command, value] = io.gets("operation(#{i})> ") |> String.trim() |> String.split()
{value, _} = Float.parse(value) # Convert a string to its float representation
run_command(acc, command, value)
describe "+ 1.0 * 5" do
defmodule FakeIO do
defdelegate puts(message), to: IO
def gets("operation(1)> "), do: "+ 1.0"
def gets("operation(2)> "), do: "* 5"
def gets(_), do: "= 0.0"
end
test "accumulator should be 5.0" do
run = fn ->
@thiagokokada
thiagokokada / mons.sh
Created December 31, 2018 17:13
Inlined version of mons
#!/bin/sh
###############################################################################
# ABOUT #
###############################################################################
# This is a modified version of mons v0.8.2 [1] with needed #
# liblist.sh v1.1 [2] functions included inline. #
# [1]: https://github.com/Ventto/mons/blob/v0.8.2/mons #
# [2]: https://github.com/Ventto/libshlist/blob/v1.1/liblist.sh #
###############################################################################

Keybase proof

I hereby claim:

  • I am thiagokokada on github.
  • I am thiagokokada (https://keybase.io/thiagokokada) on keybase.
  • I have a public key whose fingerprint is B291 6223 6D5D D544 24AB 0831 1CA3 07B3 74C1 BD81

To claim this, I am signing this object:

@thiagokokada
thiagokokada / resume.json
Last active March 21, 2024 10:47
resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Thiago Kenji Okada",
"label": "Senior Software Engineer",
"picture": "https://avatars2.githubusercontent.com/u/844343?s=460&u=b0a39e7e5e7079e199a81ba9bcce46648f1392af&v=4",
"email": "[email protected]",
"summary": "I am a Full Stack Senior Software Engineer with experience developing scalable applications in languages like Kotlin, Clojure and Ruby, frontend development with JavaScript and mobile development with Flutter. I also have experience in DevOps, mainly in AWS environment, working with tools like Ansible and Terraform and also managing multiple Kubernetes clusters. I have business experience in payment systems and financial services, and a computer science degree focused in distributed systems and cloud computing.",
"location": {
"city": "Dublin",
@thiagokokada
thiagokokada / low-latency-kvm.md
Last active July 7, 2024 14:48
Low-latency KVM

Low-latency guests in KVM

Summary

Obtaining a low-latency guests in KVM (i.e.: low DPC latency for Windows guests) can be difficult. Without it, you may hear cracks/pops in audio or freezes in the VM, so they can be very annoying, specially for gaming dedicated VMs.

This document summarizes some of my findings on this subject.

Configuring KVM for real-time workloads