Skip to content

Instantly share code, notes, and snippets.

View danidiaz's full-sized avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE ViewPatterns #-}
-- depends on the "dep-t" and "async" packages
module Main where
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [
pkgs.glibcLocales
(pkgs.postgresql.withPackages (p: []))
pkgs.pgcli
];
shellHook = ''
StartPG(){
pg_ctl -w -l $PGDATA/log start
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# 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 June 26, 2022 17:57
CSS & Tailwind snippets
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>
{-# 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
{-# 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 (..))
{-# 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 March 17, 2022 22:07
Modeling Nix's "override" and "overrideAttrs" in Haskell
-- | 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 January 7, 2022 14:11 — forked from jdhom/mistel-barocco-md600.md
Mistel Barocco MD600 Programming and Firmware

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