Skip to content

Instantly share code, notes, and snippets.

@SeverTopan
SeverTopan / Dockerfile
Created March 26, 2021 23:53
Dockerfile for Beluga Installation
from debian:buster
# Setup.
workdir /workspace
run apt-get update && apt-get install -y git opam rlwrap
# Clone Beluga.
run git clone https://github.com/Beluga-lang/Beluga.git
# Setup opam.
@SeverTopan
SeverTopan / to_max2sat.py
Created September 18, 2020 00:01
3SAT to MAX2SAT
def _3_sat_to_max_2_sat(S):
# Using https://math.stackexchange.com/questions/1633005/how-exactly-does-a-max-2-sat-reduce-to-a-3-sat
S = torch.FloatTensor(S)
S_prime = torch.zeros([S.size()[0]*10, S.size()[1] + S.size()[0]])
num_aux = len(S)
for aux, (t, l1, l2, l3) in enumerate(S):
aux_true = [0]*num_aux
aux_true[aux] = 1
@SeverTopan
SeverTopan / cyclic.agda
Created July 30, 2020 00:32
Is it possible to construct cyclic types in Agda?
data A : Set
data B : Set where
b : A → B
data A where
a : B → A
@SeverTopan
SeverTopan / Creator.md
Last active November 7, 2018 07:20
Casting Away the Private Constructor std::make_shared Boilerplate

A common problem that I have come across exists when attempting to create shared pointers of objects which have protected constructors. The following class design details a class that can only be accessed through a shared reference.

class A
{
protected:
    A(int foo)
        : _foo(foo)
    {
 }
@SeverTopan
SeverTopan / formdown.py
Last active April 24, 2018 13:23
Formdown - Pretty Markdown Formatting Script
"""Formdown is a tiny python module that converts a string into html, and applies a
github-like formatting style to it.
The module requires the https://github.com/Python-Markdown/markdown module.
"""
import markdown
import argparse
def format(markdown_string):
"""Convert the given markdown string to html, and apply a github-like formatting style.