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 / git-is-related
Last active April 5, 2022 08:08 — forked from simonwhitaker/git-is-ancestor
A script to determine whether one git commit is the ancestor of another
@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
@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 / wp-email-validate-check.php
Created March 17, 2020 08:57 — forked from yolabingo/wp-email-validate-check.php
Test Wordpress email validation regular expression
<?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 / IDLE with asyncio + imaplib + mbsyncrc
Created September 12, 2019 07:43 — forked from boris-arzur/IDLE with asyncio + imaplib + mbsyncrc
I use a mail stack based on mbsync & notmuch. I want to run mbsync on new mails. IDLE allows watching efficiently one folder in my mailbox. Async makes is easy to watch a few connections.
#!python3
import imaplib
import os
import asyncio
loop = asyncio.get_event_loop()
conf = [x.strip().split() for x in open('mbsyncrc')]
# let pred =
Array.init 100 (fun r ->
let a = n1 () in
let b = n1 () in
let c = a +. b in (* Makes the third column/predictor redundant and our data collinear! *)
[|a;b;c|]) ;;
val pred : float array array =
[|[|2.1000; 0.9001; 3.0001|]; [|1.7343; 2.9934; 4.7277|]; [|2.7644; 4.0290; 6.7935|];
[|0.7972; 2.6754; 3.4726|]; [|0.6089; 2.7250; 3.3340|]; [|0.7870; 2.7721; 3.5592|];
...|]
@unhammer
unhammer / README.md
Created October 1, 2012 13:29 — forked from mbostock/.block
pan on drag with d3

pan using zoom behaviour, unfortunately not very smooth

@unhammer
unhammer / stdin.sh
Created May 29, 2012 20:39 — forked from anonymous/stdin.sh
fast-user-switch for kdm
#!/bin/bash
set -f # no globbing, so we can safely use *
# other_local[joe]=:0, other_local[bob]=:1 etc. for all active local
# users other than us:
unset other_local; declare -A other_local;
while read -rd $'\t'; do
IFS=$',\n' r=($REPLY)
[[ "${#r[@]}" -ge 4 && "${r[4]}" != '*' && "${r[2]}" != '' && "${r[0]}" != '' ]] && other_local[${r[2]}]=${r[0]}