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 / pangrams.hs
Created August 28, 2015 14:17
find possible pangrams
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
import Data.List
import Data.List.Split
import System.Environment
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as TIO
-- assumes sorted input
@unhammer
unhammer / query-replace-matching-lines.el
Last active August 29, 2015 13:56
First ask for a regex of which lines to match, then do query-replace on only lines that match that regex, like sed '/lineregex/ s/foo/bar/g'
(defvar *query-replace-matching-lines-history* nil)
(defun query-replace-matching-lines-read-arg ()
(let* ((default (or (car *query-replace-matching-lines-history*)
"^"))
(input
(read-from-minibuffer
(concat "Line regexp"
(if default
(format " (default: %s): " (query-replace-descr default))
@unhammer
unhammer / sparse-random-lines.sh
Created February 12, 2014 13:10
For every PERIOD lines, output a random line from that set of lines
#!/bin/bash
set -e -u
if [[ $# -ne 1 ]];then
echo "Usage: $0 PERIOD"
echo "For every PERIOD lines, output a random line from that set of lines"
echo "E.g. printf '%s\n' {1..30} | $0 7"
echo "might output 5, 12, 19, 23 and 30."
exit 1
@unhammer
unhammer / apertium-ca.sh
Last active August 29, 2015 14:01
source this file; cd to apertium language pair / language dir by saying "ca some pair" or "ca somelang"
#!/bin/bash
# Save this file to e.g. ~/src/apertium-ca.sh, then put "source
# ~/src/apertium-ca.sh" in ~/.bashrc Now you can type "ca nno" to go
# to languages/apertium-nno and "ca kir kaz" to go to
# nursery/apertium-kaz-kir – even though it's in the other order
export APERTIUM_SVNROOT=$HOME/src/apertium
ca () {
(defvar-local dix-yas-key-rex ""
"Used by `dix-yas-update-key-rex' for caching the regex-opt of
possible snippet keys.")
(defvar-local dix-yas-key-rex-tables nil
"Used by `dix-yas-update-key-rex' for checking if we need to
update `dix-yas-key-rex'.")
(defun dix-yas-update-key-rex ()
"Update `dix-yas-key-rex', used by `dix-yas-skip-backwards-to-key'."
(let ((tables (yas--get-snippet-tables)))
(eval-after-load "company-ycmd-autoloads"
'(progn (company-ycmd-setup)))
(eval-after-load "ycmd-autoloads"
'(progn (require 'ycmd-next-error)
(set-variable 'ycmd-server-command '("python2" "/home/me/src/ycmd/ycmd/__main__.py")) ; doesn't understand '~'
(set-variable 'ycmd-global-config "/home/me/.emacs.d/.ycm_extra_conf.py")
(add-hook 'c-mode-common-hook 'ycmd-mode)
(add-hook 'c-mode-common-hook 'company-mode)
(add-hook 'python-mode-hook 'ycmd-mode)
@unhammer
unhammer / default-ssl.conf
Created November 24, 2014 14:40
config snippets for how to run ocsigen/eliom behind an ssl-enabled apache
# The apache server is SSL-enabled, passes requests that hit /thesubdir to localhost:8080 over http
ProxyPreserveHost On
ProxyRequests Off
<Location "/thesubdir">
ProxyPass http://0.0.0.0:8080/thesubdir
ProxyPassReverse http://0.0.0.0:8080/thesubdir
</Location>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Snåase - aktivyøki eatnaminie - Snåsa kommune
</title>
<link href="/nordtrondelag/snasa/snasak.nsf/cascadingstylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body bgcolor="#FFFFFF" class="innholdskolonne defaulttext" style="background-image:none" text="#000000">
<form action="">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Snåase - aktivyøki eatnaminie - Snåsa kommune
</title>
<link href="/nordtrondelag/snasa/snasak.nsf/cascadingstylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body bgcolor="#FFFFFF" class="innholdskolonne defaulttext" style="background-image:none" text="#000000">
<span><span>A</span></span>
@unhammer
unhammer / gt-corpus-xmldiff.sh
Created January 16, 2015 14:33
gt-corpus-xmldiff.sh prev-converted/ new-converted/
#!/bin/sh
set -u
c14n_sort ()
{
# The order of <parallel_text> elements does not matter. Assuming
# input has been through c14n, we can just sort those lines.
awk '
/<version>XSLtemplate/{next}