Skip to content

Instantly share code, notes, and snippets.

Harry sonhanguyen

  • Melbourne, Australia
Block or report user

Report or block sonhanguyen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4743d4b7c479d52c43a5447f831271ee
type NumericIndex = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
type Index<T extends any[]> = NumericIndex & keyof T
type UnionToIntersection<U> =
(U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never
type Builder<State = {}> = {
(): State
<A extends string[]>(...namedArgsOrder: A): <
V extends { [K in keyof A]: any },
T = UnionToIntersection<{ [K in Index<A>]: Record<string & A[K], V[K]> }[Index<A>]>
@sonhanguyen
sonhanguyen / overload.ts
Last active Sep 20, 2019
OverloadBuilder
View overload.ts
type Func = (..._) => any
const overload = <Default extends Func>(defaultFunc: Default): OverloadBuilder<Default> => {
// @ts-ignore
const match = cases => Object.assign(
(...args) => {
const matcher = cases.find(([ guard ]) => guard(args))
const func = matcher
? matcher[1]
: defaultFunc
@sonhanguyen
sonhanguyen / Default.bttpreset
Created Jul 20, 2019
Better touch tool setup for window management
View Default.bttpreset
{
"BTTPresetName" : "Default",
"BTTGeneralSettings" : {
"disableScrollingIf3" : true,
"BTTPasteWhenTriggeringClipboardAgain" : true,
"BTTForceNormalClickPressure5F" : 200,
"disableScrollingIf2" : true,
"BTTDidRegisterForUpdateStats" : "3.140",
"BTTShowControlStrip" : true,
"BTTShowControlStripItem" : true,
@sonhanguyen
sonhanguyen / Variants.ts
Created Sep 24, 2018
What enum should've been
View Variants.ts
type Literal = string | number | symbol | {}
const Literal = <T extends Literal>(val: T) => val
const Variants = <T extends Literal[]>(...variants: T) => variants
type Variants<T extends Literal[]> = T[number]
const Enum = Variants('a', 'b', {a: Literal('b')})
type Enum = Variants<typeof Enum>
@sonhanguyen
sonhanguyen / app.tsx
Last active Sep 7, 2018
Services in React's new context API
View app.tsx
import * as React from 'react'
import { render } from 'react-dom'
import { compose, fromRenderProps } from 'recompose'
import { identity, pick, mapValues } from 'lodash'
const withDependencies = (...services: Array<[any, Function]>) => {
const enhance = compose(
...services.map(([service, mapProps]) => fromRenderProps(
Service.contextFor(service).Consumer,
mapProps
View Main.scala
import com.river11576.transcript_search._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
object Main {
// https://www.wordhunt.xyz/api/freemium?phrase=test
def main(argv: Array[String]) = {
print(
Await.result(
View side panel style for using with Tree Tabs
/*#region Vivaldi */
#browser:not(.is-settingspage) > #header {
min-height: 0 !important;
height: 0;
}
#panels-container #panels > #switch {
-webkit-app-region: drag;
}
View App.tsx
import * as React from 'react'
import Grid from './Grid'
import './App.css'
interface BaseLineItem {
id: string
name: string
cost: number
}
@sonhanguyen
sonhanguyen / mobX.md
Created Nov 16, 2017
use revealjs to view
View mobX.md

MobX


"How I learn to love React" cliche

  • What it is
  • Why do we need it
  • How do we use it
  • Some gotchas
  • Demo
View NexusFolder.ahk
/*
## NexusFolder.ahk
##
## Switch default filemanager by launching this script without
## commandline parameters. If you send a file or folder as a
You can’t perform that action at this time.