Skip to content

Instantly share code, notes, and snippets.

@nobbele
nobbele / build_wasm.sh
Last active October 8, 2023 22:40 — forked from tgolsson/wasm-bindgen-macroquad.sh
Compatibility shim for combining macroquad with wasm-bindgen.
#!/usr/bin/env bash
set -e
HELP_STRING=$(cat <<- END
usage: build_wasm.sh
Build script for combining a Macroquad project with wasm-bindgen,
allowing integration with the greater wasm-ecosystem.

About variadics in Rust

This is an analysis of how variadic generics could be added to Rust. It's not a proposal so much as a summary of existing work, and a toolbox for creating an eventual proposal.

Introduction

Variadic generics (aka variadic templates, or variadic tuples), are an often-requested feature that would enable traits, functions and data structures to be generic over a variable number of types.

To give a quick example, a Rust function with variadic generics might look like this:

from typing import Tuple, List
t = "teen"
y = "ty"
NUMBERS = ["zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thir" + t,
"four" + t, "fif" + t, "six" + t, "seven" + t,
"eigh" + t, "nine" + t, "twenty"]
TENS = ["thir" + y, "four" + y, "fif" + y, "six" +
y, "seven" + y, "eight" + y, "nine" + y]
@RameshRavone
RameshRavone / godot 3.0 shader
Created August 27, 2017 06:23
simple light shader for godot 3.0
shader_type canvas_item;
void fragment () {
vec2 resolution = vec2(1024, 600);
vec2 texcoord = FRAGCOORD.xy / resolution;
vec3 colours = vec3(0,0,1);
float backgroundlight = 0.35;
vec3 lightcolor = vec3(1,0,0);
@danking
danking / gist:1068185
Created July 6, 2011 19:55
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()