Skip to content

Instantly share code, notes, and snippets.

@mrkishi
mrkishi / count.rs
Created September 22, 2020 01:48
macro_rules! count
macro_rules! count {
() => { 0 };
($($half:tt $_:tt)*) => { count!($($half)*) * 2 };
($one:tt $($half:tt $_:tt)*) => { count!($($half)*) * 2 + 1 };
}
const TOTAL: usize = count!(+++++++);
pub fn main() {
println!("{}", TOTAL);
@mrkishi
mrkishi / svelte.d.ts
Created November 18, 2018 22:20
Type definitions for Svelte components
declare module '*.svelte' {
type State = Record<string, any>
type Changed = Record<string, boolean>
interface Cancellable {
cancel: () => void
}
export default class Component {
root: Component
@mrkishi
mrkishi / svelte.d.ts
Created October 22, 2018 03:33
Project-wide Svelte components type declaration for vscode
declare module '*.svelte' {
type Data = { [key]: any }
type Changed = { [key]: boolean }
type Listener = { cancel: () => void }
export default class Component {
root: Component
options: Data
constructor(init: { target: Element, data: Data })
@mrkishi
mrkishi / multiple.js
Created February 7, 2018 22:02
Experiments on spread attributes for Svelte
// App.html
<Child a="{{a}}" ...{{b_props}} c="{{c}}" d="{{d}}" ...{{e_props}} />
// app.output.js
function create_main_fragment(state, component) {
var child = new Child({
@mrkishi
mrkishi / README.md
Created January 24, 2018 18:36
Rollup duplicate dynamic imports bug

node build

(node:7660) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at /repro/node_modules/rollup/dist/rollup.js:18666:69
    at Array.forEach (<anonymous>)
    at /repro/node_modules/rollup/dist/rollup.js:18654:45
    at Array.forEach (<anonymous>)
    at Chunk.setDynamicImportResolutions (/repro/node_modules/rollup/dist/rollup.js:18653:29)
    at /repro/node_modules/rollup/dist/rollup.js:18861:69

at

@mrkishi
mrkishi / index.html
Last active November 5, 2016 00:30
AAMVA Magnetic Stripe Card Parser
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AAMVA Magnetic Stripe Card Parser</title>
<style>
html {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
@mrkishi
mrkishi / cancelAutomationAfterTime.js
Created October 28, 2015 01:19
AudioParam Automation
(() => {
'use strict';
class AutomationEvent {
constructor(proxy, time) {
this.proxy = proxy;
this.time = time;
}