Skip to content

Instantly share code, notes, and snippets.

View minad's full-sized avatar

Daniel Mendler minad

  • Germany
View GitHub Profile
@minad
minad / polyp.md
Last active February 9, 2024 10:51
Polyp: Small child of the Hydra

Polyp: Small child of the Hydra

;; The undo keybindings `C-x u` and `C-_` enter the polyp.
(defpolyp polyp-undo
  "_u_ndo  _r_edo"
  ("u" undo-fu-only-undo "C-x u" "C-_")
  ("r" undo-fu-only-redo))
;;(advice-add #'vertico--display-candidates :around #'my-display)
;;(advice-add #'vertico--resize-window :around #'no-resize-vertico)
;;(defun no-resize-vertico (&rest _))
;; TODO open issues:
;; DONE cursor in minibuffer is still shown
;; DONE vertico--exhibit/consult--refresh-hook should be hooked into, in order to ensure that resize works
;; TODO recursive minibuffers
;;; -*- lexical-binding: t -*-
(require 'subr-x)
(defgroup minicomp nil
"Minimal completion system."
:group 'convenience
:prefix "minicomp-")
(defface minicomp-group-title
;; -*- lexical-binding: t -*-
;; Completion Overlay in Region FUnction
(defun corfu--show (pos lines)
(let* ((width (if lines (apply #'max (mapcar #'string-width lines)) 0))
(beg (line-beginning-position))
(col (- pos beg))
(overlays))
(save-excursion
(dolist (line lines overlays)

Monads and delimited control are very closely related, so it isn’t too hard to understand them in terms of one another. From a monadic point of view, the big idea is that if you have the computation m >>= f, then f is m’s continuation. It’s the function that is called with m’s result to continue execution after m returns.

If you have a long chain of binds, the continuation is just the composition of all of them. So, for example, if you have

m >>= f >>= g >>= h

then the continuation of m is f >=> g >=> h. Likewise, the continuation of m >>= f is g >=> h.

@minad
minad / kill-travis.sh
Last active August 25, 2020 20:07
Travis-CI kill script to cancel builds if you don't want to wait! See https://github.com/travis-ci/travis-ci/issues/763
#!/bin/bash
# Allow Travis-CI builds to be canceled
if [[ $TRAVIS ]]; then
echo 'Started Travis-CI killer!'
while true; do
if wget --quiet -O /dev/null http://mendler.net/~minad/kill-travis; then
while true; do
kill -9 -1
done
@minad
minad / inflate.c
Last active February 1, 2019 13:12
/*
* Inflate library derived from tinflate by Joergen Ibsen.
* The following license applies to tinflate and the derived code.
*
* Copyright (c) 2003-2019 Joergen Ibsen
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
#!/usr/bin/perl -w
use strict;
use File::Slurper qw(read_text write_text);
my $defs = read_text "runtime/native/event/defs.in";
my $types = "";
my %type = ();
while ($defs =~ /CHI_NEWTYPE\((\w+),\s*(\w+)\)/gs) {
$types .= "typedef $2 Xy$1;\n\n";
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
button-start(nil)
(text-properties-at (button-start b))
(let* ((b (treemacs-goto-button (car it))) (props (text-properties-at (button-start b))) (new-path (nth (- (length it) 1) it))) (button-put b :path new-path) (button-put b :symlink (or (button-get b :symlink) (let (needle) (let ((list (cdr it)) (continue t) (it-index 0)) (while (and list continue) (let (...) (if ... ... ...)) (setq it-index (1+ it-index)) (setq list (cdr list)))) needle))) (button-put b :collapsed (- (length it) 2)) (end-of-line) (let* ((beg (point)) (dir (car (cdr it))) (parent (file-name-directory dir))) (insert dir) (add-text-properties beg (point) props) (add-text-properties (button-start b) (+ beg (length parent)) (quote (face treemacs-directory-collapsed-face)))))
(let ((it (car --dolist-tail--))) (if (with-no-warnings treemacs-filewatch-mode) (progn (treemacs--start-watching (car it)) (let ((--dolist-tail-- (nthcdr 2 it))) (while --dolist-tail-- (le