Skip to content

Instantly share code, notes, and snippets.

Avatar
kevin :: Coffee → Code

Kevin Brubeck Unhammer unhammer

kevin :: Coffee → Code
View GitHub Profile
@unhammer
unhammer / pangrams.hs
Created Aug 28, 2015
find possible pangrams
View pangrams.hs
{-# 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 Aug 29, 2015
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'
View query-replace-matching-lines.el
(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 Feb 12, 2014
For every PERIOD lines, output a random line from that set of lines
View sparse-random-lines.sh
#!/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 / html-parse-print.py
Created Apr 29, 2014
parse html, print it out as-is (python3 boilerplate for html template like stuff)
View html-parse-print.py
#!/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 / apertium-ca.sh
Last active Aug 29, 2015
source this file; cd to apertium language pair / language dir by saying "ca some pair" or "ca somelang"
View apertium-ca.sh
#!/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 () {
View dix-yas.el
(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)))
View init-ycmd.el
(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 Nov 24, 2014
config snippets for how to run ocsigen/eliom behind an ssl-enabled apache
View default-ssl.conf
# 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>
View empty_on_xml_output.html
<!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="">
View big_nesty_but_works.html
<!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>