Skip to content

Instantly share code, notes, and snippets.

View FlorianCassayre's full-sized avatar

Florian Cassayre FlorianCassayre

View GitHub Profile
@slimsag
slimsag / ramblings.md
Last active December 13, 2023 08:02
Because cross-compiling binaries for Windows is easier than building natively

Because cross-compiling binaries for Windows is easier than building natively

I want Microsoft to do better, want Windows to be a decent development platform-and yet, I constantly see Microsoft playing the open source game: advertising how open-source and developer friendly they are - only to crush developers under the heel of the corporate behemoth's boot.

The people who work at Microsoft are amazing, kind, talented individuals. This is aimed at the company's leadership, who I feel has on many occassions crushed myself and other developers under. It's a plea for help.

The source of truth for the 'open source' C#, C++, Rust, and other Windows SDKs is proprietary

You probably haven't heard of it before, but if you've ever used win32 API bindings in C#, C++, Rust, or other languages, odds are they were generated from a repository called microsoft/win32metadata.

@stewSquared
stewSquared / Day22.worksheet.sc
Last active July 12, 2022 10:59
Advent of Code 2021 Day 22 in Scala 3
val steps =
io.Source.fromResource("2021/day-22-1.txt").getLines.toList.collect {
case s"$step x=${Range(xs)},y=${Range(ys)},z=${Range(zs)}" =>
Step(step == "on", Area(xs, ys, zs))
}
case class Step(on: Boolean, area: Area):
def countLastTouched(future: List[Step]): Long =
val overlaps = future.flatMap(_.area.intersect(area))
val touchedLater = Area.unionSize(overlaps)
@stewSquared
stewSquared / Day17.worksheet.sc
Last active July 12, 2022 11:00
Playing with Scala 3 opaque types for AoC 2021 Day 17
val input = io.Source.fromResource("2021/day-17-1.txt").getLines.next()
case class Point(x: Int, y: Int)
object Point:
opaque type Position <: Point = Point
opaque type Velocity <: Point = Point
opaque type Origin <: Position = Position
def Position(x: Int, y: Int): Position = Point(x, y)
  1. Generate the file:
$ awk 'BEGIN { for(c=0;c<10000000;c++) printf "<p>LOL</p>" }' > 100M.html
$ (for I in `seq 1 100`; do cat 100M.html; done) | pv | gzip -9 > 10G.boomgz
  1. Check it is indeed good:
@KATT
KATT / favourite-ts-tricks.md
Last active July 26, 2023 06:16
🧙‍♂️ Favourite non-obvious TS tricks

Record<string, x | undefined>

Represent maps

// rather than 
const map: {[ key: string ]: string} = {
  foo: 'bar',
}
@laughinghan
laughinghan / Every possible TypeScript type.md
Last active June 19, 2024 10:18
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@japgolly
japgolly / upgrade.md
Last active April 26, 2022 02:55
Scala 2.13 migration notes

scalafix

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.13")
import scalafix.sbt.ScalafixPlugin.autoImport.{scalafixDependencies, scalafixSemanticdb}

scalafixDependencies in ThisBuild += "org.scala-lang.modules" %% "scala-collection-migrations" % "2.1.4",
import java.util.Date
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import scala.collection.mutable
import scala.io.{AnsiColor, Source}
/**
* @author Louis Vialar
@andywer
andywer / _readme.md
Last active October 18, 2024 18:19
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@sualeh
sualeh / Dockerfile
Last active April 24, 2023 12:30
Example of how to extend the SchemaCrawler Docker image
# ========================================================================
# Example of how to extend the SchemaCrawler Docker image. See
# https://github.com/schemacrawler/SchemaCrawler-Docker
# for instructions on how to use.
# ========================================================================
FROM schemacrawler/schemacrawler
USER schcrwlr
WORKDIR /home/schcrwlr