Skip to content

Instantly share code, notes, and snippets.

bySabi Files bySabi

Block or report user

Report or block bySabi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@luisherranz
luisherranz / Proposal.md
Last active Jun 24, 2019
Proposal for a redux-like API on top of Mobx
View Proposal.md

I'd got rid of action types and I'd have only actions (action creators). No strings, the function (reference) is used later for comparisons.

export const addTodo = (id, title) => ({ id, title });
export const removeTodo = id => ({ id });
actions({ addTodo, removeTodo }); // Connect it to actions.addTodo & actions.removeTodo.

That's it. They define what your app can do.

@jamestalmage
jamestalmage / How_Require_Extensions_Work.md
Last active Oct 11, 2019
Breakdown of How Require Extensions Work
View How_Require_Extensions_Work.md

Why

Doing require extensions correctly is essential, because:

  1. Users should be able to install multiple extensions in succession, and have them work together.
  2. Coverage tools like nyc need it to reliably supply coverage information that takes into account sourcemaps from upstream transforms.
  3. Because non-standard, un-predictable behavior causes hard to solve bugs, and major headaches for project maintainers.

What is a require extension anyways?

@sebmarkbage
sebmarkbage / Enhance.js
Last active Oct 19, 2019
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@paf31
paf31 / node-haskell.md
Last active Apr 22, 2019
Reimplementing a NodeJS Service in Haskell
View node-haskell.md

Introduction

At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.

Over the past few months, I have been working on two Haskell services:

  • A reimplementation of an existing socket.io service, previously written for NodeJS using TypeScript.
  • A new service, which would interact with third-party components using standard data formats from the medical industry.

I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces

View gist:490f4e5a77e61b297284
(Chapters marked with * are already written. This gets reorganized constantly
and 10 or so written chapters that I'm on the fence about aren't listed.)
Programmer Epistemology
* Dispersed Cost vs. Reduced Cost
* Verificationist Fallacy
* Mistake Metastasis
The Overton Window
Epicycles All The Way Down
The Hyperspace Gates Were Just There
@Fristi
Fristi / Aggregate.hs
Last active Sep 8, 2019
DDD/Event Sourcing in Haskell. Implemented an aggregate as a type class and type families to couple event, command and error types specific to the aggregate. Errors are returned by using Either (Error e) (Event e). Applying Applicative Functors fits here well to sequentially check if the command suffice.
View Aggregate.hs
{-# LANGUAGE TypeFamilies #-}
import Data.Function (on)
import Control.Applicative
data EventData e = EventData {
eventId :: Int,
body :: Event e
}
@austintaylor
austintaylor / ShuntingYard.hs
Created Apr 11, 2011
A basic math evaluator in Haskell
View ShuntingYard.hs
type Precedence = Int
data Associativity = AssocL | AssocR
data Token = Operand Int | Operator String (Int -> Int -> Int) Associativity Precedence | ParenL | ParenR
instance Show Token where
show (Operator s _ _ _) = s
show (Operand x) = show x
show ParenL = "("
show ParenR = ")"
You can’t perform that action at this time.