Skip to content

Instantly share code, notes, and snippets.

View tanepiper's full-sized avatar

Tane Piper tanepiper

View GitHub Profile
@jexp
jexp / graphrag-load-neo4j-1.ipynb
Last active July 20, 2024 03:51
Quick Neo4j Loaders for GraphRAG Parquet
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hyperupcall
hyperupcall / settings.jsonc
Last active July 21, 2024 10:53
VSCode config to disable popular extensions' annoyances (telemetry, notifications, welcome pages, etc.)
// I'm tired of extensions that automatically:
// - show welcome pages / walkthroughs
// - show release notes
// - send telemetry
// - recommend things
//
// This disables all of that stuff.
// If you have more config, leave a comment so I can add it!!
{
@ClickerMonkey
ClickerMonkey / types.ts
Last active June 18, 2024 17:13
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@MarsiBarsi
MarsiBarsi / replay-control-value-changes.ts
Last active November 3, 2022 00:04
replay-control-value-changes.ts
export class ReplayControlValueChanges<T> extends Observable<T> {
constructor(control: AbstractControl | AbstractControlDirective) {
super(subscriber => {
if (!control.valueChanges) {
throw new Error('Control does not have valueChanges');
}
control.valueChanges.pipe(startWith(control.value)).subscribe(subscriber);
});
}
@busypeoples
busypeoples / validation.ts
Created February 10, 2020 14:50
Validation in TS (version 2)
type ValidationResult<T, U> = Partial<{ [Key in keyof T]: U }>;
type Validation<T, U> = (fields: T) => ValidationResult<T, U>;
const validate = <T, U = boolean | string>(
validations: Validation<T, U>[],
fields: T
): ValidationResult<T, U> =>
validations
.map(validation => validation(fields))
.reduce((acc, a) => Object.assign(acc, a), {});
@hmil
hmil / tuples.ts
Created September 20, 2018 16:34
Well-typed variable-length tuples in TypeScript
/**
* Arbitrary-length tuples
* =======================
*
* Working with tuples of unknown length in TypeScript is a pain. Most library authors fall back on enumerating all possible
* tuple lengths up to a threshold (see an example here https://github.com/pelotom/runtypes/blob/fe19290d375c8818d2c52243ddc2911c8369db37/src/types/tuple.ts )
*
* In this gist, I'm attempting to leverage recursion to provide support for arbitrary length tuples. This has the potential
* to make some kinds of declarative APIs nicer and enhance type inference in some cases.
* This example shows how to take a variable-length tuple as an input, transform each of its types and use the resulting
@KSXGitHub
KSXGitHub / tuple-utils.ts
Last active September 12, 2018 11:23
Tuple generic
export namespace TupleUtils {
/**
* Get type of first element
* @example `First<[0, 1, 2]>` → `0`
*/
export type First<Tuple extends [any, ...any[]]> = Tuple[0]
/**
* Get type of last element
@markstuart
markstuart / ng-serve-docker-nginx-proxy.md
Last active October 29, 2018 22:22
Running Angular CLI in local dev behind docker nginx reverse proxy

Setup

Angular app talking to multiple microservices using Cookie authentication on ajax requests. Cookies are not passed over cross domain ajax requests, so we need to be able to have the Angular app and microservices running on same-domain in local dev as well as in production.

We have a Docker nginx proxy running on localhost:8000:

  • proxying to multiple microservices on localhost:8000/api/<microservice>
  • proxying other requests to Angular CLI (ng serve) on en0 inet (192.168.1.5 for instance) port 4200
  • using a python script to get the correct en0 IP and write it to the nginx config at proxy startup
@rendro
rendro / parsecookie.js
Last active May 4, 2024 15:38
Parse document.cookie into object
document.cookie.split(';').map(function(c) {
return c.trim().split('=').map(decodeURIComponent);
}).reduce(function(a, b) {
try {
a[b[0]] = JSON.parse(b[1]);
} catch (e) {
a[b[0]] = b[1];
}
return a;
}, {});
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active June 30, 2024 04:14
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html