Skip to content

Instantly share code, notes, and snippets.

View kunjee17's full-sized avatar
💭
Functional Programmer for hire. F#, Scala, Rust. For web, mobile, cloud etc.

Kunjan Dalal kunjee17

💭
Functional Programmer for hire. F#, Scala, Rust. For web, mobile, cloud etc.
View GitHub Profile
type Email = private | Email of string
module Email =
let create(email : string ) =
// Some validation on email
Email email
let value (Email email) = email
type Email private (email : string) =
member __.Email = email
static member create(email : string ) =
// Some validation on email
Email (email)
open System
open FSharpPlus
open FSharpPlus.Data
module Person=
type Name = { unName : String }
with static member create s={unName=s}
type Email = { unEmail : String }
with static member create s={unEmail=s}
type Age = { unAge : int }
@kunjee17
kunjee17 / rqrr_helper.rs
Created May 31, 2022 01:22
QR Code scan using rqrr rust.
/// Scan current video frame for a valid QR code containing customer id, returning it if found.
fn process_frame(&self) -> anyhow::Result<Option<i32>> {
// Get necessary elements
let video = self
.ref_video
.cast::<HtmlVideoElement>()
.ok_or(anyhow!("Video required"))?;
let context = self.context.as_ref().ok_or(anyhow!("Context required"))?;
let (width, height) = self.camera_dim;
// Draw frame to canvas