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
@unhammer
unhammer / my-travis-read-log.el
Last active September 17, 2017 07:29
Retrieve Travis log from URL and render nicely.
(defun my-travis-read-log (url)
"Retrieve Travis log from URL and render nicely."
(interactive (list (read-string "URL: " nil nil (eww-suggested-uris))))
(let ((url (replace-regexp-in-string "^https://travis-ci.org/\\([^/]+\\)/\\([^/]+\\)/jobs/\\([0-9]+\\)"
"https://api.travis-ci.org/jobs/\\3/log.txt?deansi=true"
url)))
(pop-to-buffer-same-window (get-buffer-create "*travis*"))
(eww-setup-buffer)
(plist-put eww-data :url url)
(plist-put eww-data :title "")
@unhammer
unhammer / git-spark
Last active June 27, 2017 08:49
`git-spark-score 80` # sparklines 80 days back for all branches (remember to `git fetch` all your remotes first)
#!/bin/bash
set -e -u
if [[ $# -ge 1 ]]; then
author="$1"
else
author="$(git config user.email)"
fi
cd apertium-en-es
curl https://raw.githubusercontent.com/goavki/streamparser/master/streamparser.py >streamparser.py
# put the files of this gist in cwd
sh run.sh < sonnet17.xml
@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 / .bash_profile_tmux_history
Created April 19, 2017 08:15
put in bashrc/bash_profile to get separate bash histories per tmux session
#!/bin/bash
export TMUX_SESSION=
if [[ -n ${TMUX+set} ]]; then
TMUX_SESSION=$(tmux display-message -p "#S")
# can end up wrong if I move a pane to a different session, but I rarely do that
if [[ -n ${TMUX_SESSION+set} ]]; then
[[ -d ~/.bash_history.d ]] || mkdir -p ~/.bash_history.d
export HISTFILE="$HOME/.bash_history.d/${TMUX_SESSION}"
[[ -f $HISTFILE ]] || cp "$HOME"/.bash_history "$HISTFILE"
@unhammer
unhammer / create-loopback-btrfs.sh
Created December 29, 2016 09:38
Making a loopback virtual filesystem under e.g. a FAT-formatted SD-card
# Don't just run this script, but check each command to fix paths etc.
# The dd does not need sudo (and becomes more dangerous with sudo ...)
# This creates an empty file 1GB large to hold your filesystem:
dd if=/dev/zero of=/path/to/sd-card/vfs bs=1024 count=1024000
# Should gives something like:
@unhammer
unhammer / syncthing-foldericons
Last active December 19, 2016 10:11
on-login-script to make a link to Syncthing GUI from each synced folder, with icon showing sync-status
#!/bin/bash
set -u
# Put "st-state.desktop" in .stignore, then run this on login.
# Requires xmllint and wget; uses config.xml to find GUI address,
# apikey and folders (so that we can change folder icons even if
# syncthing is down)
@unhammer
unhammer / cpulimit-unless-raised
Last active November 10, 2016 09:13
Throttle CPU of, say, firefox when it's not raised. Requires cpulimit (and xprop, pgrep, but these are typically installed)
#!/bin/bash
set -e -u
target="$1"
get_wpid() {
wid="$(xprop -root _NET_ACTIVE_WINDOW | grep -o '0x[^, ]\{7,\}' )" || return 1
xprop -id "${wid}" _NET_WM_PID | grep -o '[0-9]\{1,\}'
}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module OurUsers where
import Control.Monad.Logger (runNoLoggingT)
import qualified Data.Text as T
import GHC.Generics
@unhammer
unhammer / init-haskell.el
Created June 16, 2016 08:54
some emacs haskell configs
(use-package evil-leader
;; needs to be enabled before M-x evil-mode!
:ensure t
:config
(evil-leader/set-leader ",")
(evil-leader/set-key-for-mode #'haskell-mode
"t" #'intero-type-at ; was: haskell-mode-show-type-at
"T" #'intero-info ; was: haskell-doc-show-type
"I" #'haskell-do-info