Skip to content

Instantly share code, notes, and snippets.

View lthms's full-sized avatar

Thomas Letan lthms

View GitHub Profile
fn main() -> Result<()> {
let conn = kls::get_database().unwrap();
kls::migrations::run_migrations(&conn).unwrap();
for date in keyr::list_days()? {
let mut file = DayFile::open(&date, OpenOptions::new().read(true).clone())?;
file.read_global_count()?;
loop {
trait Func<A, B> {
fn apply(&self, x: A) -> B;
}
pub struct Curry<A, B>(Box<Fn(A) -> B>);
impl<A, B> Func<A, B> for Curry<A, B> {
fn apply(&self, x: A) -> B {
(self.0)(x)
}
@lthms
lthms / Category.v
Last active December 3, 2018 16:32
Require Import Coq.Logic.ProofIrrelevance.
Require Import Coq.Program.Tactics.
Ltac simpl_exist_eq :=
match goal with
| [ |- exist _ ?x _ = exist _ ?y _]
=> let H := fresh "H"
in cut (x = y);
[ intro H;
apply eq_sig with (p:=H);
Require Import Coq.Logic.ProofIrrelevance.
Require Import Coq.Program.Tactics.
Ltac simpl_exist_eq :=
match goal with
| [ |- exist _ ?x _ = exist _ ?y _]
=> let H := fresh "H"
in cut (x = y);
[ intro H;
apply eq_sig with (p:=H);
@lthms
lthms / too_much.sql
Last active September 18, 2018 22:37
CREATE TABLE sheets (
id SERIAL PRIMARY KEY,
character_id INTEGER NOT NULL REFERENCES characters,
created TIMESTAMP NOT NULL DEFAULT now(),
validated TIMESTAMP,
current BOOLEAN,
future BOOLEAN,
invalidated TIMESTAMP,
name VARCHAR(80) NOT NULL,
@lthms
lthms / README.md
Last active September 20, 2018 15:08

ogmarkup

What is ogmarkup?

Typographic rules can be trick to enforce in a consistent manner in a document. In French, typographic rules for dialogues are arguably worst. ogmarkup is part of the so-called ogma-project. It is a minimal domain-specific markup language, intended to free fiction writers from the pain to enforce typographic rules within their productions manually.

CREATE TABLE entities (
id SERIAL PRIMARY KEY,
time INT4RANGE,
class SMALLINT NOT NULL
);
CREATE TABLE documents (
id SERIAL PRIMARY KEY,
language INT2 NOT NULL,
raw TEXT NOT NULL,
#[test]
fn test_render() {
use typography::ENGLISH;
use generator::test::Html;
assert_eq!(
render_galatian_document(r#"It looks like it is working.
+I+
smiled *at
#[test]
fn test_document() {
assert_eq!(
document(r#"She opened the letter, and read it.
_____letter____
Dear friend.
I love you.
_______________"#),
#[test]
fn test_paragraph() {
assert_eq!(
paragraph("[Hi stranger, this is me.] Indeed.\n\n[Hi]"),
Ok(
(
"\n\n[Hi]",
Paragraph(
vec![
Component::Dialogue(