Skip to content

Instantly share code, notes, and snippets.

defmodule Flightlog.FlightView do
use Flightlog.Web, :view
def download(airport) do
url = "https://airportapi02560c297e8.azurewebsites.net/api/Airports?code={not_that_important}&iataCode=" <> airport
response = HTTPotion.get url
{status, fields} = JSON.decode(response.body)
fields
end
<h2>Show flight</h2>
<ul>
<li>
<strong>Date:</strong>
<%= @flight.date %>
</li>
<li>
#r "System.Net.Http"
#r "Newtonsoft.Json"
open System.Net
open System.Net.Http
open Newtonsoft.Json
type Airport = {
iata: string;
country: string;
var beacon = require('beacon-pie');
console.log("Wait for the UART to initialize");
setTimeout(function() {
    console.log("UART should be ready by now");
    // setting first advertiser with power 4db, 400ms interval, Local Name "Test"
    beacon.setAdvertisingPacket(1, 4, 400, "Test");
    // same settings for 2nd advetiser, with bigger granularity
defmodule Flightlog.FlightView do
use Flightlog.Web, :view
def download(airport) do
url = "https://airportapi02560c297e8.azurewebsites.net/api/Airports?code=gEjAp7qIbRDJRJYFYxcgZ1bl1sqCPaTBPsZLVxy5MGHRNFEU79etKw==&iataCode=" <> airport
response = HTTPotion.get url
{status, fields} = JSON.decode(response.body)
fields
end
defmodule Flightlog.Math do
def greatCircle(a,b) do
lat1 = elem(a, 0)
lon1 = elem(a, 1)
lat2 = elem(b, 0)
lon2 = elem(b, 1)
rlat1 = :math.pi * lat1 / 180.0
rlat2 = :math.pi * lat2 / 180.0
theta = lon1 - lon2