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 / Words.hs
Created Dec 14, 2020
Data.Algorithm.Diff.Words extension to Diff package
View Words.hs
-----------------------------------------------------------------------------
-- |
-- 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 Dec 8, 2020 — forked from queertypes/Pascal.hs
Pascal's triangle in Haskell
View Pascal.hs
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 / .tmux.conf
Last active Nov 2, 2020
tmux double-click menu with "open in emacs" item
View .tmux.conf
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
View test.html
<html>
<head>
<style>
h1 {
font-family: Verdana;
}
</style>
</head>
<body>
<h1>RAWR</h1>
View test.md

blah

stuff!

code:

{
  "foo": "bar"
}
@unhammer
unhammer / wp-email-validate-check.php
Created Mar 17, 2020 — forked from yolabingo/wp-email-validate-check.php
Test Wordpress email validation regular expression
View wp-email-validate-check.php
<?php
/*
When using a current PHP version, class-phpmailer.php:validateAddress() uses a complex regex ("pcre8") for email address validation.
PHP < 7.3 uses libpcre 8.x.
PHP 7.3 uses libpcre2 10.x.
Due to a bug in libpcre2 < 10.32-RC1 https://bugs.exim.org/show_bug.cgi?id=2300,
this email regex validation fails in PHP 7.3 with PCRE_VERSION < 10.32.
@unhammer
unhammer / install-mssql-ubuntu.sh
Created Nov 21, 2019
Fix mssql package for Ubuntu 19.10
View install-mssql-ubuntu.sh
#!/bin/bash
# https://askubuntu.com/a/1033956/25639
set -e -u
wget -qO- https://packages.microsoft.com/keys/microsoft.asc \
| sudo apt-key add -
echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017 xenial main' \
| sudo tee /etc/apt/sources.list.d/mssql-server.list
@unhammer
unhammer / vddiff
Last active Dec 14, 2019
little wrapper around `vd --diff` to get diff's -U option, since vd doesn't have a "go to next difference" feature ( https://github.com/saulpw/visidata/issues/303 )
View vddiff
#!/bin/bash
# Usage:
# $ vddiff -U4 before after -ftsv
# You can toggle between the before/after sheets with Ctrl-^
# If you keyboard layout makes that impossible to type, add an
# alternative binding to your ~/.visidatarc, e.g.
# bindkey("ø", "prev-sheet")
@unhammer
unhammer / showpage.js
Created Sep 27, 2019
Right next to your address bar, make a "New bookmark" with this in, now you can easily remove all those header/footer bars that block your content
View showpage.js
javascript:(function()%7B(function%20()%20%7Bvar%20i%2C%20elements%20%3D%20document.querySelectorAll('body%20*')%3Bfor%20(i%20%3D%200%3B%20i%20<%20elements.length%3B%20i%2B%2B)%20%7Bif%20(getComputedStyle(elements%5Bi%5D).position%20%3D%3D%3D%20'fixed')%20%7Belements%5Bi%5D.parentNode.removeChild(elements%5Bi%5D)%3B%7D%7D%7D)()%7D)()
View ical2org.awk
#!/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!