Skip to content

Instantly share code, notes, and snippets.

View abiodun0's full-sized avatar

Abiodun abiodun0

View GitHub Profile
@sebmarkbage
sebmarkbage / Infrastructure.js
Last active October 1, 2024 04:42
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
import React from "react";
import { storiesOf } from "@kadira/storybook";
import Component from "./toggle-button";
storiesOf("toggle-button").add("default", () => {
const { View, stateStream, actions } = Component();
return <View />;
});
const {Map} = require('immutable-ext')
const Id = require('fantasy-identities')
const Task = require('data.task')
const defs = {
Band: {
dino_jr: {
name: 'Dinosaur Jr',
members: 3,
},
@dennisreimann
dennisreimann / Main.elm
Last active April 2, 2024 20:17
A reaction to the article "A small dive into, and rejection of, Elm"
{-
This file is a reaction to the article "A small dive into, and rejection of, Elm":
https://hackernoon.com/a-small-dive-into-and-rejection-of-elm-8217fd5da235#.9w3ml4r6b
I think constructive criticism is very welcome in the Elm community. Pointing out
possibilities for documentation improvements, mentioning missing features or ways
in which the language could evolve etc. are imho a vital part of a good community.
However, the article above is neither well informed nor constructive. IMHO ranting

Type Safe JSON Decoding in Elm

The power of a Static Typed language can seem magical at first. But the goal here is to take a tiny peak behind that curtain.

Elm's implementation of JSON parsing is type safe and how it achieves that can seem like a mystery. Even though I got the code to work, it took me a while to fully understand how it works.

I'm writing it down here for 2 reasons. To help others gain a greater understanding of Types and so I don't forget what I learned.

Word of Caution

@busypeoples
busypeoples / TestSetupExampleCRAEnzymeChaiMocka.md
Last active May 13, 2019 13:07
Mocha/Chai/Enyzme test setup with create-react-app

Basic setup for using Enzyme/Mocha/Chai with create-react-app

This is a temporary solution. Might change in the near future, this depends on how create-react-app will implement testing.

create-react-app quick-test-example

cd quick-test-example

npm run eject
@abiodun0
abiodun0 / slim-redux.js
Created June 12, 2016 23:21 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@yang-wei
yang-wei / destructuring.md
Last active December 2, 2024 06:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
import Html exposing (..)
import Html.App exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Http
import Task exposing (Task)
import Json.Decode as Json exposing ((:=))
type Msg
@Dammmien
Dammmien / dijkstra.js
Last active April 8, 2018 21:30
Implementation of Dijkstra's algorithm in JavaScript
var nodes = [
{
links: [ 1, 3 ], // node 0 is linked to node 1 and 3
weightLinks: [ 5, 15 ], // the distance between node 0 and 1 is 5, between 0 and 3 is 15
distance: Infinity
}, {
links: [ 0, 2 ], // node 1 is linked to node 0 and 2
weightLinks: [ 5, 5, ], // the distance between node 1 and 0 is 5, between 1 and 2 is 5
distance: Infinity
},