Skip to content

Instantly share code, notes, and snippets.

View ramirez7's full-sized avatar
💗
Grey hairs are visible / I'm kinda of miserable, too

Armando Ramirez ramirez7

💗
Grey hairs are visible / I'm kinda of miserable, too
View GitHub Profile
@ramirez7
ramirez7 / maybe-void-aeson.hs
Last active April 1, 2023 21:16
You can use `Maybe Void` to drop a field from a JSON object
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE DeriveGeneric #-}
module MaybeVoidAeson where
import Data.Aeson qualified as Ae
import GHC.Generics
data T a = T { x :: Int, y :: a } deriving Generic

[Final result here]

<script src="./hls.js"></script>
<marquee direction="up"><h1>HLS STREAMING</h1></marquee>
<video id="video" controls></video>
<marquee direction="left"><h1>SO</h1></marquee>
<marquee direction="right"><h1>COOL</h1></marquee>
<
<script>
{
services.paperless = {
enable = true;
consumptionDirIsPublic = true;
extraConfig = {
PAPERLESS_CSRF_TRUSTED_ORIGINS="http://localhost,http://armando-desktop.local";
PAPERLESS_ALLOWED_HOSTS="localhost,armando-desktop.local";
PAPERLESS_CORS_ALLOWED_HOSTS="http://localhost,http://armando-desktop.local";
};
};
(setq hsc-memorable-field-ty-def "")
(defun hsc-memorable-field (c-ty name hs-ty)
"Insert a Memorable struct field .hsc declaration"
(interactive
(list
(read-string
(format "C struct [%s]: " hsc-memorable-field-ty-def)
nil nil hsc-memorable-field-ty-def)
(read-string "C name: ")
(read-string "Haskell type: ")
@ramirez7
ramirez7 / tf-constraint.hs
Last active December 21, 2022 20:05
TF effectively returning c => t
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ConstraintKinds #-}
import Data.Kind (Type, Constraint)
data CT (c :: Type -> Constraint) t
type family TF t :: Type where
@ramirez7
ramirez7 / implicit-inference.hs
Created December 2, 2022 22:15
Using ImplicitParams to guide type inference
-- asks is frequently too ambiguous
impAsks
:: forall a b es
. (?impReader :: Proxy a)
=> Reader a :> es
=> (a -> b)
-> Eff es a
impAsks = asks
withImpReader
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let src = fetchgit {
url = "https://github.com/binji/smolnes";
rev = "9126b8c9aa32e58814627281bbab2ba06a159514";
sha256 = "03ifah66y42gw4h3bqh7mhykbbkn5s9byi48amq3qxiqpz260mdy";
};
in stdenv.mkDerivation {
name = "smolnes";
version = "2022-11-02";
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils -p wineWowPackages.stable
set -e
if [[ -z "$1" ]]; then
echo "USAGE: ./nix-wine-run.sh PATH_TO_EXE"
exit 1
fi
(setq paste-dry-v "")
(setq paste-dry-txt "")
(defun paste-dry-setup (v txt)
"Setup a paste-dry"
(interactive
(list
(read-string
(format "Variable [%s]: " paste-dry-v)
nil nil
paste-dry-v-def)
newtype Aligned f a = Aligned { unAligned :: f a }
instance (Semigroup a, Semialign f) => Semigroup (Aligned f a) where
Aligned x1 <> Aligned x2 = Aligned $ Data.Align.salign x1 x2
instance (Semigroup a, Align f) => Monoid (Aligned f a) where
mempty = Aligned Data.Align.nil