Skip to content

Instantly share code, notes, and snippets.

View ryanmtaylor's full-sized avatar

Ryan M Taylor ryanmtaylor

View GitHub Profile
@rupertlssmith
rupertlssmith / GameState.elm
Last active July 21, 2023 01:09
Exploring State Machines with phantom types in Elm
module GameState
exposing
( Game(..)
, GameDefinition
, PlayState
, loading
, updateGameDefinition
, updatePlayState
, updateScore
, toReady
@mrcrowl
mrcrowl / basket.ts
Last active August 9, 2021 01:16
Example of using vuex-type to create strongly-typed vuex store access
// path: store/basket/basket.ts (module)
import { RootState } from "../../store"
import inventory, { Product } from "../inventory/inventory"
export interface Item { productId: string, quantity: number }
export interface DisplayItem { product: Product, quantity: number }
export interface BasketState { items: Item[], isLoading: boolean }
const initialBasketState: BasketState = { items: [], isLoading: false }
@wonderful-panda
wonderful-panda / builder.ts
Last active March 18, 2018 19:22
vuex store builder (TypeScript >= 2.1 is required / namespaced module is not supported)
// MIT License
import * as Vuex from "vuex";
/*
* Infrastructure types
*/
export type KV<K extends string, V> = { [_ in K]: V };
export type Payload<T, V> = { type: T } & V;
/*
@enriched
enriched / jsonSchemaInterface.ts
Last active December 8, 2023 07:28
TypeScript interface for Json-Schema V4
/**
* MIT License
*
* Copyright (c) 2016 Richard Adams (https://github.com/enriched)
*
* 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
@gre
gre / easing.js
Last active April 23, 2024 04:20
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 = {