Skip to content

Instantly share code, notes, and snippets.

@shreevatsa
shreevatsa / pandoc-tex2svg.hs
Created November 9, 2017 15:36
Simpler (slower) version of pandoc-tex2svg.hs, without caching
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Text.Pandoc.JSON
import Control.Monad (when)
import System.Exit
import System.Process
import System.Directory (findExecutable)
import System.IO (stderr, hPutStrLn)
@shreevatsa
shreevatsa / pandoc-mathjax-svg-filter.js
Created November 9, 2017 15:07
A Pandoc filter in JS (Node), for converting TeX snippets to SVG using mathjax-node
#!/usr/bin/env node
var pandoc = require('pandoc-filter');
var RawInline = pandoc.RawInline;
var mjAPI = require("mathjax-node");
mjAPI.config({
MathJax: {
// traditional MathJax configuration
}
@shreevatsa
shreevatsa / robber.cc
Created October 7, 2017 19:19
Brute-force program for cops-and-robbers 144601
#include <iostream>
#include <set>
typedef long long Int;
Int candidates_a[1<<17]; int length_a = 0; std::string full_a = "74837258394056219";
Int candidates_b[1<<9]; int length_b = 0; std::string full_b = "268435455";
Int candidates_c[1<<9]; int length_c = 0; std::string full_c = "124038877";
void subset_ints(std::string full, Int where[], int* length) {
@shreevatsa
shreevatsa / libspl.c.diff
Created June 6, 2017 04:17
Diff needed for Shakespeare's int_input to behave like scanf
diff --git a/spl-1.2.1/libspl.c b/spl-1.2.1/libspl.c
index ad597fe..1e0bd13 100644
--- a/spl-1.2.1/libspl.c
+++ b/spl-1.2.1/libspl.c
@@ -305,40 +305,28 @@ int int_factorial(int line, int n)
return n;
}
void int_input(int line, CHARACTER *character)
{
@shreevatsa
shreevatsa / get_next.diff
Created May 19, 2017 18:01
Dumping what's going on as TeX reads
diff --git a/web2c/tex.web b/web2c/tex.web
index 92b0cc5..372874c 100644
--- a/web2c/tex.web
+++ b/web2c/tex.web
@@ -7240,7 +7240,12 @@ if state<>token_list then
else @<Input from token list, |goto restart| if end of list or
if a parameter needs to be expanded@>;
@<If an alignment entry has just ended, take appropriate action@>;
-exit:end;
+exit: