Skip to content

Instantly share code, notes, and snippets.

@wasamasa
wasamasa / doctor.el
Last active April 2, 2021 16:26
M-x doctor, but not as we know it.
;;; doctor.el --- psychological help for frustrated users
;; Copyright (C) 1985, 1987, 1994, 1996, 2000-2021 Free Software
;; Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: games
;; This file is part of GNU Emacs.
(defun my-image-map-key-handler (posn)
(let* ((area (symbol-name (posn-area posn)))
(color (capitalize (cadr (split-string area "-")))))
(message "%s" color)))
(defun my-image-map-key-filter (_map)
(let ((e last-input-event))
(when (mouse-event-p e)
;; implicitly returns nil if not all conditions were satisfied,
;; thereby allowing other keys to pass through
@wasamasa
wasamasa / checkinstance.rb
Last active February 4, 2023 10:12
See the local timeline of any Mastodon instance
#!/usr/bin/env ruby
require 'json'
require 'http'
def api_request(instance, path, params)
uri = URI::HTTPS.build(host: instance, path: path,
query: URI.encode_www_form(params))
res = HTTP.headers(accept: 'application/json').get(uri)
raise("HTTP error #{res.status.to_i}") unless res.status.ok?
@wasamasa
wasamasa / r2pipe.el
Created September 29, 2019 15:52
r2pipe.el
(require 'cl-lib)
(require 'json)
(defvar r2pipe-bin (executable-find "radare2"))
(defvar r2pipe-buffer "*r2pipe*")
(defun r2pipe-process-filter (proc string)
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
(let ((moving (= (point) (process-mark proc))))
@wasamasa
wasamasa / exapunks-nonograms.md
Created October 29, 2018 08:33
Transcription of the nonograms in the 2nd EXAPUNKS zine

EASY

                              1  4
                           1  1  1  4
                     3  2  3  1  1  1  7  4  4
                 15  5  6  3  5  3  5  3  6  4 15

              11
            3  6
@wasamasa
wasamasa / config.scm
Last active October 7, 2017 17:31
Playing the piano with Kawa
;; ~/.config/midi.scm/config
((default-instrument-id . 4)
(default-velocity . 127)
(default-volume . 127)
(map (97 . 60) ; a -> c4
(119 . 61) ; w -> c4#
(115 . 62) ; s -> d4
(101 . 63) ; e -> d4#
(100 . 64) ; d -> e4
@wasamasa
wasamasa / alpaca.el
Created September 16, 2016 17:48
AJE
;;;
;;; alpaca.el -- an easy way to edit GnuPG files encrypted with
;;; shared-key cryptography
;;;
;; Author: Kazu Yamamoto <Kazu@Mew.org>
;; Created: Oct 16, 2003
;; Revised: Feb 17, 2008
;;; Commentary:
@wasamasa
wasamasa / lowdown-fenced-code-block.scm
Last active November 5, 2021 19:11
Fenced code block extension for lowdown
(module lowdown-fenced-code-block
(fenced-code-block
enable-lowdown-fenced-code-blocks!)
(import scheme)
(import (chicken base))
(import (chicken string))
(import (srfi 13))
@wasamasa
wasamasa / obfuscate-buffer.el
Last active April 8, 2016 15:26
Buffer obfuscation
(defvar my-buffer-obfuscation-overlay nil)
(defun my-obfuscate-buffer ()
(interactive)
(let* ((buffer-content (buffer-substring (point-min) (point-max))))
(dotimes (i (length buffer-content))
(let ((char (aref buffer-content i)))
(when (string-match-p "[[:graph:]]" (char-to-string char))
(aset buffer-content i ?.))))
(setq my-buffer-obfuscation-overlay
@wasamasa
wasamasa / filter-buffer.el
Last active October 10, 2017 19:45
Emacs buffer filtering
(defun my-filter-current-buffer (program &rest args)
(let* ((stdout-buffer (generate-new-buffer " stdout"))
(ret (apply 'call-process-region (point-min) (point-max) program
nil (list stdout-buffer) nil args)))
(when (zerop ret)
(let ((output (with-current-buffer stdout-buffer
(buffer-string))))
(erase-buffer)
(insert output)))
(kill-buffer stdout-buffer)))