Skip to content

Instantly share code, notes, and snippets.

View danidiaz's full-sized avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
@danidiaz
danidiaz / _01_modify_delete_conflicts.md
Last active November 26, 2023 21:06
Truquillos Git
View _01_modify_delete_conflicts.md

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
danidiaz / netrw.txt
Created October 7, 2016 20:57
Vim's netrw commands.
View netrw.txt
--- ----------------- ----
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
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
View CaseOfKnownConstructor.hs
-- https://www.reddit.com/r/haskell/comments/170f6qa/comment/k6spn9n/
-- 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
danidiaz / FullLazinessPresumedWoes.hs
Created October 19, 2023 21:35
problems due to laziness
View FullLazinessPresumedWoes.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE LambdaCase #-}
-- | https://well-typed.com/blog/2016/09/sharing-conduit/
module Main where
import Control.Exception
import System.IO
retry :: IO a -> IO a
retry io = do
@danidiaz
danidiaz / RecordUpdatePain.hs
Last active October 4, 2023 20:30
record update pain
View RecordUpdatePain.hs
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE RecordWildCards #-}
module Main where
import Distribution.Simple (KnownExtension(RecordWildCards))
data Foo = Foo {
aaa :: Int,
bbb :: Bool
View ReifyExceptions.hs
-- code by mniip
types :: [String]
types = $(
do
insts <- reifyInstances ''Exception [VarT (mkName "a")]
let
tyConOf (AppT ty _) = tyConOf ty
tyConOf (ConT con) = Just con
tyConOf _ = Nothing
tyCons <- for insts \case
@danidiaz
danidiaz / ifd1.nix
Last active August 5, 2023 16:40
ifd
View ifd1.nix
# https://nixos.wiki/wiki/Import_From_Derivation
# https://discourse.nixos.org/t/how-to-import-a-derivation-with-import/15375
# https://nixos.org/manual/nix/stable/language/builtins#builtins-import
# https://nixos.org/manual/nix/stable/language/values.html#type-string
let
pkgs = import <nixpkgs> {};
derivation-to-import = pkgs.writeText "inner" "5";
imported-nix-value = import derivation-to-import;
in pkgs.writeText "foo" ''
The value from the inner derivation was: ${toString imported-nix-value}
@danidiaz
danidiaz / _FP reading lists.md
Last active July 8, 2023 19:53
assorted reading lists
View _FP reading lists.md

A series of reading lists mostly related to functional programming.

@danidiaz
danidiaz / flake.macos.nix
Last active May 10, 2023 10:59
My first Nix flake
View flake.macos.nix
{
# https://nix.dev/anti-patterns/language#unquoted-urls
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs, ... }@attrs:
# https://discourse.nixos.org/t/using-nixpkgs-legacypackages-system-vs-import/17462/5
# https://discourse.nixos.org/t/recommendations-for-use-of-flakes-input-follows/17413
let pkgs = nixpkgs.legacyPackages.aarch64-darwin;
in {
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-fmt.html