Skip to content

Instantly share code, notes, and snippets.

View matze's full-sized avatar

Matthias Vogelgesang matze

View GitHub Profile
@matze
matze / ditaa.rb
Created August 25, 2012 18:58
Ditaa plugin for Jekyll
require 'fileutils'
module Jekyll
class DitaaBlock < Liquid::Block
def initialize(tag_name, markup, tokens)
super
end
def render(context)
File.open('/tmp/ditaa.txt', 'w') {|f| f.write(super)}
@matze
matze / ti
Created September 24, 2012 18:04
TicGit bash completion, originally by Nick Anderson
# Author: Nick Anderson (http://www.cmdln.org)
# Contributions: Matthias Vogelgesang (http://bloerg.net)
# Description: Simple Bash Completion for ticgit
_ti()
{
local cur prev opts state_opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="assign checkout comment list new points recent show state sync tag"
@matze
matze / sorted-and-filtered-tree-view.c
Created October 22, 2012 20:33
A sorted and a filtered Gtk+ tree view
#include <gtk/gtk.h>
enum
{
COLUMN_ARTICLE = 0,
COLUMN_PRICE,
N_COLUMNS
};
typedef struct
@matze
matze / Makefile
Created December 3, 2012 11:45
Pandoc template
TEMPLATE = template.tex
STYLESHEET = style.css
MD = $(wildcard *.md)
TEX = $(patsubst %.md,%.tex,$(MD))
HTML = $(patsubst %.md,%.html,$(MD))
PDF = $(patsubst %.md,%.pdf,$(MD))
.PHONY: clean pdf html
all: pdf html
@matze
matze / Makefile
Last active December 11, 2015 19:19
Template for C project Makefile
PKGS = glib-2.0
SRC = $(wildcard *.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
BIN = foo
CFLAGS := $(CFLAGS) $(shell pkg-config --cflags $(PKGS))
LDFLAGS := $(LDFLAGS) $(shell pkg-config --libs $(PKGS))
.PHONY: clean
$(BIN): $(OBJ)
@matze
matze / mdconv.rb
Created March 3, 2013 09:32
Improved HTML output with Typogruby
require 'typogruby'
module Jekyll
class MarkdownConverter < Jekyll::Converter
def convert(content)
setup
return Typogruby.improve(Maruku.new(content).to_html)
end
end
end
@matze
matze / gist:5325713
Last active December 14, 2016 21:55
promise decorator to resolve future arguments
from concurrent.futures import Future, ThreadPoolExecutor
class promise(object):
executor = ThreadPoolExecutor(max_workers=100)
def __init__(self, func):
self.func = func
@matze
matze / Makefile
Created June 28, 2013 15:20
rubber-based LaTeX compilation Makefile
SRC=$(wildcard *.tex)
OPTS=--pdf
.PHONY: clean
all: $(patsubst %.tex,%.pdf,$(SRC))
%.pdf: %.tex
@rubber $(OPTS) $<
@matze
matze / gist:5919701
Created July 3, 2013 15:55
Diff two texts and markup result with <del> and <ins>.
# -*- coding: utf-8 -*-
import re
import difflib
import codecs
from itertools import chain
_diff_split_re = re.compile(r'(\s+)(?u)')
@matze
matze / gist:6606560
Created September 18, 2013 09:07
Co-routine example with multicast
def coroutine(func):
def start(*args, **kwargs):
g = func(*args, **kwargs)
g.next()
return g
return start
def produce(consumer):
for item in (1,2,3,4):