Skip to content

Instantly share code, notes, and snippets.

@mlusiak
mlusiak / redis-complete.fs
Created December 11, 2013 01:40
Putting it all together - get data, save to redis, read back, chart
#if INTERACTIVE
#r "bin/Debug/FSharp.Data.dll"
#r "bin/Debug/FSharp.Charting.dll"
#r "bin/Debug/ServiceStack.Common.dll"
#r "bin/Debug/ServiceStack.Interfaces.dll"
#r "bin/Debug/ServiceStack.Text.dll"
#r "bin/Debug/ServiceStack.Redis.dll"
#load "../packages/FSharp.Charting.0.90.5/FSharp.Charting.fsx"
#endif
open System.IO
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
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
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
#r "System.Net.Http"
#r "Newtonsoft.Json"
open System.Net
open System.Net.Http
open Newtonsoft.Json
type Airport = {
iata: string;
country: string;
<h2>Show flight</h2>
<ul>
<li>
<strong>Date:</strong>
<%= @flight.date %>
</li>
<li>
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
<li>
<strong>Plane Type</strong>
<%= @flight.plane_type %>
</li>
@mlusiak
mlusiak / show.html.eex
Created March 21, 2017 23:08
Elixir Template 2
<div class="jumbotron">
<h2>Flight details</h2>
<%= if @id=="1" do %>
<strong>Date:</strong> 13.03.2017</br>
<strong>Flight Number:</strong>SK 753</br>
<strong>From:</strong> CPH</br>
<strong>To:</strong> GDN</br>
<% else %>
No information about flight <%= @id %> ;( !
<% end %>
@mlusiak
mlusiak / index.html.eex
Created March 21, 2017 23:07
Elixir Template #1
<div class="jumbotron">
<h2>List of flights</h2>
<table>
<tr><th>Date</th><th>Flight Number</th><th>Details</th></tr>
<tr><th>13.03.2017</th><th>SK753</th><th><a href="/flights/1">-></a></th></tr>
</table>
</div>