Skip to content

Instantly share code, notes, and snippets.

View agumonkey's full-sized avatar

gum agumonkey

  • NONE
  • Dark side of the moon @ ['tkf8-2-1', 'ay21-3', '3263-827']
View GitHub Profile
@agumonkey
agumonkey / nav-buffer-local-variables.el
Created November 10, 2018 18:12
Helper to show buffer local variables in a table (thanks to the amazingly superb ctable)
(require 'ctable)
(defun nav-buffer-local-variables (b)
(interactive "bBuffer:\n")
(let ((vars (buffer-local-variables (get-buffer b))))
(ctbl:popup-table-buffer-easy vars '(name value))))
(setq lexical-binding t)
(require 'ht)
(defvar *pool* (ht-create) "*POOL*: HN Callback Pool")
(defvar *ids*
(list
"18376741"
"18376287"
@agumonkey
agumonkey / hn.el
Last active September 26, 2021 14:38
porting hackernews -> org-mode from js to elisp https://gist.github.com/dharmatech/2ef271907cb73298318fdb50a4ee7d54
;;; hn.el --- convert hacker news post into org-mode buffer -*- lexical-binding: t -*-
;; Copyright (C) 2018- Free Software Foundation, Inc.
;; Author: Johan Ponin <johan.ponin.pro@gmail.com>
;; Version: 0.0.1
;; Package-Version: 20181103.0001
;; Keywords: hackernews, org-mode
;; This program is free software; you can redistribute it and/or modify
@agumonkey
agumonkey / c-x-4.el
Created November 2, 2018 12:41
make a new buffer in a new window
(progn
(defun new-other-buffer ()
(interactive)
(let ((n (generate-new-buffer-name "new")))
(let ((b (get-buffer-create n)))
(split-window-right)
(switch-to-buffer-other-window b))))
(global-set-key (kbd "C-x 4") #'new-other-buffer))
@agumonkey
agumonkey / refup
Created September 24, 2018 10:44
update pacman mirrorlist using reflector
#!/usr/bin/bash
# file -> ext -> io
function rotate () {
echo ">>> $*"
local f=$1
local e="bak"
local t=`date -Iminutes`
sudo cp -v $f "${f}.${t}.${e}"
}
@agumonkey
agumonkey / rsync-clone.sh
Last active December 25, 2018 19:39
some microporcelain over rsync
function clone () {
local src=$1
local dst=$2
local min=`date +%F_%Hh%Mm%Ss`
local log="/tmp/rsync-$min-$1-to-$2.log"
echo "[INFO] logging into $log"
rsync -chaux --verbose --progress --stats --delete --log-file=$log "${src}" "${dst}"
}
clone
(defun mns (a)
(let ((n (symbol-name a)))
(if (s-contains? "directory" n)
(if (boundp a)
(let ((v (symbol-value a)))
(if (and v (stringp v) (s-contains? "/usr/share" v))
(message "> %S %s %s" a n v)))))))
(mapatoms #'mns)
@agumonkey
agumonkey / defint.el
Created September 6, 2018 01:58
defun interactive macro
(defmacro defint (name args &rest body)
`(defun ,name ,args (interactive) ,@body))
;;; (macroexpand '(defint bash () (ansi-term "/bin/bash")))
(defint bash () (ansi-term "/bin/bash"))
@agumonkey
agumonkey / pdf-tags.sh
Created September 2, 2018 16:40
ultra naive pdf word frequency sorted words
function tags () {
ps2ascii $1 | sed -e 's,\s\+,\n,g' | tr 'A-Z' 'a-z' | tr '.,;:)([]' ' ' | grep -Evi '(by|do|does|\.|\||/|are|very|from|it|if|should|not|keep|over|for|to|a|as|be|or|of|on|in|and|the|you|your|will|when|would|is|maybe|with|such|let|must|implies|given|but|now|where|both|unique|some|while|set|some|we|which)' | grep -Evi '^[0-9 ]*$' | grep -Evi '^[a-z\-\+]$' | sort | uniq -c | sort -rn -k1 | head -n ${2:-48} ### pdf-stats
}
@agumonkey
agumonkey / buffer-urls.el
Created August 2, 2018 14:17
list urls from a buffer
(require 'ctable)
(defun ERC-urls ()
(interactive)
(let ((small (lambda (url) (< (length url) 64)))
(r '())
(b (current-buffer))
(p (point)))
(save-excursion
(while (re-search-backward "https?://[[:graph:]]+" nil t)