Skip to content

Instantly share code, notes, and snippets.

View danidiaz's full-sized avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
danidiaz / netrw.txt
Created October 7, 2016 20:57
Vim's netrw commands.
--- ----------------- ----
Map Quick Explanation Link
--- ----------------- ----
< <F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file |netrw-cr|
<del> Netrw will attempt to remove the file/directory |netrw-del|
<c-h> Edit file hiding list |netrw-ctrl-h|
<c-l> Causes Netrw to refresh the directory listing |netrw-ctrl-l|
<c-r> Browse using a gvim server |netrw-ctrl-r|
<c-tab> Shrink/expand a netrw/explore window |netrw-c-tab|
danidiaz / flake.nix
Created July 17, 2024 13:30
python & npm Nix flake from Mac system
description = "A very basic flake";
inputs = {
nixpkgs.url = "nixpkgs/24.05";
outputs = { self, nixpkgs }:
let system = "aarch64-darwin";
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE LambdaCase #-}
module Main where
import Data.Unrestricted.Linear (move, unur, Ur(..)) -- from linear-base
data R = R
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE OverloadedRecordDot #-}
import Control.Monad.State (State, execState, gets, modify, put, get)
import GHC.Records (HasField (..))
setField :: (HasField s a b) => b -> a -> a
danidiaz / _FP reading
Last active May 23, 2024 04:02
assorted reading lists

A series of reading lists mostly related to functional programming.

Vertical decomposition. Creating cohesive services

One of the biggest misconceptions about services is that a service is an independent deployable unit, i.e., service equals process. With this view, we are defining services according to how components are physically deployed. In our example, since it’s clear that the backend admin runs in its own process/container, we consider it to be a service.

But this definition of a service is wrong. Rather you need to define your services in terms of business capabilities. The deployment aspect of the system doesn’t have to be correlated to how the system has been divided into logical services. For example, a single service might run in different components/processes, and a single component might contain parts of multiple services. Once you start thinking of services in terms of business capabilities rather than deployment units, a whole world of options open.

What are the Admin UI

danidiaz /
Last active November 26, 2023 21:06
Truquillos Git

conflictos modify/delete

(NOTA: Los primeros "truquillos Git" fueron redactados antes de que en Git la rama por defecto pasase a ser main, y he usado --initial-branch=master como manera fácil de adaptar los ejemplos para que siguiesen funcionado. Los "truquillos" posteriores ya usan main.)

Ejecutar este script en Git Bash crea un repositorio y lo deja en un estado de conflicto de merge:

mkdir conflicto.01
cd conflicto.01
git init --initial-branch=master

echo "zzz" > foo.txt

danidiaz / CaseOfKnownConstructor.hs
Last active October 29, 2023 08:56
Example of how the case-of-known-constructor can remove the use of a record
-- Compare the core of
-- ghc -O0 -c Main.hs -ddump-to-file -ddump-simpl -dsuppress-idinfo -dsuppress-coercions -dsuppress-type-applications -dsuppress-uniques -dsuppress-module-prefixes -fforce-recomp
-- with the core of
-- ghc -O2 -c Main.hs -ddump-to-file -ddump-simpl -dsuppress-idinfo -dsuppress-coercions -dsuppress-type-applications -dsuppress-uniques -dsuppress-module-prefixes -fforce-recomp
-- search for "foofun".
module Main (main) where
data Foo = Foo
{ aaa :: Int,
danidiaz / FullLazinessPresumedWoes.hs
Created October 19, 2023 21:35
problems due to laziness
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE LambdaCase #-}
-- |
module Main where
import Control.Exception
import System.IO
retry :: IO a -> IO a
retry io = do