Skip to content

Instantly share code, notes, and snippets.

View DanCouper's full-sized avatar

Dan Couper DanCouper

  • Strive Gaming
  • Newcastle, UK
  • 20:29 (UTC +01:00)
  • X @DanCouper
View GitHub Profile
@maxattack
maxattack / OrbitExt.cs
Created January 9, 2018 17:41
Orbit Camera Degrees-of-Freedom
/*
Copyright (c) 2018 Max Kaufmann
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
furnished to do so, subject to the following conditions:
@acdlite
acdlite / Dataloader.js
Last active August 15, 2018 04:36
Idea for Dataloader component
// The `loader` prop is a Dataloader instance
// https://github.com/facebook/dataloader
class Dataloader extends React.Component {
state = {data: null, isLoaded: false};
componentWillMount() {
this.prefetchData(this.props);
}
componentWillReceiveProps(nextProps) {
if (this.props.id !== nextProps.id || this.props.loader !== nextProps.loader) {
this.setState({isLoaded: false});
@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@busypeoples
busypeoples / UIPattern.re
Last active January 28, 2019 15:31
Slaying a UI Anti Pattern in ReasonML
/*
Slaying a UI Anti Pattern in ReasonML
Based on Kris Jenkins original writing.
http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html
*/
type remoteData 'e 'a =
| NotAsked
| Loading
| Failure 'e
| Success 'a;
@busypeoples
busypeoples / reason-remote-data.re
Last active September 7, 2019 14:13
ReasonML port remote-data
/*
remote-data ported to ReasonML
See also https://github.com/krisajenkins/remotedata
Tools for fetching data from remote sources (incl. HTTP).
*/
type remoteData 'e 'a
= NotAsked
| Loading
@busypeoples
busypeoples / PhantomTypeReasonML.md
Last active February 6, 2024 21:29
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

@romainl
romainl / vanilla-linter.md
Last active April 20, 2025 07:00
Linting your code, the vanilla way

Linting your code, the vanilla way

You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.

Defining makeprg

autocmd FileType <filetype> setlocal makeprg=<external command>

This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.

@BaseCase
BaseCase / dc_2017_biblio.md
Last active January 23, 2020 05:13
List of resources recommended or mentioned by the speakers at Deconstruct 2017

Deconstruct 2017 Bibliography

Here are all of the resources mentioned by Deconstruct 2017 speakers, along with who recommended what. Please post a comment if I missed something or have an error!

DC 2017 Speakers' Choice Gold Medalist

  • Seeing Like a State by James Scott

Books

  • Public Opinion by Walter Lippmann (Evan Czaplicki)
  • A Pattern Language by Christopher Alexander (Brian Marick)
  • Domain Driven Design by Eric Evans (Brian Marick)
@imranismail
imranismail / queue.ex
Created April 10, 2017 08:24
Elixir Wrapper for Erlang Queue module
defmodule Queue do
def insert(queue, item), do: :queue.in(item, queue)
def insert_last(queue, item), do: :queue.in_r(item, queue)
def member?(queue, item), do: :queue.member(item, queue)
def filter(queue, fun), do: :queue.filter(fun, queue)
def split(queue, n) do
@kritollm
kritollm / web-animations.d.ts
Last active October 3, 2017 09:06
Typescript definition file for the web animations api, in progress.
// UPDATE: The types is ready. npm install @types/web-animation-js
// I leave this as an refference for the w3c specs
// I coldn't find any definition file. This is a work in progress and it's my first d.ts file so the gist will be updated.
// The latest spec and the latest web-animations-js polyfill isn't compatible, so I will try to make it more web-animations-js compatible.
interface DocumentTimelineOptions {
originTime: DOMHighResTimeStamp;
}
declare type FillMode = "none" | "forwards" | "backwards" | "both" | "auto";
declare type IterationCompositeOperation = "replace" | "accumulate";