Skip to content

Instantly share code, notes, and snippets.

View jtbandes's full-sized avatar
💜
Working on @foxglove!

Jacob Bandes-Storch jtbandes

💜
Working on @foxglove!
View GitHub Profile
@CodaFi
CodaFi / AlgorithmW.swift
Last active July 28, 2024 10:04
A Swift Playground containing Martin Grabmüller's "Algorithm W Step-by-Step"
/// Playground - noun: a place where people can play
/// I am the very model of a modern Judgement General
//: # Algorithm W
//: In this playground we develop a complete implementation of the classic
//: algorithm W for Hindley-Milner polymorphic type inference in Swift.
//: ## Introduction
import Cocoa
// Note: use of enumeration var in generic is instadeath
// Note: use of static var in generic is not yet supported
public protocol EnumConvertible: Hashable {
init?(hashValue hash: Int)
static func countMembers() -> Int
static func members() -> [Self]
}
@peta
peta / demo-grammar.tmProperties
Last active March 21, 2020 04:58
Regex design pattern for Textmate language grammars. An absolutely cool feature of PCRE (even supported by Oniguruma) are named subexpression calls. Allowing for recursive matching while preserving (atomic) contexts at every recursion level in form of named match results. However, there is no light without shadow: When no multiline matches can b…
myPattern = {
name = 'meta.spec.triples';
begin = '(?x)
(?<subject> \g<iri> | \g<BlankNode> | \g<collection> ){0}
(?<iri> \g<IRIREF> | \g<PrefixedName> ){0}
(?<IRIREF> \< (?:[^\x00-\x20\<\>\\\"\{\}\|\^`] | (?:\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8}))* \> ){0}
(?<PrefixedName> \g<PNAME_LN> | \g<PNAME_NS> ){0}
(?<PNAME_LN> (\g<PNAME_NS>) ( (?: [\p{L}\p{M}_] | [:0-9] | %[0-9A-Fa-f]{2} | [\\_~.\-!$&''\(\)*+,;=/?#@%] ) (?:(?:[\p{L}\p{M}_\-0-9\u00B7\u0300-\u036F\u203F-\u2040] | [:.] | %[0-9A-Fa-f]{2} | [\\_~.\-!$&''\(\)*+,;=/?#@%])* (?:[\p{L}\p{M}_\-0-9\u00B7\u0300-\u036F\u203F-\u2040] | : | %[0-9A-Fa-f]{2} | [\\_~.\-!$&''\(\)*+,;=/?#@%])) )? ){0}
(?<PNAME_NS> (?: [\p{L}\p{M}] (?:(?:[\p{L}\p{M}_.\-0-9\u00B7\u0300-\u036F\u203F-\u2040])* [\p{L}\p{M}_\-0-9\u00B7\u0300-\u036F\u203F-\u2040] )? )? \: ){0}
(?<BlankNode> \g<BLANK_NODE_LABEL> | \g<ANON> ){0}
@jkubicek
jkubicek / gho
Created January 3, 2013 07:43
Oneliner bash command for opening the current git repo in github
git config --get remote.origin.url | sed 's#^[^:]*.\([^.]*\)\.git#http://github.com/\1#' | xargs open