Skip to content

Instantly share code, notes, and snippets.

@tabatkins
tabatkins / proposal.md
Last active August 22, 2023 13:31
Pattern-matching across constructs

"Matchers Everywhere" Proposal

tldr:

  • Matchers are mostly identical to what's in the repo today, except:
    • I added "predicate matchers" (if(<boolean-expr>)) and removed the if(...) part from the match() syntax.
    • Added ident when <matcher> binding-matcher form, to match its usage in destructuring.
    • Made regex matchers use /foo/ when <matcher> for consistency (and removed the named bindings for simplicity).
    • Added a simpler custom-matcher syntax (foo(<matchers>))
@msteen
msteen / print-lezer-tree.ts
Last active May 1, 2024 21:05
Print Lezer Trees
// MIT License
//
// Copyright (c) 2021 Matthijs Steen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@thecodewarrior
thecodewarrior / App Icon Template.svg
Last active September 24, 2024 02:45
An SVG template for creating macOS app icons, including guides and the standard drop shadow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@avaidyam
avaidyam / BackdropView.swift
Created July 2, 2020 17:23
DIY NSVisualEffectView using Private API for macOS
// TODO: setting window transforms (or mission control) flattens layers...
// TODO: Mask image vs path (layer)?
/// `NSVisualEffectView`:
///
/// A view that adds translucency and vibrancy effects to the views in your interface.
/// When you want views to be more prominent in your interface, place them in a
/// backdrop view. The backdrop view is partially transparent, allowing some of
/// the underlying content to show through. Typically, you use a backdrop view
/// to blur background content, instead of obscuring it completely. It can also
@lattner
lattner / TaskConcurrencyManifesto.md
Last active November 1, 2024 10:13
Swift Concurrency Manifesto
@chriseidhof
chriseidhof / references.swift
Last active October 14, 2021 10:24
References Blogpost
//: Playground - noun: a place where people can play
import Foundation
final class Disposable {
private let dispose: () -> ()
init(_ dispose: @escaping () -> ()) {
self.dispose = dispose
}
@mchambers
mchambers / serializer.swift
Created June 25, 2014 07:49
A simple, limited model-to-JSON serializer in Swift.
// Here we'll use Swift's IDE-supporting reflect()
// function to build a basic JSON serializer.
// Per the fine engineers at WWDC, Swift's reflection support
// exists purely to support the IDE and the Playground. But
// we can have some fun with it anyway. ;)
class SerializerBase {
}
@mchambers
mchambers / reflect.swift
Last active March 5, 2021 09:20
Basic Reflection in Swift.
// Let's define a basic Swift class.
class Fruit {
var type=1
var name="Apple"
var delicious=true
}
// We can get at some info about an instance of an object using reflect(), which returns a Mirror.
reflect(Fruit()).count
reflect(Fruit())[1].0
@bvssvni
bvssvni / gist:9674632
Last active December 23, 2023 22:56
A Rust Chain Macro
//! Chain macro in Rust
//!
//! A typical usage is to avoid nested match expressions.
//!
//! Supports:
//! - Pattern matching
//! - Or expressions (A | B => ...)
//! - Guarded statements (x if <cond> => ...)
//! - Implicit else (requires all arms to return same type)
@brson
brson / gist:9470739
Last active February 15, 2016 04:15
Rust doc hacking cheatsheet

Tips for hacking on Rust docs in the Rust tree

Standalone docs

  • make doc/tutorial.html - build the tutorial
  • make check-stage1-doc-tutorial - test the examples in the tutorial

API docs

  • make doc/std/index.html - build the API docs for std