This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from subprocess import check_call, CalledProcessError | |
from tempfile import NamedTemporaryFile | |
from dpms import DPMS | |
from mss import mss | |
from PIL import Image, ImageFilter | |
GAUSSIAN_BLUR_RADIUS = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Script to update now-dns.com IPv4/v6 address | |
# Based on https://now-dns.com/client/dynupdate.pl | |
# Depends on python3 and python3-requests installed in the system | |
import os | |
import re | |
import requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# i3lock-xkcd.py | |
# Downloads and show random xkcd comic as i3lock background | |
import os | |
import sys | |
from subprocess import run | |
from tempfile import NamedTemporaryFile | |
from textwrap import wrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# rotate_desktop.sh | |
# | |
# Rotates modern Linux desktop screen and input devices to match. Handy for | |
# convertible notebooks. Call this script from panel launchers, keyboard | |
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.). | |
# | |
# Using transformation matrix bits taken from: | |
# https://wiki.ubuntu.com/X/InputCoordinateTransformation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Auto-upgrade Arch Linux or get e-mail in case of failure. |