{{ message }}

Instantly share code, notes, and snippets.

# Jimmy Tang talyian

Created Mar 25, 2020
Last active Jan 31, 2020
CracklePop in regex
View cracklepop.js
 // CracklePop // Problem: Write a program that prints out the numbers 1 to 100 (inclusive). // If the number is divisible by 3, print Crackle instead of the number. // If it's divisible by 5, print Pop. // If it's divisible by both 3 and 5, print CracklePop. // Solution: regex is not only perfectly capable of lexing HTML, // it is also perfectly capable of expressing, in a roundabout way, // a finite automaton that verifies divisibility by a given number.
Last active Dec 27, 2019
vector map
View generic_vector_map.cpp
 template struct vector { int length; T* data; }; using vector_int = vector; using vector_float = vector; // F is a function type that takes T and returns R // Map takes a vector, and F and returns vector template auto Map(vector input, F func){
Last active Dec 24, 2019
Slowest Font Renderer in the West
View fragment.glsl
 uniform int n_lin_segments; uniform vec2 lin_segments[256]; uniform int n_quad_segments; uniform vec2 quad_segments[512]; varying vec3 pos; varying vec2 uv; void main() { vec2 point = uv; // point = (point + vec2(0.3, 0)) * 0.1;
Created Sep 29, 2018
Convert a Regex to NFA to DFA
View regex_to_dfa.fsx
 // An exercise in converting a regex to an NFA to a DFA type RegexNode = | Or of RegexNode list | Seq of RegexNode List | Star of RegexNode | T of string | Eta (* todo: does this value really belong here? *) let regex_pattern = "x(x|y)*|z"
Last active Sep 28, 2018
POC for New Breve Idea
View A_Blitz_FSharp
 Breve was designed as a backwards-compatible Blitz replacement that does safe context-aware sanitization. The current architecture uses Blitz's parser frontend + Latte as a context-aware backend to achieve this goal. This was because I figured writing a context-aware HTML+macro parser was harder than re-implementing Blitz's logic flows (blocks, variable lookups, partial templates, etc.) in Latte. As it turns out, reimplementing logic is a difficult problem. An alternate solution would be to write our own Blitz-compatible frontend that just adds context-aware output and delegates to Blitz for the logic implementation. This is a Proof of concept that shows it isn't that bad in a language that makes writing parsers easy.
Last active Sep 28, 2018
Poker Demo