Skip to content

Instantly share code, notes, and snippets.

View phi-gamma's full-sized avatar
💤
Does nothing unless polled.

Philipp Gesang phi-gamma

💤
Does nothing unless polled.
View GitHub Profile
@phi-gamma
phi-gamma / word_count.lua
Created May 6, 2012 13:03
Word count with LuaTEX
packagedata = packagedata or { } -- namespace proposal for packages
local word_count = { threshold = 3, }
packagedata.word_count = packagedata.word_count or word_count
dofile(kpse.find_file"char-def.lua") -- unicode tables
dofile(kpse.find_file"lualibs-table.lua") -- old Context table code
local utf = unicode.utf8
local node = node
local type = type
@phi-gamma
phi-gamma / features.wiki
Created June 16, 2012 13:02
it’s not a bug, it’s a feature! -- section for the ConTeXt wiki

If ConTeXt appears to behave in a counterintuitive way, chances are that it’s actually your intuitions that lack calibration.

Controlling Page Break Before Headings

If you add the option page=yes to a heading setup, this will cause ConTeXt to break the page. Ordinarily this works as expected, unless, however, the heading immediately follows a previous section with no text in between. The rationale behind this is that consecutive headings are conceived of collectively as one single structural element.

points:
exact answer: 5
time: 1
location: 1
culture: 1
players: p a
score:
@phi-gamma
phi-gamma / Makefile
Last active July 7, 2017 18:20 — forked from brentp/Makefile
lua binary module example
LUA_CFLAGS=-I/usr/include/lua
LUA_CFLAGS+=-Wall -Werror
all: stringext.so
stringext.so: stringext.c
$(CC) $(LUA_CFLAGS) -O3 -fPIC -o stringext.o -c stringext.c
$(CC) -shared -O3 stringext.o -o stringext.so
clean:
@phi-gamma
phi-gamma / -
Created January 29, 2017 16:37
fontforge -script ./outlines.py
#!/usr/bin/env texlua
local stringformat = string.format
local texprint = tex.print
local stringgsub = string.gsub
local stringrep = string.rep
package.path = "/usr/share/lua/5.2/?.lua;/usr/share/lua/5.2/?/init.lua"
package.cpath = "/usr/lib/lua/5.2/?.so"
>>> processing slovakia-slovenia.dat
>>> language data : 54
>>> greatest distance : 6 (language[s]: uk)
>>> mean distance : 2.8
>>> median distance : 3.0
>>> standard deviation : 1.020
>>> #0, line #7: “cs” “Slovensko” “Slovinsko” → δ=1 scaled=(0.167 84 0x54)
>>> #1, line #47: “sk” “Slovensko” “Slovinsko” → δ=1 scaled=(0.167 84 0x54)
>>> #2, line #1: “be” “Славакія” “Славенія” → δ=2 scaled=(0.333 105 0x69)
>>> #3, line #2: “bg” “Словакия” “Словения” → δ=2 scaled=(0.333 105 0x69)
@phi-gamma
phi-gamma / beegradients.lua
Last active September 28, 2016 06:06
bee gradients for TeX documents: http://tex.stackexchange.com/q/131883/14066
packagedata = packagedata or { }
packagedata.beegradients = { }
local beegradients = packagedata.beegradients
local processorid = "beegradients" --- name of callback
local err, warn, info
if luatexbase then
err, warn, info = luatexbase.provides_module {
name = "beegradients",
@phi-gamma
phi-gamma / prs.lua
Last active January 25, 2016 06:34
making sense of a windows registy dump
#!/usr/bin/env texlua
kpse.set_program_name "luatex"
require "lualibs"
local rawset = rawset
local lpeg = require "lpeg"
local P, R, S = lpeg.P, lpeg.R, lpeg.S
local lpegmatch = lpeg.match
local C, Cc, Cf = lpeg.C, lpeg.Cc, lpeg.Cf
local Cg, Cmt, Cs, Ct = lpeg.Cg, lpeg.Cmt, lpeg.Cs, lpeg.Ct
@phi-gamma
phi-gamma / someinputfile.tex
Last active December 24, 2015 04:49
Collecting info about tokens with Luatex (http://tex.stackexchange.com/q/135319/14066)
current file: \printcurrentfile, line \printcurrentpos \par
This token is going to be listed: \collecttoken \jobname %% collect “\jobname”