Skip to content

Instantly share code, notes, and snippets.

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)
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)
-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,
# -*- 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
local http = require("socket.http")
function upload()
http.request("http://192.168.0.104:8080/xplane/pilot?23")
end
do_often("upload()")
upload()
local http = require("socket.http")
function upload()
http.request("http://192.168.0.104:8080/xplane/pilot?23")
#!/bin/bash
vagrant ssh --command "cd /vagrant && make --directory /vagrant $*"
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]))
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)
defmodule Counter do
use GenServer
defstruct val: 0,
watches: []
def increment() do
GenServer.cast({:global, __MODULE__}, :increment)
end