Skip to content

Instantly share code, notes, and snippets.

View varkor's full-sized avatar

varkor varkor

View GitHub Profile
@varkor
varkor / free-cocompletion-macros.tex
Created November 22, 2020 18:10
A set of macros for a diagram demonstrating q.uiver.app's macro support
\newcommand{\cat}{\mathscr}
\newcommand{\psh}{\widehat}
\newcommand{\smcat}{\mathbb}
\newcommand{\yo}{よ}
@varkor
varkor / traits-as-type-constructors.md
Created August 28, 2018 14:58
A categorical model of traits in Rust

Traits as type constructors

This is a demonstration that we may view traits as type constructors: that is, functions from Type to Type. This view is motivated from a categorical perspective of type theory, in which the morphisms of the category take the central role. Cf. subobjects, which are represented by morphisms, rather than objects in a different category.

I'm assuming that the category of types, Type, is bicartesian closed. The set of morphisms between any two objects includes the set of functions denoted by Fn, FnMut and FnOnce in Rust.

@varkor
varkor / to_degrees.m
Created March 3, 2018 16:18
Mathematica functions for converting radians, in 32-bit floating point binary representation, to degrees
(* Functions for converting between f32 and Real *)
f32ToReal[li_]:=SetPrecision[First[ImportString[ExportString[FromDigits[li,2],"UnsignedInteger32"],"Real32"]],Infinity];
realToF32[x_]:=IntegerDigits[First[ImportString[ExportString[x,"Real32"],"UnsignedInteger32"]],2,32];
(* Functions for converting between binary strings *)
binaryF32ToReal[x_]:=f32ToReal@ToExpression@StringSplit[x,""]
toDegrees[x_] := x/Degree
realToBinaryF32[x_] := StringJoin[ToString /@ realToF32[x]]
(* For example: *)
@varkor
varkor / whatsapp-emoticon-preserver.user.js
Last active November 25, 2022 12:31
Disable automatic emoticon → emoji conversion in WhatsApp Web
// ==UserScript==
// @name WhatsApp Emoticon Preserver
// @namespace https://gist.github.com/varkor/ca697f6fd59f60b5b9a8aeaa6d7cb341
// @version 0.5
// @author varkor
// @description Disable automatic emoticon → emoji conversion in WhatsApp Web
// @match https://web.whatsapp.com/
// @grant none
// ==/UserScript==