Skip to content

Instantly share code, notes, and snippets.

View whitetigle's full-sized avatar

Whitetigle whitetigle

View GitHub Profile
let events = ResizeArray()
let rec stateMachine (smodel: StateModel) (rmodel: RenderModel option) lastDelta: Async<unit> = async {
let! delta = awaitAnimationFrame()
let diff = delta - lastDelta
let newState =
(smodel, events)
||> Seq.fold (fun smodel ev ->
match ev with
| DonePreparing -> Run
| _ -> ev
paket add Fable.Import.Pixi
paket add Fable.Import.Animejs
@whitetigle
whitetigle / Fable.Import.PouchDB.Core.fs
Last active December 21, 2017 11:13
PouchDB wrappers for fable. WIP
namespace Fable.Import
open System
open System.Text.RegularExpressions
open Fable.Core
open Fable.Import.JS
open Fable.Import.Browser
type [<AllowNullLiteral>] Buffer =
inherit Uint8Array
@whitetigle
whitetigle / jspdf.d.Ts
Created December 30, 2017 11:10
Sample jsPDF typescript file for testing
// Type definitions for jsPDF v1.1.135
// Project: https://github.com/MrRio/jsPDF
// Definitions by: Amber Schühmacher <https://github.com/amberjs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'jspdf' {
class jsPDF {
constructor(orientation?:any,
unit?:string,
format?:string,
@whitetigle
whitetigle / Fable.Import.JsPDF.fs
Created December 30, 2017 11:13
jspdf ts2fable 0.6.x generated file
// ts2fable 0.0.0
module rec Fable.Import.JsPDF
open System
open Fable.Core
open Fable.Import.JS
open Fable.Import.Browser
let [<Import("*","jspdf")>] jspdf: Jspdf.IExports = jsNative
module Jspdf =
@whitetigle
whitetigle / Fable.Import.JsPDF.fs
Created December 30, 2017 11:14
corrected file
// ts2fable 0.0.0
module rec Fable.Import.JsPDF
open System
open Fable.Core
open Fable.Import.JS
open Fable.Import.Browser
let [<Import("*","jspdf")>] jspdf: Jspdf.jsPDFStatic = jsNative //not working
module Jspdf =
@whitetigle
whitetigle / deploy.md
Last active May 17, 2022 21:00
Deploying a Single Page Application to Gitlab

Deploying a Single Page Application to Gitlab

Last week I spent some time trying to deploy a SPA on Gitlab. It took me a few hours because the documentation even if complete was not that easy to read. (at least for me)

Preparation

The following steps are mostly taken from this guide

  1. Create an account in Gitlab (or use an existing one)
  2. Create a new git project to host your web site
@whitetigle
whitetigle / haproxy.cfg
Created April 19, 2018 15:15
Haproxy working config for pouchdb/couchdb + service workers
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
maxconn 2048
tune.ssl.default-dh-param 2048
user haproxy
group haproxy
@whitetigle
whitetigle / cors.lua
Created April 19, 2018 15:16
OPTIONS method handling for haproxy
core.register_service("cors-response", "http", function(applet)
applet:set_status(200)
applet:add_header("Content-Length", "0")
applet:add_header("Access-Control-Allow-Origin", applet.headers["origin"][0])
applet:add_header("Access-Control-Allow-Credentials", "true")
applet:add_header("Access-Control-Allow-Headers", "Origin, DNT, If-Match, If-Modified-Since, If-None-Match, If-Range, If-Unmodified-Since, X-Requested-With, Content-Type, X-Auth-Token, X-Service-Token, X-Newest, X-Trans-Id-Extra, X-Trans-Id, X-Account-Meta-Temp-URL-Key, X-Account-Meta-Temp-URL-Key-2, X-Timestamp, X-Openstack-Request-Id, X-Account-Bytes-Used, X-Account-Container-Count, X-Account-Object-Count, X-Account-Meta-Quota-Bytes, X-Account-Access-Control, X-Container-Meta-Temp-URL-Key, X-Container-Meta-Temp-URL-Key-2, X-Storage-Policy, X-Container-Object-Count, X-Container-Bytes-Used, X-Container-Meta-Quota-Count, X-Container-Meta-Quota-Bytes, X-Container-Read, X-Container-Write, X-Container-Sync-Key, X-Container-Sync-To