Skip to content

Instantly share code, notes, and snippets.

View patrixr's full-sized avatar
🌱
Slow growth

Patrick R patrixr

🌱
Slow growth
View GitHub Profile
const { execSync } = require('child_process');
const files = execSync(`git --no-pager diff --name-only HEAD HEAD~1`).toString().split('\n');
const extensions = {}
const identity = (i) => i
const upper = (s) => s.toUpperCase()
files.forEach(f => {
@patrixr
patrixr / lazy.ts
Created January 22, 2021 02:38
Typescript Spec Lazy Vars
import _ from 'lodash'
interface LazyVarEntry<T = any> {
gen : () => T,
val? : T
}
interface LazyCache {
[key: string]: LazyVarEntry[]
}
import React, { useState } from "react";
type Maybe<T> = T | null;
type AnyFunction = (...args: any[]) => any;
type Awaited<T> = T extends { then(onfulfilled: (value: infer U) => any): any }
? U
: T extends { then(...args: any[]): any }
? never
import React, { useState } from "react";
// -------------------------
// Typing
// -------------------------
type Maybe<T> = T | null;
type AnyFunction = (...args: any[]) => any;
@patrixr
patrixr / matcher.ts
Last active February 3, 2021 07:22
Lodash & Typescript pattern matching
import _, { LoDashStatic } from 'lodash'
type PredicateMethod = (
"has" |
"isEqual" |
"isString" |
"isObject" |
"isArray" |
"isBoolean" |
"isMatch"
//
// E2E Test Setup
// e2e_helpers.js
//
import { getMainDefinition } from '@apollo/client/utilities'
import { AuthPayload } from '../../lib/typings/goodchat'
import { WebSocketLink } from '@apollo/client/link/ws'
import { promisify } from 'util'
import fetch from 'cross-fetch'
@patrixr
patrixr / docker-compose.yml
Last active May 25, 2021 08:22
GoodChat Docker Compose
version: "3.9"
services:
goodchat:
image: goodregistry.azurecr.io/goodchat/goodchat:latest
ports:
- "8000:8000"
environment:
- PORT=8000
- GOODCHAT_AUTH_URL=https://api-staging.goodcity.hk/api/v2/auth/goodchat
- DB_HOST=postgres_goodchat
@patrixr
patrixr / useAsync.ts
Last active August 4, 2021 07:57
Vue UseAsync
import { onMounted, ref } from 'vue'
type AsyncFunc = () => Promise<any>
type ReturnType<F extends AsyncFunc> = F extends () => Promise<infer R> ? R : any
type UseAsyncOptions = {
lazy?: boolean
}
@patrixr
patrixr / testMatrix.ts
Last active August 11, 2021 07:50
Typed Test Matrix
// ---------------------------
// ~ Helpers
// ---------------------------
const capitalize = (s : string) => s.charAt(0).toUpperCase() + s.slice(1);
// ---------------------------
// ~ TYPES
// ---------------------------
@patrixr
patrixr / sample.txt
Created September 26, 2021 02:43
Tezos link
I am attesting that this GitHub handle patrixr is linked to the Tezos account tz1WPQ824uvHhzp95sZVRnWPjfgBtLarDgVL for tzprofiles
sig:edsigtiRUPezs6RP74tssQbRFsg5E1VjsCxBV7TEEgpq53EESWPphbsx9fhiy9aLSGfGqJbarPQ2sHeKX3zsBwXiaMiVe2qwS3g