Skip to content

Instantly share code, notes, and snippets.

@leshy
leshy / diagon-babel.el
Last active December 14, 2024 08:34
diagon org mode babel language
(defun org-babel-execute:diagon (body params)
(let* ((mode (or (cdr (assoc :mode params))
(error "You must specify a :mode parameter")))
(diagon-command (format "nix run github:petertrotman/nixpkgs/Diagon#diagon -- %s -style=Unicode" mode))
(result-type (cdr (assoc :result-type params)))
(output (string-trim (org-babel-eval diagon-command body))))
(if (eq result-type 'value)
output
(org-babel-import-elisp-from-file output))))
@leshy
leshy / h.sh
Created September 28, 2024 10:07
#!/bin/bash
# Function to handle entities (switches and scenes)
handle_entities() {
local action=$1
local name=$2
# Get the list of all entities once
local all_entities=$(hass-cli entity list)
@leshy
leshy / jwz.sh
Created December 10, 2020 08:44
#!/bin/bash
rm dl.list
for i in $(seq -f "%03g" 1 140)
do
echo "https://archive.org/compress/jwz-mixtape-${i}/formats=VBR%20MP3&file=/jwz-mixtape-${i}.zip" >> dl.list
done
wget -ci dl.list

Keybase proof

I hereby claim:

  • I am leshy on github.
  • I am lesh (https://keybase.io/lesh) on keybase.
  • I have a public key whose fingerprint is 5E79 D2A9 2462 8020 DD4B 9A46 5E00 9023 46BB 19B9

To claim this, I am signing this object:

@leshy
leshy / f.py
Last active October 5, 2017 19:39
# class dict does internally what next example does explicitly (builds a dict of { cls.__name__ : cls }
return f.map_keys(
arg(last, call('lower')), # equivalent to next example lambda
f.class_dict(
common.service.RestartableService.__subclasses__(),
common.service.Service.__subclasses__()
)).get(service_name.lower())
# list comprehension, but utilizing map_keys
@leshy
leshy / slime-livescript.el
Last active September 29, 2017 15:08
emacs slime livescript
(defun livescript-compile-region-emacs ()
(interactive)
(save-excursion
(setq livescript-args-compile '("-c" "--no-header" "--bare"))
(if (equal mark-active nil) (mark-whole-buffer))
(livescript-compile-region (point) (mark))
(deactivate-mark)
(setq livescript-args-compile '("-c" "--no-header" "-m" "embedded")))
)
(require 'sclang)
(add-to-list 'auto-mode-alist '("\\.sc$" . sclang-mode))
(add-to-list 'auto-mode-alist '("\\.sclang$" . sclang-mode))
(add-hook 'sclang-mode-hook
(lambda () (progn
(local-set-key (kbd "C-q C-e") 'sclang-eval-region)
(local-set-key (kbd "C-q C-c") 'sclang-eval-region)
(local-set-key (kbd "C-q C-s") 'sclang-server-free-all)
(load-file "~/emacs/el/lesh/colorpicker/colorpicker.el")
(defun xah-syntax-color-hex ()
"Syntax color hex color spec such as 「 #FF1100 」 in current buffer."
(interactive)
(font-lock-add-keywords
nil
'(("#[abcdefABCDEF[:digit:]]\\{6\\}"
(0 (put-text-property
(+ (match-beginning 0) 1)
#!/bin/bash
# downloads all mp3 jwz mixtapes (1-75)
for i in `seq -f "%03g" 1 75`;
do
URL="https://archive.org/compress/jwz-mixtape-$i/formats=VBR%20MP3&file=/jwz-mixtape-$i.zip"
echo $URL
wget -c $URL
done
for z in *.zip
;flycheck livescript
(flycheck-define-checker livescript
"A Livescript syntax checker using livescript.
See URL `http://livescript.net/'."
:command ("livescript" "--compile" "--print" "--stdin")
:standard-input t
:error-patterns
((error line-start "[" (message) "on line " line "]" line-end))
:modes livescript-mode)