Skip to content

Instantly share code, notes, and snippets.

View defims's full-sized avatar

Wei Long defims

View GitHub Profile

introduction

inspired by a friend’s fledgling language design and motivated by the JeanHeyd Meneide RustConf Fiasco™ and improving the story for compile-time introspection, i decided i needed a place to spew the last year’s musings on variadic generics in Rust in one mighty, less-than-understandable catharsis.

i think somewhere in here is a considered and reasonable design, so that’s neat!

perhaps i’ll make this an RFC one day. probably not. you have my express permission to do that yourself.

variadic generics?

this nugget of language jargon encapsulates the idea that we might want to bind to an arbitrarily large list of generic parameters, all at once. there are many reasons to want to do this:

@PCreations
PCreations / rxjs-diagrams.md
Last active January 18, 2024 08:52
Super Intuitive Interactive Diagrams to learn combining RxJS sequences by Max NgWizard K
@uchcode
uchcode / jxa-snippets.js
Last active September 10, 2023 19:16
JXA (JavaScript for Automation) snippets for applet.
function MenuItem(title, action, target) {
if (!title && !action && !target) return $.NSMenuItem.separatorItem
let i = $.NSMenuItem.alloc.init
i.title = title
i.action = action
i.target = target
return i
}
function StatusItem() {
@defims
defims / selected-frames-svg-smil-path-data-generator.jsfl
Last active June 21, 2016 02:53
selected frames svg smil path data generator by Def (def@hai.li)
/*
MIT license
what:
selected frames svg smil path data generator by Def (def@hai.li)
why:
[Flash2Svg](https://github.com/TomByrne/Flash2Svg) and [SnapSVG-Animator](http://cjgammon.github.io/SnapSVG-Animator/) are awesome.
but both of them generate shape tween svg code in frame by frame way.
this script generate svg path code in the keyframe way flash used.
@lucamarrocco
lucamarrocco / app.swift
Last active January 30, 2024 11:00
swift osx application without nib
import Cocoa
class WindowController: NSWindowController {
}
class AppDelegate: NSObject {
var mainWindow: NSWindow?
var mainController: NSWindowController?
}
@divarvel
divarvel / continuation.js
Last active May 27, 2023 08:12
implementation of the continuation monad in JS
console.log("\033[39mRunning tests…");
function assertEquals(actual, expected, description) {
if(typeof actual === "undefined") {
console.error("\033[31m" + description + " not implemented\033[39m");
} else {
if(actual !== expected) {
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m");
} else {
console.log(description + " \033[32m ok\033[39m");
}
// Polyfill for ES6 Object.observe()
// Limitations:
// - No 'splice' (etc); if you're observing an Array, you're gonna have a bad time
(function(global) {
function assert(e) { if (!e) throw new Error('Assertion failed'); }
// http://wiki.ecmascript.org/doku.php?id=harmony:observe
// ECMAScript internal approximations
@shiweifu
shiweifu / lweb.lua
Created June 22, 2012 06:21
lua static webserver
socket = require("socket")
httpcode = require("httpcode")
require("mime")
getMime = mime.getMime
assert(getMime)
function main( p )
local port
@gre
gre / easing.js
Last active June 13, 2024 12:18
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@paulirish
paulirish / rAF.js
Last active June 11, 2024 14:29
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];