Skip to content

Instantly share code, notes, and snippets.

@zkessin
zkessin / Main.elm
Last active April 2, 2024 20:17
Elm Architecture Hello world
module Main exposing (..)
{-
********************************************************************************
Copyright 2016 Zachary Kessin
Released under the BSD3 licence
Test your Code for better code quiality
http://elm-test.com/?utm_source=gist&utm_content=template
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)
@zkessin
zkessin / stream.erl
Created September 13, 2012 19:14
Erlang Data Streaming
-module(streaming).
-export([stream_data/1, out/1, stream_from_file/3]).
out(_Arg) ->
_Pid = spawn_link(?MODULE, stream_data, [self()]),
{streamcontent, "audio/mp3", <<>>}.
stream_data(Pid) ->
File = "/home/erlang/erlang-talk/audio.mp3",
FileHDL = open_file(File),
stream_from_file(Pid, FileHDL, 1).
-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")
@zkessin
zkessin / cover.erl
Created August 24, 2012 20:49
Erlang Code Coverage
-module(cover).
-export([ cover/0]).
cover()->
io:format("~n********************************************************************************~n"),
io:format("Running Tests~n~n"),
cover:start(),
_R = cover:compile_beam_directory("ebin/"),
#!/bin/bash
vagrant ssh --command "cd /vagrant && make --directory /vagrant $*"