Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
View shell.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [
pkgs.glibcLocales
(pkgs.postgresql.withPackages (p: []))
pkgs.pgcli
];
shellHook = ''
StartPG(){
pg_ctl -w -l $PGDATA/log start
View TypeLevelFieldMetadata.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
View AtLeastOneValue.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
-- https://twitter.com/ChShersh/status/1544240982559948801
module Main where
import Data.Kind (Type)
import Data.RBR -- from package "red-black-record"
( Deletable (Delete),
FromList,
@danidiaz
danidiaz / Flexbox_and_Margins.tsx
Created Jun 26, 2022
CSS & Tailwind snippets
View Flexbox_and_Margins.tsx
export default function Flexy() : JSX.Element {
return (<div className="flex flex-row">
<div className = "outline outline-black">
<p>Foo</p>
</div>
<div className = "outline outline-black">
<p>Bar</p>
</div>
<div className = "ml-auto outline outline-black" >
<p>Baz</p>
View Main.hs
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE ImportQualifiedPost #-}
module Main where
import Data.Array.Mutable.Linear (Array, set)
import Data.Array.Mutable.Linear qualified as Array
import Prelude.Linear (Ur(..), (&), (.))
quicksort :: Array Int Array Int
View LensyTypChangingUpdate.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE KindSignatures #-}
module Main where
import Control.Lens ( (^.), (&), (.~), Lens )
import Data.Generics.Product.Fields qualified as G
import GHC.Records (HasField (..))
View ABitOfKnotTying.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Main where
import Dep.Has (Has(dep), asCall) -- from the "dep-t" package
import Control.Monad.IO.Class
@danidiaz
danidiaz / Override.hs
Last active Mar 17, 2022
Modeling Nix's "override" and "overrideAttrs" in Haskell
View Override.hs
-- | Derivations in Nixpkgs are usually the result of a chain of function calls.
-- Typically, a function receives some input derivations as arguments (the "inputs
-- pattern") and it eventually calls the 'mkDerivation' function, which produces the
-- actual derivation value that is put into Nixpkgs.
--
-- Turns out that derivation values in Nixpkgs keep a "memory" of how they were produced at
-- those two stages: which functions were called, and with which arguments. They
-- also provide "hooks" that allow re-running the stages with (partially or
-- totally) different arguments, resulting in a new derivation.
--
@danidiaz
danidiaz / mistel-barocco-md600.md
Created Jan 7, 2022 — forked from jdhom/mistel-barocco-md600.md
Mistel Barocco MD600 Programming and Firmware
View mistel-barocco-md600.md

Mistel Barocco MD600 RGB Split Keyboard

keyboard firmware

What I remap

CapsLock is RCTRL    ... i do this on all keyboards
FN CapsLock is RCTRL ... was accidently toggling capslock with fn+capslock
LCTRL is FN ... arrow/pg/home on right half, FN+arrow I now prefer on ALL keyboards... so nice
@danidiaz
danidiaz / ConstrainingCoerce.hs
Created Dec 14, 2021
constraining "coerce" using type families
View ConstrainingCoerce.hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DataKinds #-}
-- | Examples of how to constrain "coerce" using type families so that only the
-- types that we really want to change might change, and not some unexpected
-- newtype.
module Main where