Skip to content

Instantly share code, notes, and snippets.

View mpg's full-sized avatar

Manuel Pégourié-Gonnard mpg

View GitHub Profile
@mpg
mpg / aesni.c
Created April 26, 2014 15:25
Using PolarSSL's AES-NI module with "old" assemblers
/*
* AES-NI support functions
*
* Copyright (C) 2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
*
* All rights reserved.
*
@mpg
mpg / keyparse.c
Created March 28, 2014 09:37
Parsing an EC key using secp256k1 and SpecifiedECDomain
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <polarssl/pk.h>
/* Initialise DER encoded key string*/
const char privkey_str[] = "3081d302010104208ea106a78201d7bfc11af5c9230803db1eb104e0a4f47fa3af4a23a785584206a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220002a6ce40504bd48f6e71eaa27784705ba457463fb3b746e881350a09af2b850afc";
bool decode_hex(unsigned char *p, size_t max_len, const char *hexstr, size_t *out_len_)
{
@mpg
mpg / pdfdiff.sh
Created October 15, 2012 19:31
diff of multipage pdfs using imagemagick and pdftk
#!/bin/bash
# visual diff of two pdfs
#
# inspired by:
# http://usakuv.blogspot.fr/2011/05/visual-diff-for-pdf-files.html
# https://docs.google.com/document/pub?id=10GBd9u4e-NwNCd-4t4hb9rcdKJlFFhkkq-b_ezzg73c
print_help() {
echo "Usage: $0 a.pdf b.pdf diff.pdf" >&2
@mpg
mpg / biglumber-sort.py
Created July 18, 2012 15:46
biglumber-sort - sort keys from a biglumber page by mean shortest distance
#!/usr/bin/python -tt
# coding: utf-8
# Manuel Pégourié-Gonnard, 2012. WTFPL v2.
"""
biglumber-sort - sort keys from a biglumber page by mean shortest distance
Example:
biglumber-sort 'http://biglumber.com/x/web?sc=Paris'
@mpg
mpg / etcorphan.pl
Created August 12, 2011 20:49
list files in /etc not belonging to an installed Debian package
#!/usr/bin/perl
# etcorphan - list files in /etc not belonging to an installed Debian package
#
# Usage: etcorphan [ exclude_file... ]
#
# A lot of files don't formally belong to any package (eg because they are
# generated by an installation script) but are legitimate. You may want to
# ignore those files. The exclude files indicated on the command line use
# basically the same format as gitignore: one pattern per linei (supported
@mpg
mpg / cleanup_ext_links.user.js
Created May 7, 2011 18:49
"Clean up external links" user script for Greasemonkey
@mpg
mpg / distsel.lua
Created February 17, 2011 14:58
start a cmd.exe windows with another TeX distro activated
-- distsel.lua: start a cmd.exe windows with another TeX distro activated
-- Manuel Pégourié-Gonnard, 2010. WTFPL v2.
local usage = [[texlua c:\path\to\distsel.lua DistName C:\path\to\distro]]
-- arguments
if not arg[2] then
io.stderr:write('Usage: ' .. usage)
os.exit(1)
end
@mpg
mpg / enable-local-fonts
Created August 6, 2010 22:37
Enable fonts from texmf-local using updmap-sys --enable Map
#!/bin/sh
# Enable fonts from texmf-local using updmap-sys --enable Map
#
# Manuel Pégourié-Gonnard, 2010; WTFPL v2.
find -H `kpsewhich --var-value TEXMFLOCAL` -name '*.map' | while read file
do
updmap-sys --nohash --nomkmap --enable Map `basename $file`
done
@mpg
mpg / git-split.sh
Created June 29, 2009 16:56
Split a git repo in multiple repositories, one per top-level directory.
#!/bin/sh
# Split a git repo in multiple repositories, one per top-level directory.
#
# assume there are no spaces in dir names etc.
# assume the git repo is in the working directory
# Manuel Pégourié-Gonnard, 2009, WTFPLv2.
# This is gist #137698 <http://gist.github.com/137698>
@mpg
mpg / validate-utf8.lua
Created March 10, 2009 21:05
A simple UTF-8 validator in (tex)lua
#!/usr/bin/env texlua
-- A simple UTF-8 validator in Lua. (Tested only with texlua.)
-- Manuel Pégourié-Gonnard, 2009, WTFPL v2.
-- returns true if s is a valid utf-8 sequence according to rfc3629
function is_valid_utf8(str)
local len = string.len(str)
local not_cont = function(b) return b == nil or b < 128 or b >= 192 end
local i = 0