Skip to content

Instantly share code, notes, and snippets.

@josgraha
josgraha / OUTLINE.md
Last active March 16, 2022 19:36
Hypthesis Based Problem Solving

Hypthesis Based Problem Solving

Business Problem -> Facts ~~ -> Gaps ~~ -> Solution
                               (Hypthesis)

Process: To work solution-oriented from an early stage, hypothesis are needed to "fill the gaps"

@josgraha
josgraha / EnglishAuction.hs
Last active April 14, 2021 11:05
Plutus Playground Smart Contract
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
@josgraha
josgraha / poolMetadata.json
Last active March 2, 2021 02:33
IUXTA Pool Meta
{
"name": "IUXTA Pool",
"description": "iuxta-casus pool",
"ticker": "IUXTA",
"homepage": "https://iuxta-casus.com"
}
@josgraha
josgraha / map_to_object_with_lodash.js
Created January 7, 2021 15:50
JavaScript Map to Object
const _ = require('lodash');
mapToObject = m => _.isMap(m) ? [...m].reduce((o, entry) => ({...o, ...{ [_.head(entry)]: mapToObject(_.head(_.tail(entry))) }}), {}) : m;
@josgraha
josgraha / combinators.js
Created March 19, 2019 20:54 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@josgraha
josgraha / README.md
Created February 3, 2019 18:57
Find max subarray divisible by K

Logic:

Already going to assume that you know about prefix sums before you read this. We can all agree that for an array A = [], where N = A.length, that there are N prefix sums.

prefix[0] = A[0], prefix[1] = A[0] + A[1], ... prefix[i] = prefix[0] + ... + prefix[i].

Then to calculate how many subarrays are divisible by K is logically equivalent to saying, how many ways can we pair up all prefix sum pairs (i,j) where i < j such that (prefix[j] - prefix[i]) % K == 0

@josgraha
josgraha / .jpmrc
Created October 3, 2018 18:29
My Dotfiles
{
permaBan: [/He/],
mt: false,
jp: false,
}
@josgraha
josgraha / settings.json
Last active October 8, 2018 15:39
VSCode Settings
{
"workbench.startupEditor": "newUntitledFile",
"window.zoomLevel": 0,
"terminal.integrated.fontFamily": "'Dank Mono', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
@josgraha
josgraha / LIST.md
Last active December 25, 2018 08:15
Curated JavaScript and React Resources

Curated JavaScript and React Resources

Mostly paid list of resources to learn JavaScript and React. This list is sorted in descending recommended order and is grouped by paid and free. My experience is that paid resources are easier to find at the moment but there are lots of great free resources out there. My favorite paid instructors are Stephen Grider and Kent C. Dodds.

Paid Resources

React related

@josgraha
josgraha / zipper.js
Created September 9, 2018 19:58
Zipper in JS
const lastIndex = list => (
list && list.length > 0 ? list.length - 1 : 0);
const isNone = val => val === null || typeof val === 'undefined';
const asList = list => (isNone(list) ? [] : list);
const isEmptyList = list => list && list.length <= 0;
const isLastIndex = (lst, index) => (asList(lst).length - 1) === index;