Skip to content

Instantly share code, notes, and snippets.

View bjartwolf's full-sized avatar

Bjørn Einar Bjartnes bjartwolf

View GitHub Profile
namespace FDK.SmsSender
open PSWinCom.Gateway.Client;
open Model;
open log4net.Ext.EventID;
type ISmsService =
abstract member SendSms: recieverNumber: string -> body: string -> unit
type UnknownError = { Error: string}
@bjartwolf
bjartwolf / color.st
Created June 8, 2014 11:14
Change color of Rapiro from Pharo
sPort := SerialPort new.
sPort baudRate: 57600.
sPort close.
sPort openPort: '/dev/ttyAMA0'.
sPort nextPutAll: '#PR010G255B255T001'.
@bjartwolf
bjartwolf / contentnegotiation.cs
Created May 1, 2014 18:28
contentnegotiation
public async Task Invoke(IDictionary<string, object> env)
{
var ctx = new OwinContext(env);
var accepts = ctx.Request.Accept;
if (accepts != null && accepts == accepts.ToUpper())
{
ctx.Response.Body = new CapsStream(ctx.Response.Body);
}
await next(env);
}
public class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
appBuilder.Use<AllCapsMiddleware.AllCaps>();
appBuilder.UseWebApi(config);
}
}
@bjartwolf
bjartwolf / allCapsMiddleware.cs
Last active August 29, 2015 14:00
all caps middleware
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Owin;
namespace AllCapsMiddleware
{
using AppFunc = Func<IDictionary<string,object>, Task>;
public class AllCaps
{
@bjartwolf
bjartwolf / capsstreams.cs
Last active August 29, 2015 14:00
streams to make caps
using System;
using System.IO;
using System.Text;
namespace HelloWorldMiddleWare2
{
class CapsStream: Stream
{
private Stream _stream;
@bjartwolf
bjartwolf / streamingowinstuff.cs
Last active August 29, 2015 14:00
streaming
using System;
using System.IO;
using System.Text;
namespace AllCapsMiddleware
{
class CapsStream: Stream
{
private readonly Stream _stream;
private readonly Decoder _decoder;
@bjartwolf
bjartwolf / 2.5.4.fs
Created April 21, 2014 19:14
2.5.4.fs
let VolumeA0IsPyramid ((h:decimal<m>), (b:decimal<m>)) =
RoundM3(V h 0m<m> b) = RoundM3( b * b * h / 3m )
Check.Quick (Prop.forAll twoDecimals VolumeA0IsPyramid)
@bjartwolf
bjartwolf / 2.5.3.fs
Created April 21, 2014 19:00
2.5.3.fs
let g (a: decimal<m>) (b: decimal<m>):decimal<m^2> = (a*a + b*b) / 2m
@bjartwolf
bjartwolf / 2.5.3.fs
Created April 21, 2014 18:49
2.5.3.fs
let RoundM3 (cubic:decimal<m^3>): decimal<m^3> = Math.Round(cubic * 1m<m^-3>,10)*1m<m^3>
let VolumeAIsBEqualssquare((a:decimal<m>), (h:decimal<m>)) =
RoundM3 (V h a a) = RoundM3( a * a * h )
let twoDecimals = Arb.generate<decimal<m>> |> Gen.suchThat ((<) 0m<m>) |> Gen.suchThat ((>) 1000000m<m>) |> Gen.two |> Arb.fromGen
Check.Quick (Prop.forAll twoDecimals VolumeAIsBEqualssquare)