Skip to content

Instantly share code, notes, and snippets.


David Siegel dvdsgl

View GitHub Profile
dvdsgl / schema.json
Created Mar 30, 2018
Figma Platform schema
View schema.json
"$ref": "#/definitions/FileResponse",
"$schema": "",
"definitions": {
"BlendMode": {
"enum": [
dvdsgl / blocks.json
Last active Mar 6, 2018
Examples of maps vs classes classified by quicktype Markov chains
View blocks.json
"0000000000000000000e222e4e7afc29c49f6398783a94c846dee2e13c6408f5": {
"size": 969709,
"height": 510599,
"difficulty": 3007383866429.732,
"previous": "000000000000000000552a7783efd39eaa1c5ff6789e21a0bbe7547bc454fced"
"000000000000000000552a7783efd39eaa1c5ff6789e21a0bbe7547bc454fced": {
"size": 991394,
"height": 510598,
dvdsgl / term-schema.json
Last active Feb 28, 2018
A languge-independent logic representation (see
View term-schema.json
"id": "",
"$schema": "",
"description": "A languge-independent logic representation",
"$ref": "#/definitions/Term",
"definitions": {
"Term": {
"type": "object",
"additionalProperties": false,
"description": "A logical value",
dvdsgl / Imgur API.postman_collection.json
Created Feb 28, 2018
Imgur API Postman Collection
View Imgur API.postman_collection.json
"info": {
"name": "Imgur API",
"_postman_id": "00eac12b-6725-3a66-b1b2-b242834fae2d",
"description": "![image](\n\n## API Status\nStatus for the API can be found at [](!\n\n## Getting Started\nImgur's API exposes the entire Imgur infrastructure via a standardized programmatic interface. Using Imgur's API, you can do just about anything you can do on, while using your programming language of choice. The Imgur API is a RESTful API based on HTTP requests and JSON responses.\n\nThis version of the API, version 3, uses OAuth 2.0. This means that all requests will need to be encrypted and sent via HTTPS. It also means that you need to register your application, even if you aren't allowing users to login.\n\nThe easiest way to start using the Imgur API is by clicking the **Run in Postman** button above. [Postman]( is a free tool which helps developers run and debug API requests, and is the source of
View CreateOrUpdateGistRequest.json
"description": "the description for this gist",
"files": {
"file1.84D9D31B-8AD2-492F-A44D-6407128DAD79.txt": {
"content": "updated file contents"
"file2.84D9D31B-8AD2-492F-A44D-6407128DAD79.txt": {
"content": "updated file contents"
dvdsgl / QTPokedex.m
Created Jan 17, 2018
quicktype Objective-C enum support prototype sample
View QTPokedex.m
// To parse this JSON:
// NSError *error;
// QTPokedex *pokedex = [QTPokedex fromJSON:json encoding:NSUTF8Encoding error:&error]
#import <Foundation/Foundation.h>
// MARK: Types
typedef NSNumber NSBoolean;
View quicktype-sample.json
"int or string": [1, "1"],
"nested array": [[false, true]],
"best friend": { "name": "Sue" },
"friends": [{ "name": "Sal" }, { "name": "Sue" }],
"a map": {
"zero": 0, "one": 1, "two": 2, "three": 3,
"four": 4, "five": 5, "six": 6, "seven": 7,
"eight": 8, "nine": 9, "ten": 10, "eleven": 11,
"twelve": 12, "thirteen": 13, "fourteen": 14,
dvdsgl / Parsers.purs
Created Oct 15, 2015
Unit tests for a stack trace parser
View Parsers.purs
module Test.Parsers (tests) where
import Prelude
import Data.Default
import Test.Prelude
import Test.Data
import Test.Unit (runTest, test, assert)
View ShootOutAnimator.fs
type ShootOutAnimator(referenceView: UIView) =
let speed = 1300.0f
let animator = UIDynamicAnimator(referenceView)
member this.ShootOut(view: UIView, direction: Direction) =
let x, y = direction.UnitVector
let shoot = UIDynamicItemBehavior(view, AngularResistance=2.0f)
shoot.AddLinearVelocityForItem(PointF(x * speed, y * speed), view)
shoot.AddAngularVelocityForItem(x * 3.0f, view)
shoot.Action <- fun () ->
dvdsgl / Monads for a C#
Last active Nov 12, 2020
Monads explained (sort of) to a C# developer
View Monads for a C#

A monad is a fancy word for a generic type of the form MyMonad<T> (a generic type of arity 1).

A monad is special because it adds 'special powers' to the T that it wraps. These 'special powers' won't sound very special to an imperative programmer, so you have to squint to see them but bear with me.

  • IEnumerable<T> is a monad that gives values of type T the special power of nondeterminism, or the ability to 'be' multiple values at once.
  • Nullable<T> is a monad that gives values of type T the special power of nullability, or the ability to be absent.
  • Task<T> is a monad that gives values of type T the special power of asynchronicity, or the ability to be used before they are computed.

The trick with monads comes when you want to play with the T values, because they are inside another type. C# introduced language changes to make dealing with values inside these monads easier:

You can’t perform that action at this time.