Skip to content

Instantly share code, notes, and snippets.

David Michael Barr barrbrain

Block or report user

Report or block barrbrain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@barrbrain
barrbrain / xwn2dict.py
Last active Aug 29, 2015
Generate English vocabulary guide from eXtended WordNet; requires python-igraph
View xwn2dict.py
#!/usr/bin/python
import xml.sax
from igraph import Graph
from collections import defaultdict
class XWN( xml.sax.ContentHandler ):
def __init__(self):
self.graph = Graph(directed = True)
self.synSets = []
self.currentTag = ""
@barrbrain
barrbrain / header.bin
Created Mar 15, 2011
Simple XML record stream processor. Uses node-binary, node-postgres and xml2js-expat.
@barrbrain
barrbrain / mergesort.hs
Created Mar 18, 2011
An attempt at an bottom-up functional representation of mergesort
View mergesort.hs
import Control.Arrow
import Data.List
import Data.Function
main = interact (show.(mergeSort (<=)).head.lines)
merge :: (a -> a -> Bool) -> [a] -> [a] -> [a]
merge _ xs [] = xs
merge _ [] ys = ys
merge p (x:xs) (y:ys) =
@barrbrain
barrbrain / packsize.sh
Created Mar 13, 2012
A script to calculate a push strategy for a ref, given a pack size limit.
View packsize.sh
#!/bin/bash
LIMIT=$1
TIP=$2
BS=$(( 64 * 1024 ))
COUNT=$(( ( $LIMIT ) / $BS ))
packsize() {
COMMITS=$1
ENDPOINT=$TOP
@barrbrain
barrbrain / fmix32.c
Last active Oct 14, 2015
SSE4.2 implementation of David Barr's similarity hash
View fmix32.c
/* See https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
for original plain C/C++ implementation */
/* build with -msse4.2 */
#include <smmintrin.h>
#include <emmintrin.h>
FORCE_INLINE fmix32_m128i ( __m128i h )
{
@barrbrain
barrbrain / PSNR-CIE76.bash
Last active Oct 31, 2015
Calculate PSNR with CIE76 difference method
View PSNR-CIE76.bash
#!/bin/bash
# REQUIRES imagemagick compiled with HDRI feature enabled
SIZE=$(head -n1 "$1" | sed -E 's/.*W([0-9]*) H([0-9]*).*/\1x\2/')
FMT="-size $SIZE -depth 8 -sampling-factor 4:2:0 -interlace plane -set colorspace Rec709YCbCr"
convert $FMT YUV:<(tail -n+3<"$1") YUV:<(tail -n+3<"$2") \
-colorspace Lab -compose difference \
-composite -evaluate Pow 2 -separate -evaluate-sequence Add \
-filter box -resize 1x1\! -format "%[fx:-10*log(u)]\n" info:
@barrbrain
barrbrain / generate_table.py
Created Nov 6, 2015
Chroma quantization curve table generation for Daala
View generate_table.py
import math
P = 2.25
def quant(cq): return math.trunc(math.exp((cq-6.235)*.10989525)*16.0)
def curve(cq): return quant(cq-math.pow(cq-1,P)/(2.0*P*math.pow(62.0,P-1)))
print(', '.join(['0x%04X' % n for n in [0] + [curve(cq) for cq in range(1,64)]]))
@barrbrain
barrbrain / visualize_quality_curve.sh
Last active Nov 30, 2015
Script to render a video of quantization effects in daala
View visualize_quality_curve.sh
#!/bin/bash
readlinkf(){ perl -MCwd -e 'print Cwd::abs_path shift' "$1";}
DAALA_ROOT="$(readlinkf ${DAALA_ROOT:-.})"
INPUT_IMAGE="$(readlinkf $1)"
OUTPUT_VIDEO="$(readlinkf ${2:-$(basename "$INPUT_IMAGE").webm})"
cq="0 1 2 3 4 5 7 9 11 13 16 19 22 25 28 33 38 44 50 57 64 73 82 92 104 117 132 148 166 187 209 235 263 295 330 369 413 462"
P=${P:-4}
(
cd /tmp
FIFOS="`echo -n $cq|sed 's/[0-9][0-9]*/&.y4m/g'`"
@barrbrain
barrbrain / analyze_ciede2000.py
Last active Dec 4, 2015
Color Image Quality Assessment Based on CIEDE2000, Yang Yang, Jun Ming and Nenghai Yu, 2012
View analyze_ciede2000.py
#!/usr/bin/env python3.4
from collections import deque
import sys
import numpy as np
from skimage import color
import random
from scipy import ndimage
# Assuming BT.709
yuv2rgb = np.array([
View .gitconfig
[url "https://github.com/"]
insteadof = git@github.com:
You can’t perform that action at this time.