Skip to content

Instantly share code, notes, and snippets.


Phillip Berndt phillipberndt

View GitHub Profile
phillipberndt /
Created Aug 18, 2014
Cython test (For SO question 25141838)
#!/usr/bin/env python
from distutils.core import setup
from Cython.Build import cythonize
ext_modules = cythonize("test.pyx")
phillipberndt / magic.jl
Last active Aug 29, 2015
Magic squares in Julia
View magic.jl
# These are possibly naïve implementations of magic squares generation
# for a micro-benchmark to compare Julia to Python and Matlab
function magic_matlab(n::Int64)
# Works exactly as Matlab's magic.m
if n % 2 == 1
p = (1:n)
M = n * mod(broadcast(+, p', p - div(n+3, 2)), n) + mod(broadcast(+, p', 2p - 2), n) + 1
View magic.jl
function magic!(M::Array{Int}, n::Int)
# Fast magic square generation
if n % 2 == 1
# Odd-order magic square
# Algorithm:
ndiv2 = div(n, 2);
for I = 1:n
phillipberndt /
Last active Aug 29, 2015
Check if an elf file has superflous dependencies
#!/usr/bin/env python
A quick & dirty replacement for dpkg-shlibdeps
Written to check if pqiv uses any unnecessary depencencies. dpkg-shlibdeps
claims that this was the case and I wanted to check.
import functools
import multiprocessing.pool
import os
phillipberndt /
Created Jan 23, 2015
Build binaries of all xrandr versions
git clone || exit 1
cd xrandr || exit 1
for TAG in $(git tag | grep "^xrandr-"); do
git reset --hard HEAD
git clean -fx
git checkout $TAG
grep -vE "(m4_ifndef|m4_fatal|XORG_MACROS_VERSION)" >
phillipberndt / 0autorandr_test_env_readme
Last active Aug 29, 2015
autorandr test environment
View 0autorandr_test_env_readme
This is a small test environment for autorandr, that can be added as a
pre-commit git hook in local copies of the repository.
Run `` to build all xrandr versions and generate fixtures.
Fixtures are a set of two files, FOO.version and FOO.verbose, that are the output
of `xrandr -v` and `xrandr --verbose -q`. You can also write more elaborate
tests by placing a script into the dynamic/ subfolder. It will be executed instead
of xrandr by tests.
View bionic-libc-lookup-times.diff
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
index 2612d6a..277afb0 100644
--- a/libc/dns/net/getaddrinfo.c
+++ b/libc/dns/net/getaddrinfo.c
@@ -80,6 +80,7 @@
#include <fcntl.h>
#include <sys/cdefs.h>
#include <sys/types.h>
+#include <time.h>
#include <sys/stat.h>
phillipberndt / autorandr.patch
Created May 18, 2015
autorandr patch to show DPI
View autorandr.patch
diff --git a/ b/
index 19722c9..6df9d9b 100755
--- a/
+++ b/
@@ -129,7 +129,8 @@ class XrandrOutput(object):
(?P<rotate>(?:normal|left|right|inverted))\s+ # Rotation
(?:(?P<reflect>X\ and\ Y|X|Y)\ axis)? # Reflection
)? # .. but everything of the above only if the screen is in use.
- (?:[\ \t]*\([^\)]+\))(?:\s*[0-9]+mm\sx\s[0-9]+mm)?
+ (?:[\ \t]*\([^\)]+\))\s*
View gtktextbuffer-markup-bug.c
#include <gtk/gtk.h>
void main() {
GtkTextIter start, end, inspos, tagpos;
gsize length;
GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);
GtkTextTag *tag1 = gtk_text_buffer_create_tag(buffer, "tagone", NULL);
GtkTextTag *tag2 = gtk_text_buffer_create_tag(buffer, "tagtwo", NULL);
View randr.c
* This file generated automatically from randr.xml by
* Edit at your peril.
#include "config.h"
#include <stdlib.h>
#include <string.h>