This file contains 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 LineCircle do | |
@type point() :: {number, number} | |
@spec intersection([point()], point(), number()) :: [point()] | nil | |
def intersection([{x1, y1}, {x2, y2}], {cx, cy}, r) when is_number(r) do | |
dx = x2 - x1 | |
dy = y2 - y1 | |
dr = :math.sqrt(dx * dx + dy * dy) | |
matrix = x1 * y2 - x2 * y1 | |
discriminant = square(r) * square(dr) - square(matrix) |
This file contains 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 LineCircleIntersection do | |
@type point() :: {number, number} | |
@spec intersection([point()], point(), number()) :: [point()] | nil | |
def intersection([{x1, y1}, {x2, y2}], {cx, cy}, r) when is_number(r) do | |
dx = x2 - x1 | |
dy = y2 - y1 | |
dr = :math.sqrt(dx * dx + dy * dy) | |
matrix = x1 * y2 - x2 * y1 | |
discriminant = square(r) * square(dr) - square(matrix) |
This file contains 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
-label("Waistcoat\n%name\n%date") | |
body($back_length $front_length_to_side $blade $under_arm $breast $waist $bottom_of_front) -> | |
@A = $breast/2 right of @origin, | |
@M = @origin, | |
|top = @A to @origin, | |
@V = 0.75 inch down from @A, | |
@C = $back_length * 1 down from @V, | |
@B = $under_arm * 1 up from @C, |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure("2") do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at |
This file contains 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
local http = require("socket.http") | |
function upload() | |
http.request("http://192.168.0.104:8080/xplane/pilot?23") | |
end | |
do_often("upload()") | |
upload() |
This file contains 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
local http = require("socket.http") | |
function upload() | |
http.request("http://192.168.0.104:8080/xplane/pilot?23") | |
This file contains 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 | |
vagrant ssh --command "cd /vagrant && make --directory /vagrant $*" |
This file contains 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 FlightschoolParser do | |
@moduledoc """ | |
Documentation for FlightschoolParser. | |
""" | |
alias :hackney, as: Hackney | |
alias :timer, as: Timer | |
def run() do | |
result = get_states("http://www.flightschoollist.com/", "airplane-flight-schools/") | |
:file.write("airport_data.csv", :io_lib.format("~p~n", [result])) |
This file contains 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 CounterTest do | |
use ExUnit.Case | |
use PropCheck.StateM | |
use PropCheck | |
require Logger | |
test "Start" do | |
{:ok, pid} = Counter.start_link(0) | |
assert Process.alive?(pid) |
This file contains 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 Counter do | |
use GenServer | |
defstruct val: 0, | |
watches: [] | |
def increment() do | |
GenServer.cast({:global, __MODULE__}, :increment) | |
end |
NewerOlder