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 / signal
Last active February 21, 2022 20:04
Launch Signal if not running, otherwise toggle hidden/shown state. Put signal.desktop in ~/.config/autostart/.
#!/bin/bash
run () {
signal-desktop &
disown
}
show () {
local -r id="$1"
idx="$(printf "0x%08x" "${id}")"
@unhammer
unhammer / Adder.hs
Created November 24, 2021 20:04 — forked from mtolly/Adder.hs
Small example of compiling a Haskell Mac .dylib to be used from C
{-# LANGUAGE ForeignFunctionInterface #-}
module Adder where
import Foreign.C
adder :: CInt -> CInt -> IO CInt
adder x y = return $ x + y
foreign export ccall adder :: CInt -> CInt -> IO CInt
#!/usr/bin/gawk -f
# awk script for converting an iCal formatted file to a sequence of org-mode headings.
# this may not work in general but seems to work for day and timed events from Google's
# calendar, which is really all I need right now...
#
# usage:
# awk -f THISFILE < icalinputfile.ics > orgmodeentries.org
#
# Note: change org meta information generated below for author and
# email entries!
@unhammer
unhammer / intervec.py
Last active July 27, 2021 15:59
Multilingual word vectors for SpaCy (based on https://github.com/Babylonpartners/fastText_multilingual )
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# A SpaCy implementation of
# https://github.com/Babylonpartners/fastText_multilingual
#
# heavily based on
# https://github.com/Babylonpartners/fastText_multilingual/blob/master/align_your_own.ipynb
import numpy as np
@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
@unhammer
unhammer / Words.hs
Created December 14, 2020 08:55
Data.Algorithm.Diff.Words extension to Diff package
-----------------------------------------------------------------------------
-- |
-- Module : Data.Algorithm.Diff.Words
-- Copyright : (c) Kevin Brubeck Unhammer 2020
-- License : BSD 3 Clause
-- Maintainer : s.clover@gmail.com
-- Stability : experimental
-- Portability : portable
--
-- Convenience functions for "word-diffing" / grouping diffs by separators.
@unhammer
unhammer / Pascal.hs
Last active December 8, 2020 13:52 — forked from queertypes/Pascal.hs
Pascal's triangle in Haskell
import Control.Applicative ((<$>))
center :: String -> Int -> String
center s n = spaces ++ s ++ spaces
where spaces = replicate ((n - length s) `div` 2) ' '
-- http://www.haskell.org/haskellwiki/Blow_your_mind, Ctrl-F "pascal"
pascal :: [[Int]]
pascal = iterate (\row -> zipWith (+) ([0] ++ row) (row ++ [0])) [1]
@unhammer
unhammer / apertium-xsel
Last active November 9, 2020 12:49
Bind "/path/to/apertium-xsel" and "/path/to/apertium-xsel prev" to some global shortcut key, and get apertium translation on whatever you've selected with your mouse (if it's an URL, then it'll download the page, translate it and open that). The one with the "prev" argument will use your most recently used language pair, the other one pops up a …
#!/bin/bash
# This file gives you apertium translation on whatever you've selected
# with your mouse. When called with "prev" as an argument, it will use
# your most recently used language pair, without it will pop up a
# picker. It only uses installed pairs, ie. the ones listed by
# "apertium -l".
# Install dependencies on Debian/Ubuntu:
# $ sudo apt-get install xsel zenity
@unhammer
unhammer / .tmux.conf
Last active November 2, 2020 09:14
tmux double-click menu with "open in emacs" item
bind-key -T root DoubleClick1Pane if-shell -F -t = "#{||:#{mouse_any_flag},#{pane_in_mode}}" "select-pane -t=; send-keys -M" "display-menu -t= -xM -yM -T \"#[align=centre]#{pane_index} (#{pane_id})\" 'Open in Emacs' 'e' {run 'cd \"#{pane_current_path}\" && ~/bin/switch-to-emacsclient \"#{q:mouse_word}\"'} '' '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {copy-mode -t=; send -Xt= search-backward \"#{q:mouse_word}\"} '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {send-keys -l -- \"#{q:mouse_word}\"} '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {set-buffer -- \"#{q:mouse_word}\"} '#{?mouse_line,Copy Line,}' 'l' {set-buffer -- \"#{q:mouse_line}\"} '' 'Horizontal Split' 'h' {split-window -h} 'Vertical Split' 'v' {split-window -v} '' 'Swap Up' 'u' {swap-pane -U} 'Swap Down' 'd' {swap-pane -D} '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane} '' '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m} '#{?wind