Skip to content

Instantly share code, notes, and snippets.

View disintegrator's full-sized avatar

Georges Haidar disintegrator

View GitHub Profile
@disintegrator
disintegrator / typescriptreact.json
Created December 18, 2020 10:11
VS Code snippets
{
"React function component": {
"prefix": "nrf",
"body": [
"import * as React from \"react\";",
"",
"export interface ${1:$TM_FILENAME_BASE}Props {}",
"",
"const ${1:$TM_FILENAME_BASE}: React.FC<${1:$TM_FILENAME_BASE}Props> = props => {",
" return <>{props.children}</>;",
@disintegrator
disintegrator / example_1.html
Created December 11, 2020 15:11
Having Fun with Markdown and Remark
<h1>I am a level 1 heading</h1>
<p class="subtitle subtitle--1">I am a level 1 subtitle</p>
<p class="subtitle subtitle--2">I am a level 2 subtitle</p>
<p class="subtitle subtitle--6">
Up to six levels are supported corresponding to heading levels
</p>
@disintegrator
disintegrator / propTypes.ts
Created September 5, 2018 22:29
Get the prop types of a react component class, functional component or string corresponding to HTML tag name
import * as React from "react";
/**
* Given a JSX.IntrinsicElement[...], get its attributes
*/
type Attributes<E> = E extends React.DetailedHTMLProps<infer Attr, any>
? Attr
: never;
/**
@disintegrator
disintegrator / main.ts
Last active November 14, 2020 06:58
RxJS + Axios
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Observable } from 'rxjs';
const fromRequest = (request: AxiosRequestConfig) =>
new Observable<AxiosResponse>(
(o) => {
const source = axios.CancelToken.source();
o.add(() => source.cancel('Operation canceled by the user.'));
@disintegrator
disintegrator / pino.d.ts
Created September 24, 2020 12:53
An example TypeScript declaration file that demonstrates how to augment the type definitions of a third party library.
import "pino";
declare module "pino" {
interface LoggerOptions {
// @types/pino does not currently expose this option
nestedKey?: string;
}
}
@disintegrator
disintegrator / PropType.tsx
Created May 1, 2018 22:46
PropType conditional type inference in TypeScript
import { ComponentType } from "react";
/**
* For any type T that is a React.ComponentType give me the type of its Props
*
*/
export type PropType<T> = T extends ComponentType<infer P> ? P : never;
// USAGE:
import { Component, Fragment } from "react";
@disintegrator
disintegrator / Value.ts
Last active April 26, 2018 12:23
Value component
import * as React from "react";
interface Props<T> {
initial?: T;
children: (r: { value?: T; onChange: (value: T) => void }) => React.ReactNode;
}
interface State<T> {
value?: T;
}
@disintegrator
disintegrator / redux.ts
Created May 11, 2017 23:25
Redux TS boilerplate
export type ActionType = string;
export interface Action<T extends ActionType> {
type: T;
}
export interface BasicAction<T extends ActionType, P> extends Action<T> {
payload: P;
}
@disintegrator
disintegrator / Cassandra-OpsCenter-Compose.md
Last active October 12, 2016 11:35
OSX: 3-node Cassandra cluster + OpsCenter using Docker Compose
brew install boot2docker
eval $(boot2docker shellinit)
boot2docker up
sudo pip install -U docker-compose

# put the docker-compose.yml file in a directory e.g. ~/Work/docker/cassandra

cd ~/Work/docker/cassandra
docker-compose up

Keybase proof

I hereby claim:

  • I am disintegrator on github.
  • I am disintegrator (https://keybase.io/disintegrator) on keybase.
  • I have a public key whose fingerprint is B27D E9C9 E08C A86E F46B 84FA F60F 7D8E 4BAD 4281

To claim this, I am signing this object: