Skip to content

Instantly share code, notes, and snippets.

Avatar

Ionuț G. Stan igstan

View GitHub Profile
@igstan
igstan / jitted.c
Created Nov 30, 2022
Hello World JIT for Apple Silicon
View jitted.c
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
static uint8_t code[] = {
0x40, 0x05, 0x80, 0x52, // mov w0, #3
0xc0, 0x03, 0x5f, 0xd6, // ret
View fold_right.ml
module Seq = struct
include Seq
let rec fold_right : 'a Seq.t -> 'b -> ('a -> 'b Lazy.t -> 'b Lazy.t) -> 'b Lazy.t =
fun seq acc f ->
match seq () with
| Seq.Nil -> lazy acc
| Seq.Cons (a, rest) -> f a (lazy (Lazy.force (fold_right rest acc f)))
let map : ('a -> 'b) -> 'a Seq.t -> 'b Seq.t =
View visitors-1.scala
trait SACVisitor[R] {
def c1(a: Int): R
def c2(a: R, b: R): R
}
sealed trait SAC extends Product with Serializable {
def fold[R](visitor: SACVisitor[R]): R
}
object SAC {
View StateComposition.scala
import cats.implicits._
import cats.Monad
import cats.data.State
//
// Two capability/tagless final traits: Foo & Bar
//
trait Foo[F[_]] {
def foo: F[Unit]
}
View execution.log
$ ./to-csv.sed records.xml
111111H2,111AA2026
111111N1,111AA2026
111111Q1,111AA2026
111111U1,111AA2026
111111Z1,111AA2026
View BubbleUpObservable.scala
import cats.Eq
import monix.reactive.Observable
import monix.execution.Scheduler.Implicits.global
object Main {
implicit final class ObservableOps[A](private val self: Observable[A]) extends AnyVal {
def bubbleUpHot(a: A)(implicit Eq: Eq[A]): Observable[A] =
self.publishSelector { hot =>
val special = hot.find(_ === a)
val beforeSpecial = hot.takeWhile(_ =!= a)
View OptionalVisitor.scala
trait Optional[A] {
def visit[R](visitor: Optional.Visitor[A, R]): R
// Alias to show that visiting is similar to pattern matching.
def matching[R](visitor: Optional.Visitor[A, R]): R =
visit(visitor)
}
object Optional {
View ServicePrincipal.ts
import * as azure from "@pulumi/azure";
import * as azuread from "@pulumi/azuread";
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
export const app = new azuread.Application('pulumi', {
availableToOtherTenants: false,
homepage: "http://example.com",
identifierUris: ["http://example.com"],
oauth2AllowImplicitFlow: true,
View bucharestfp-61.md

Bucharest FP #61 — Implementing IMP in K and Haskell

Event Agenda

  • 18:45 — 19:00 Welcome
  • 19:00 — 20:00 Everett Hildenbrandt — Side-by-side implementation of an IMP language in K and Haskell
  • 20:00 — 21:00 Networking

Talk Abstract

View QuotedString.scala
final class QuotedString(private val sc: StringContext) extends AnyVal {
/**
* {{{
* scala> val msg = "foo"
* msg: String = foo
*
* scala> qs"$msg"
* res1: String = "foo"
*
* scala> qs"<$msg"