Skip to content

Instantly share code, notes, and snippets.

@siassaj
siassaj / weird.ts
Last active January 13, 2020 03:25
// everything works totally correctly with this version
export function test<
P extends Props
>(input: unknown, innerCodec: TypeC<P>) {
return innerCodec.is(input) // no errors
}
// no errors within this function, but where the function is called such as
//
// test({}, someCodec)
import React from "react";
import { sortWith, compose, filter, propEq, propIs } from "ramda";
import { Formik, Form, Field } from "formik";
import Box from "@material-ui/core/Box";
import Button from "@material-ui/core/Button";
import Check from "@material-ui/icons/Check";
import Checkbox from "@material-ui/core/Checkbox";
import Clear from "@material-ui/icons/Clear";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
{
"slump": {
"name": "slump",
"title": "Slump",
"data": "{\"slump\":[{\"title\":\"80\",\"value\":80,\"price\":0},{\"title\":\"90\",\"value\":90,\"price\":0}]}"
}
"agg": {
"name": "agg",
"title": "Agg",
"data": "{\"slump\":[{\"title\":\"80\",\"value\":80,\"price\":0},{\"title\":\"90\",\"value\":90,\"price\":0}]}"
INSERT INTO customers (primary_contact_id, company_name, created_at, updated_at)
SELECT user_id, account_name, current_timestamp as the_timestamp FROM account_named_users
VALUES (user_id, account_name, the_timestamp, the_timestamp);
-- ERROR: table "values" has 2 columns available but 4 columns specified
class DoThing
include Dry::Monads::Result::Mixin
include Dry::Monads::Do.for(:call)
Context = Struct.new(:user, :params, :accumulator)
Result = Struct.new(:output)
Error = Struct.new(:step, :errors)
def call(input)
context = yield railway(Context.new(input[:user], input[:params], {}))
class DoThing
include Dry::Transaction
Context = Struct.new(:user, :params, :accumulator)
Result = Struct.new(:output)
Error = Struct.new(:step, :errors)
step :build_context
step :operation_one
step :operation_two
/* Keymap 0: Basic layer
*
* ,--------------------------------------------------. ,--------------------------------------------------.
* | Esc | 1 | 2 | 3 | 4 | 5 | LEFT | | DEL | 6 | 7 | 8 | 9 | 0 | BSpace |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | Tab | ' | , | . | P | Y | / | | PgUp | F | G | C | R | L | \ |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | BkSp | A | O | E | U | I |------| |------| D | H | T | N | S | ENT |
* |--------+------+------+------+------+------| _ | | PgDn |------+------+------+------+------+--------|
* | LShift | ; | Q | J | K | X | | | | B | M | W | V | Z | RShift |
@siassaj
siassaj / snabbdom-asnyc.js
Last active June 28, 2019 05:50
trying to understand how to use snabbdom when dealing with asynchronous events (inlining an svg)
import { h, init } from 'snabbdom';
import classModule from 'snabbdom/modules/class';
import propsModule from 'snabbdom/modules/props';
import styleModule from 'snabbdom/modules/style';
import eventModule from 'snabbdom/modules/eventlisteners';
// Init patch function with chosen modules
const patch = init([
classModule, // makes it easy to toggle classes
$ yarn run tsc
yarn run v1.12.3
$ /home/quazi/Filing/app/node_modules/.bin/tsc
error TS2688: Cannot find type definition file for 'react-native'.
Found 1 error.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
export function mix<
COMB extends {
[CS in keyof ComponentSinks]?: (arg: {
[K in keyof COMPONENTS]: Stream<any>
}) => ComponentSinks[CS]
},
COMPONENTS extends {
[COMPNAME in keyof COMPONENTS]: {
[SINKNAME in keyof ComponentSinks]?: (COMB[SINKNAME] extends (arg: infer STREAMS) => any ? (
COMPNAME extends keyof STREAMS ? STREAMS[COMPNAME] : ComponentSinks[SINKNAME]