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 / 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 / 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 / IDLE with asyncio + imaplib + mbsyncrc
Created Sep 12, 2019 — 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.
View IDLE with asyncio + imaplib + mbsyncrc
#!python3
import imaplib
import os
import asyncio
loop = asyncio.get_event_loop()
conf = [x.strip().split() for x in open('mbsyncrc')]
View collinear_example.ml
# 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 Oct 1, 2012 — forked from mbostock/.block
pan on drag with d3
View README.md

pan using zoom behaviour, unfortunately not very smooth

@unhammer
unhammer / stdin.sh
Created May 29, 2012 — forked from anonymous/stdin.sh
fast-user-switch for kdm
View stdin.sh
#!/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]}