This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef __cplusplus | |
| #define _GNU_SOURCE | |
| #endif | |
| // C standard library | |
| #include <assert.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \startMPpage | |
| vardef star(expr r) = | |
| save x, y ; | |
| z1 = (r*cosd(90+0*360/5),r*sind(90+0*360/5)) ; | |
| z2 = (r*cosd(90+1*360/5),r*sind(90+1*360/5)) ; | |
| z3 = (r*cosd(90+2*360/5),r*sind(90+2*360/5)) ; | |
| z4 = (r*cosd(90+3*360/5),r*sind(90+3*360/5)) ; | |
| z5 = (r*cosd(90+4*360/5),r*sind(90+4*360/5)) ; | |
| z1 -- z3 -- z5 -- z2 -- z4 -- cycle | |
| enddef ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This program reimplements the GNU glibc random number generator. | |
| https://www.mathstat.dal.ca/~selinger/random/ | |
| https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=stdlib/random_r.c | |
| */ | |
| #include <assert.h> | |
| #include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local lpeg = assert(require("lpeg")) | |
| local C, Cf, Cg, Ct, P, R, S, V = | |
| lpeg.C, lpeg.Cf, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.R, lpeg.S, lpeg.V | |
| -- number parsing | |
| local digit = R"09" | |
| local dot = P"." | |
| local eE = S"eE" | |
| local sign = S"+-"^-1 | |
| local mantissa = digit^1 * dot * digit^0 + dot * digit^1 + digit^1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \usepackage{fontspec} | |
| \usepackage{luacode} | |
| \usepackage{xcolor} | |
| \begin{luacode*} | |
| local byte = string.byte | |
| fonts.expansions.setups['quality'] = { | |
| stretch = 2, shrink = 2, step = .5, factor = 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \ifcsname ProvidesPackage\endcsname | |
| \NeedsTeXFormat{LaTeX2e} | |
| \ProvidesPackage{XeTeXemulate}[2018/09/03 v0.0 Emulate the XeTeX font primitives in LuaTeX] | |
| \fi | |
| \def\XeTeXemulate{% | |
| \chardef\XeTeXversion=0 | |
| \def\XeTeXrevision{.99999}% | |
| % Circumvent \outer error | |
| \csname newcount\endcsname\XeTeXtracingfonts \XeTeXtracingfonts=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \protected\def\startluacode | |
| {\begingroup | |
| \catcode`\^^M=12 | |
| \catcode`\%=12 | |
| \catcode`\#=12 | |
| \startluacodeindeed} | |
| \def\startluacodeindeed#1\stopluacode | |
| {\expanded{\noexpand\endgroup\directlua{#1}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local lpeg = require"lpeg" | |
| local C, P, R, S, V = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V | |
| local white = S(" \t") ^ 0 | |
| local digit = R("09") | |
| local dot = P(".") | |
| local eE = S("eE") | |
| local sign = S("+-")^-1 | |
| local mantissa = digit^1 * dot * digit^0 + dot * digit^1 + digit^1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local ffi = assert(require("ffi")) | |
| local libR = assert(ffi.load("libR.so")) | |
| local c_str = function(text) | |
| local str = ffi.new("char[?]", #text + 1) | |
| ffi.copy(str, text) | |
| return str | |
| end | |
| ffi.cdef[[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local ffi = require"ffi" | |
| ffi.cdef[[ | |
| // Cairo types | |
| typedef struct _cairo_surface cairo_surface_t; | |
| typedef int cairo_status_t; | |
| typedef struct _cairo cairo_t; | |
| // Poppler types | |
| typedef struct _PopplerPage PopplerPage; |