Skip to content

Instantly share code, notes, and snippets.

View GavinRay97's full-sized avatar

Gavin Ray GavinRay97

View GitHub Profile
@danngreen
danngreen / Makefile-compilecommands.mk
Created November 24, 2020 20:45
Makefile command to generate compile_commands.json with entries for c++ headers
# Addresses an issue where language servers won't know what to do with header files
# since compile_commands.json typically only includes .cc/.cpp/.c files.
#
# Include this file from your main Makefile, or just paste the snippet in.
# To use:
# make compile_commands
# Requires bear and compdb
# bear [osx]: brew install bear
# compdb [see https://github.com/Sarcasm/compdb]: pip install compdb
@bokwoon95
bokwoon95 / comments.sql
Last active February 28, 2025 17:38
how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- The comment tree:
-- [1]
-- / \
-- [2] [4]
-- / \ \
-- [3] [7] [6]
-- /
-- [5]
@webstrand
webstrand / 000~nonempty-validator.ts
Last active May 27, 2025 21:28
Examples of the <T>(foo: Validator<T>) pattern in typescript
/******************************************************************************
* Implementation of `Nonempty` validator which checks that the provided type
* has at least one defined property, excluding `{}`.
******************************************************************************/
type Nonempty<T extends { [key: string]: any }> = { [P in keyof T]: T }[keyof T];
declare function wantsNonempty<T extends { [key: string]: any }>(x: Nonempty<T>): true;
wantsNonempty({ x: 1 });
wantsNonempty({}); // error expected
@michaelbutler
michaelbutler / Steam_Proton_Exe.md
Last active June 16, 2025 06:52
How to run another .exe in an existing proton wine prefix

Running games through Steam's Proton is great. But what if there is a secondary exe or configuration application bundled with the game? How can you launch it if Steam itself only launches the game?

Simply run this command in a terminal:

cd /path/to/steam/steamapps/compatdata/20920/pfx

STEAM_COMPAT_DATA_PATH="/path/to/steam/steamapps/compatdata/20920" WINEPREFIX=$PWD \
    "$HOME/.steam/root/steamapps/common/Proton 5.0/proton" run ./drive_c/path/to/custom_application.exe
@baohouse
baohouse / GraphiQLExplorer.tsx
Last active January 21, 2021 22:08
Fork of graphiql-explorer 0.4.5 to support list types and object-based custom args
/**
* Copied from https://github.com/OneGraph/graphiql-explorer (0.4.5)
* We fork because we need to support customizable fields and could not wait for
* the PR process to finish. Also converted Flow type to TypeScript.
*/
import { Tooltip } from 'antd';
import prettier from 'prettier/standalone';
import parserGraphql from 'prettier/parser-graphql';
import React, { Fragment } from 'react';
@frowrik
frowrik / ImGui_Piano_imp.h
Last active June 3, 2024 02:41
Piano keyboard for ImGui v1.0
/*
The MIT License (MIT)
by https://github.com/frowrik
Piano keyboard for ImGui v1.1
example:
static int PrevNoteActive = -1;
ImGui_PianoKeyboard("PianoTest", ImVec2(1024, 100), &PrevNoteActive, 21, 108, TestPianoBoardFunct, nullptr, nullptr);
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
const Allocator = mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const SegmentedList = std.SegmentedList;
pub const Attribute = struct {
name: []const u8,
value: []const u8

The following sets up a local k3d cluster and deploys Postgres and Hasura GraphQL Engine.

NOTE: All data will be lost when containers restart

# Create the cluster mapping NodePorts to Host ports and set KUBECONFIG
k3d create --publish 5432:30032 --publish 8080:30080 --workers 2
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"

# Deploy postgres
@onamfc
onamfc / AccessToken.php
Last active September 19, 2024 10:18
Add Custom Claims to Passport 8 / Laravel 6
<?php
namespace App\Passport;
use App\User;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use League\OAuth2\Server\CryptKey;
use Lcobucci\JWT\Signer\Rsa\Sha256;
use Laravel\Passport\Bridge\AccessToken as BaseToken;