Skip to content

Instantly share code, notes, and snippets.

View GavinRay97's full-sized avatar

Gavin Ray GavinRay97

View GitHub Profile
@GavinRay97
GavinRay97 / Makefile
Created August 24, 2020 00:42
Hasura SQL + Metadata models CLI script
.PHONY: generate_sql generate_tables_yaml generate_schema_and_tables_metadata
generate_sql: ## Generate single SQL file schema from all models
ruby ./generate-sql.rb \
--identifiers '/* TABLE */,/* FOREIGN KEYS */,/* TRIGGERS */' \
--out schema.sql \
./models/**/**.sql
generate_tables_yaml: ## Generate tables.yaml file from all models
ruby ./generate-tables-metadata.rb \
@GavinRay97
GavinRay97 / notes.md
Created September 1, 2020 17:23
Yarn 2 Berry notes - VS Code, Typescript, node_modules compatibility

Set yarn to use V2/Berry in project:

  • yarn set version berry

Add Typescript plugin for automatically fetching @types/<pkg> definition when package doesn't include them:

  • yarn plugin import typescript

To use the PnP setup with VS Code, and not retain node_modules compatibility, run:

  • yarn add @yarnpkg/pnpify --dev
  • yarn pnpify --sdk vscode
@GavinRay97
GavinRay97 / docker-compose.yaml
Created August 27, 2020 16:59
Hasura GraphQL Tx over Websockets client
version: '3.6'
services:
postgres:
image: postgres:12
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
@GavinRay97
GavinRay97 / index.ts
Created September 4, 2020 01:44
GraphQL Zeus + Apollo Client typings integration
import {
ApolloProvider,
gql,
MutationHookOptions,
QueryHookOptions,
SubscriptionHookOptions,
useMutation,
useQuery,
useSubscription,
} from "@apollo/client";
@GavinRay97
GavinRay97 / main.go
Created September 12, 2020 19:04
CloudFormation RDS type
// This file was generated from Typescript using quicktype, do not modify it directly.
// To parse and unparse this JSON data, add this code to your project and do:
//
// cloudFormationRDSDBInstance, err := UnmarshalCloudFormationRDSDBInstance(bytes)
// bytes, err = cloudFormationRDSDBInstance.Marshal()
//
// dBEngine, err := UnmarshalDBEngine(bytes)
// bytes, err = dBEngine.Marshal()
//
// dBInstanceProperties, err := UnmarshalDBInstanceProperties(bytes)
@GavinRay97
GavinRay97 / README.md
Last active September 30, 2020 15:20
Hasura MySQL Test Setup

Put the docker-compose.yaml into a new folder, along with a folder called /migrations. Put the sample SQL in there at /migrations/any-name.sql. This will seed the MySQL DB on startup.

Run docker-compose up -d, and visit Hasura at http://localhost:8080

Note: If you would like to a connect to an existing MySQL DB running outside of Docker on localhost, you will need to edit the configuration for the Hasura service so that it uses host networking. Then use localhost for the --mysql-host argument. Also, in order for Hasura on localhost to connect to the Docker Postgres instance, you'll need to add 5432:5432 to the service port configurations for postgres so that it's exposed, then change the DB URL to postgres://postgres:postgrespassword@localhost:5432/postgres.

services:
  graphql-engine:
 # ...
package mypackage
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.internal.*
typealias CustomColumnNames = HashMap<String, String>
typealias ColumnPresetsExpression = HashMap<String, String>
typealias RemoteField = HashMap<String, RemoteFieldValue>
typealias InputArguments = HashMap<String, String>
@GavinRay97
GavinRay97 / VitalSample.types.ts
Created February 13, 2021 05:29
Vital .vital sample Type Definition example
export interface VitalPresetTypes {
author: string;
comments: string;
macro1: string;
macro2: string;
macro3: string;
macro4: string;
preset_style: PresetStyle;
settings: { [key: string]: SettingElement[] | Sample | number };
synth_version: string;
@GavinRay97
GavinRay97 / script.py
Created February 21, 2021 14:03
Python - Convert directory of drumkit single-instrument MIDI parts to General MIDI drumkits
#!/usr/bin/env python3
import pathlib
from glob import glob
from dataclasses import dataclass
from mido import MidiFile, MidiTrack, merge_tracks
from typing import Dict, List
pathlib.Path("./_Processed").mkdir(parents=True, exist_ok=True)
@GavinRay97
GavinRay97 / omnisharp.json
Created March 3, 2021 00:15
C# - Omnisharp settings for not-fucked-up, terrible, awful formatting (IE like JS/TS/Java/Swift/literally every other C-based language)
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInAccessors": false,