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

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 / muchas_caras_git_checkout.md
Last active October 28, 2020 10:59
Las muchas caras de git checkout

Las muchas caras de git checkout

Es bien sabido que la interfaz de línea de comandos de Git es confusa. Por ejemplo,git checkout tiene distintos comportamientos no demasiado relacionados entre sí.

El primero es cambiar a una rama ya existente:

git checkout mirama

También podemos crear una nueva rama local y cambiarnos a ella:

{-# LANGUAGE ViewPatterns #-}
module Main where
import Data.Char
import qualified Data.List
import Data.Text
data SplitState
= BreakingOnSpace
This is an example of how using "fix" and open recursion lets us instrument
functions in a way reminiscent of aspect-oriented programming.
We are going to take an evaluator function for a simple expression language,
and augument it with an interactive debugger.
But first, the unavoidable dance of extensions and imports:
> {-# LANGUAGE ScopedTypeVariables #-}
> {-# LANGUAGE MultiWayIf #-}
@danidiaz
danidiaz / ComposeLift1.hs
Last active May 31, 2020 13:43
Lifting applicative compositions to bigger compositions
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

stuff I had to install

npm install webpack webpack-cli --save-dev

npm install --save-dev file-loader

npm install --save-dev typescript ts-loader

to build

@danidiaz
danidiaz / BuildRecordInteractively.hs
Last active April 16, 2020 12:54
A function for constructing a value of any record type (that has the required instances) by asking the user interactively for the value of each field. Depends on http://hackage.haskell.org/package/red-black-record
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
@danidiaz
danidiaz / Vitreous.hs
Last active April 7, 2020 16:22
Remember this once RecordDotSyntax lands in GHC
-- see also https://stackoverflow.com/questions/61079836/why-isnt-the-constraint-trick-working-in-this-manually-defined-hasfield-insta
{-# LANGUAGE DataKinds, PolyKinds, FlexibleInstances, UndecidableInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE Rank2Types #-} -- for Into, otherwise unnecessary
{-# LANGUAGE StandaloneKindSignatures #-}
module Main where
import Control.Lens
@danidiaz
danidiaz / MaybeizeProduct.hs
Last active March 21, 2020 18:37
Maybeize a product
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
@danidiaz
danidiaz / closures.vim
Created March 2, 2020 00:06
(micro)benchmarking Vimscript closures
function Func1(x)
function! Func1Clos(y) closure
return a:x + a:y
endfunction
return funcref('Func1Clos')
endfunction
function Func2(x)
return { y -> a:x + y }
endfunction