Skip to content

Instantly share code, notes, and snippets.

View davesnx's full-sized avatar

David Sancho davesnx

View GitHub Profile
@steveruizok
steveruizok / clean-copy.md
Created December 7, 2025 22:03
Clean copy.

Reimplement the current branch on a new branch with a clean, narrative-quality git commit history suitable for reviewer comprehension.

Steps

  1. Validate the source branch

    • Ensure the current branch has no merge conflicts, uncommitted changes, or other issues.
    • Confirm it is up to date with main.
  2. Analyze the diff

  • Study all changes between the current branch and main.
@qexat
qexat / CT.md
Last active July 7, 2025 11:48
a simple type system with support for (co)cartesian types

Notes

(Co)Cartesian Types

Definitions

A cartesian type is a generalized type product where one inhabitant, called origin is common to all the types involved (called axes). A cocartesian type is a generalized type sum with a common origin to all axes.

That is, A * ... * Z is a cartesian type if there exists one inhabitant i common to every axis — i_A = i_B = ... = i_Z.

@davesnx
davesnx / index.md
Last active November 11, 2025 10:14
Safer Tailwind with OCaml-derived languages

Safer Tailwind with OCaml-derived languages (OCaml, Reason, ReScript or Melange)

Tailwind is optimised to work with JavaScript/TypeScript ecosystems, but other languages might have good integrations also.

This is the case for OCaml-derived languages that are used to do Frontend development. For the most part, a tighter integration might not be needed and using the Tailwind setup guide and regular classNames with strings is good enought.

let make = (~text) => {
 {React.string(text)}
@hirrolot
hirrolot / CoC.ml
Last active November 19, 2025 22:54
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
```
OCaml compilation pipeline
┌────────────────┐
│ │
│ Source code │
@hirrolot
hirrolot / CoC.ml
Last active August 22, 2025 04:35
Barebones lambda cube in OCaml
(* The syntax of our calculus. Notice that types are represented in the same way
as terms, which is the essence of CoC. *)
type term =
| Var of string
| Appl of term * term
| Binder of binder * string * term * term
| Star
| Box
and binder = Lam | Pi
@davesnx
davesnx / Makefile-help
Last active June 27, 2025 02:52
Print other makefiles commands as help
.PHONY: help # Set default action to be help!
help:
@echo "List of available make commands";
@echo "";
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}';
@echo "";
# Add double ## comments on the same line as the dependencies and will be printed out when running help
# Don't add them if you don't want to appear on help!
@Khady
Khady / ppxed-source
Created September 9, 2019 06:46
Use merlin to print an ocaml file after being processed by a ppx
#!/usr/bin/env sh
# A .merlin must be present nearby the file.
# With dune it can be generated by calling `dune build @check`.
FILE="$1"
ocamlmerlin single dump -what ppxed-source -filename "$FILE" < "$FILE" | jq -r '.value' | ocamlformat --name="$FILE" -
@busypeoples
busypeoples / TypeScriptFundamentals.ts
Last active June 21, 2022 14:57
TypeScript Fundamentals For JavaScript Developers
// TypeScript Fundamentals For JavaScript Developers
/*
Tutorial for JavaScript Developers wanting to get started with TypeScript.
Thorough walkthrough of all the basic features.
We will go through the basic features to gain a better understanding of the fundamentals.
You can uncomment the features one by one and work through this tutorial.
If you have any questions or feedback please connect via Twitter:
A. Sharif : https://twitter.com/sharifsbeat
*/
@mbilokonsky
mbilokonsky / thinking_like_a_function.md
Last active October 25, 2021 14:47
Thinking Like a Function

Thinking Like a Function

Part 1: What's a function?

As a software engineer, you probably think of a function as a unit of code that takes some arguments and returns some value, eg:

 function square(x) { 
   return x * x;
 }