Skip to content

Instantly share code, notes, and snippets.

View GavinRay97's full-sized avatar

Gavin Ray GavinRay97

View GitHub Profile
@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;
@erijohnt
erijohnt / twitch-captions.md
Last active January 29, 2024 01:59
DIY Closed Captioning on Twitch Streams for Deaf/HoH Viewers

DIY closed captions on twitch streams for viewers

So, you're Deaf or hard of hearing and you want to watch a Twitch streamer without missing out on everything they're saying.

Ideally, the Twitch streamer you're watching will have a plugin like Twitch Captions or OBS captions plugin which both use Twitch.tv's CC feature so the captions can be toggled on/off for users who don't want them. Alternatively, they can even have closed captions

@lhorie
lhorie / write-better-tests.md
Last active June 12, 2020 12:59
Write better tests with one neat trick

Write better tests with one neat trick

TL:DR; assert your input

If you write non-trivial code, inevitably you'll run into a situation where setting up a test is not super readable. Maybe you have to mock a bunch of things, or the input data is a data structure that spans dozens of LOC, or maybe you are testing with a large-ish fixture that was defined in another file because linting or whatever.

Due to the nature of my job, I happen to read a lot of other people's code, so you can imagine how mildly annoying it is when I'm code reviewing something, and the test looks something like this:

test('codemod does what it needs to', async () =&gt; {
@postspectacular
postspectacular / 00-sigmoid-approx.ts
Last active November 2, 2019 20:31
Sigmoid versions (AssemblyScript)
// uses Math.exp() approximation from:
// https://www.musicdsp.org/en/latest/Other/222-fast-exp-approximations.html
// @ts-ignore: decorator
@inline
function fastexp9(x: f64): f64 {
// prettier-ignore
return (362880+x*(362880+x*(181440+x*(60480+x*(15120+x*(3024+x*(504+x*(72+x*(9+x)))))))))*2.75573192e-6;
}
@Tuxonomics
Tuxonomics / cpp_interfaces.md
Last active October 17, 2022 20:43
Interfaces in C++
@MattPD
MattPD / analysis.draft.md
Last active November 15, 2025 08:43
Program Analysis Resources (WIP draft)
@asereda-gs
asereda-gs / CalciteOverheadTest.java
Last active January 30, 2022 01:35
CalciteOverheadTest
import org.apache.calcite.adapter.jdbc.JdbcSchema;
import org.apache.calcite.jdbc.CalciteConnection;
import org.apache.calcite.runtime.Hook;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.commons.dbcp2.BasicDataSource;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@neomantra
neomantra / High_Performance_Redis.md
Last active October 26, 2025 23:55
Notes on running Redis with HPC techniques

High Performance Redis

In response to this brief blog entry, @antirez tweeted for some documentation on high-performance techniques for Redis. What I present here are general high-performance computing (HPC) techniques. The examples are oriented to Redis. but they work well for any program designed to be single- or worker-threaded and asynchronous (e.g. uses epoll).

The motivation for using these techniques is to maximize performance of our system and services. By isolating work, controlling memory, and other tuning, you can achieve significant reduction in latency and increase in throughput.

My perspective comes from the microcosm of my own bare-metal (vs VM), on-premises deployment. It might not be suitable for all scenarios, especially cloud deployments, as I have little experience with HPC there. After some discussion, maybe this can be adapted as [redis.io documentation](https://redis.io/do

@dino-
dino- / string-conversions.hs
Last active October 16, 2025 10:14
A handy illustration of converting between String, Text and ByteString in Haskell
#! /usr/bin/env stack
-- stack --resolver lts-18.8 script
{-# LANGUAGE OverloadedStrings #-}
{-
This is a handy illustration of converting between five of the commonly-used
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy
Text).
@BalmungSan
BalmungSan / Polymorphism.md
Last active January 30, 2025 18:34
Polymorphism in Scala.

Polymorphism in Scala

This document aims to show and compare three alternatives for achieving polymorphism in Scala.

  • Subtyping, common in object-oriented languages like Java.
  • Duck typing, common in dynamically typed languages like Python.
  • Typeclasses, common in functional languages like Haskell.

Additionally, when implementing the typeclass pattern in Scala,