Skip to content

Instantly share code, notes, and snippets.

View unhammer's full-sized avatar
kevin :: Coffee → Code

Kevin Brubeck Unhammer unhammer

kevin :: Coffee → Code
View GitHub Profile
(defvar-keymap embark-org-column-map
:doc "Keymap for Embark org-column actions."
:parent embark-org-table-map
"M-r" #'my-cua-enable-and-replace-in-rectangle-embark)
(defun my-embark-org-column-at-point ()
"Target the org-column at point."
(when-let ((org-column
(and (org-at-table-p)
(not (looking-at-p "|")) ; since then we don't know which column you mean
@unhammer
unhammer / speakersPerLanguage.sparql
Last active August 14, 2023 09:09
Number of speakers per language in the world based on Wikidata (including dupes due to measuring speakers at different times / from different sources). Note that 6915 languages have iso 639-3 codes in wikidata, but only 1614 languages have data for number of speakers (presumably the languages with no data are at the lower end of the list)
SELECT DISTINCT ?item ?numberOfSpeakers ?speakersTime ?iso639_1 ?iso639_3 ?itemLabel ?itemLabel_en
WHERE {
?item wdt:P31 wd:Q1288568; # Any instance of a modern (current use) language
wdt:P220 ?iso639_3; # that has an ISO 639-3 code
# Require number of speakers, but as a statement so we can get the "timestamp" of the property:
?item p:P1098 ?numberOfSpeakersStatement .
?numberOfSpeakersStatement ps:P1098 ?numberOfSpeakers.
optional {
?numberOfSpeakersStatement pq:P585 ?speakersTime.
@unhammer
unhammer / progress.sh
Last active April 13, 2023 14:41
Show progress of some command you forgot to pipe through pv
#!/bin/bash
### Save as "/usr/local/bin/progress" and chmod +x, then:
#
# $ progress ~/huge-file.tar.bz2
# $ progress -p $(pidof bzcat)
# $ progress # progress of all open files, shows e.g. how far mpd is through your song :P
#
# source: http://stackoverflow.com/a/238140/69663
@unhammer
unhammer / merlin-init.sh
Last active February 12, 2023 05:40
Create .merlin file for a project with all your ocamlfind packages and .opam sources in there
#!/bin/sh
if test -f .merlin; then
echo ".merlin already exists, bailing out ..." >&2
exit 1
else
# You could add your default EXT's and such to this list:
@unhammer
unhammer / html-parse-print.py
Created April 29, 2014 14:22
parse html, print it out as-is (python3 boilerplate for html template like stuff)
#!/usr/bin/python3
from html.parser import HTMLParser
from sys import stdin
def p(*value):
print(*value, end='')
class MyHTMLParser(HTMLParser):
def handle_startendtag(self, tag, attrs):
@unhammer
unhammer / mwdump-to-pandoc
Last active December 25, 2022 18:34
Turn wikipedia dumps into plaintext using pandoc
#!/bin/bash
declare OUTFORMAT=plain
set -e -u
run () {
local text=false
local -i i=0
local out
@unhammer
unhammer / .mbsyncrc
Last active December 4, 2022 06:41
isync + dovecot + gnus with Fastmail
IMAPAccount fastmail
Host imaps:mail.messagingengine.com
User me@fastmail.com
# you may have to tweak the awk here + filename to your netrc/authinfo:
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d $HOME/.netrc.gpg | awk '$2==\"mail.messagingengine.com\" && $4==\"me@fastmail.com\" {print $6;exit(0)}'"
Port 992
# Port 992 has a "flat" hierarchy; use with
# mail_location = maildir:~/.Maildir/:LAYOUT=fs:INBOX=~/.Maildir/INBOX
# in dovecot (see also MaildirStore.Inbox below)
@unhammer
unhammer / use_gold.sh
Last active June 3, 2022 02:31
Linking with lld on Ubuntu/Debian in CMake projects (or gold in automake projects)
sudo apt install binutils
cd ~/src/an_autotools_project
export CXXFLAGS='-fuse-ld=gold'
export CFLAGS='-fuse-ld=gold'
./configure
make -j4 # no longer wait for linking! =D
# gcc doesn't support -fuse-ld=lld http://gcc.gnu.org/ml/gcc-patches/2016-07/msg00145.html :(
@unhammer
unhammer / git-is-related
Last active April 5, 2022 08:08 — forked from simonwhitaker/git-is-ancestor
A script to determine whether one git commit is the ancestor of another
@unhammer
unhammer / window-toggle-decorations.py
Created February 13, 2012 08:55
toggle gtk window decorations
#! /usr/bin/python2
import gtk.gdk
w = gtk.gdk.window_foreign_new( gtk.gdk.get_default_root_window().property_get("_NET_ACTIVE_WINDOW")[2][0] )
w.set_decorations( (w.get_decorations()+1)%2 ) # toggle between 0 and 1
gtk.gdk.window_process_all_updates()
gtk.gdk.flush()
# now bind this to super-r or something