Skip to content

Instantly share code, notes, and snippets.

View dagda1's full-sized avatar

Paul dagda1

View GitHub Profile
export interface Tab<TProps = unknown> {
title: string;
content: TProps extends React.HTMLAttributes<TProps>
? React.ReactNode
: React.ReactElement<TProps & { viewMode: ViewMode }>;
popout?: boolean;
}
type PartialDeep<T> = {
[ P in keyof T ]?: PartialDeep<T[ P ]>;
}
type PartialRestoreArrays<K> = {
[ P in keyof K ]?: K[ P ];
}
@dagda1
dagda1 / t.js
Created December 3, 2018 22:38
'use strict';
const fs = require('fs');
const path = require('path');
/* const input = '#1 @ 1,3: 4x4\n#2 @ 3,1: 4x4\n#3 @ 5,5: 2x2\n'; */
const input = fs.readFileSync(path.join(__dirname, 'day3.txt')).toString();
const lines = input.split('\n').slice(0, -1);
export type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
@dagda1
dagda1 / .zshrc
Created September 20, 2018 07:25
plugins=(
zsh-nvm
git
iterm2
colored-man-pages
yarn
vscode
frontend-search
zsh-autosuggestions
zsh-history-substring-search
import * as React from 'react';
import { range } from 'lodash';
import { Point } from '../../model/point';
import { degreesToRadians } from '../../util/trigonometry';
export enum HexagonType {
flat = 'flat',
pointy = 'pointy'
}
@dagda1
dagda1 / user.js
Last active August 5, 2018 18:42
typed grapql
import { AutoIncrement, Column, CreatedAt, Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript';
import { Field, ObjectType, ID, InterfaceType } from 'type-graphql';
@ObjectType()
@Table({ tableName: 'users', timestamps: true, freezeTableName: false })
export class User extends Model<User> {
@Field((type) => ID)
@PrimaryKey
@AutoIncrement
@Column
export type MapMapStateToProps<T, K extends keyof T, S> = MapStateToProps<Pick<T, K>, Exclude<T, K>, S>;
// usage
const mapStateToProps: MapMapStateToProps<MyComponentProps, 'someProp' | 'andAnother', State> = state => ({
someProp: selector(state),
andAnother: anotherSelector(state)
});
export declare type MapMapStateToProps<T, K extends keyof T, S> = MapStateToProps<Pick<T, K>, Exclude<T, K>, S>;
const mapStateToProps: MapMapStateToProps<MyComponentProps, 'someProp' | 'andAnother|, State> = state => ({
someProp: selector(state),
andAnother: anotherSelector(state)
});
export declare type MapMapStateToProps<T, K extends keyof T, S> = MapStateToProps<Pick<T, K>, Exclude<T, K>, S>;
const mapStateToProps: MapMapStateToProps<MyComponentProps, 'someProp' | 'andAnother|, State> = state => ({
someProp: selector(state),
andAnother: anotherSelector(state)
});