Skip to content

Instantly share code, notes, and snippets.

View jhaynie's full-sized avatar

Jeff Haynie jhaynie

View GitHub Profile
@jhaynie
jhaynie / prisma.ts
Created November 2, 2022 13:49
Terrible hack to get Prisma to work with Cockroach transaction retries
import { AsyncLocalStorage } from 'async_hooks';
import { Prisma, PrismaClient } from '@prisma/client';
const asyncLocalStorage = new AsyncLocalStorage();
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
const maxRetryCount = 5;
const retryableErrorCodes = ['P1001', 'P2028', 'P2010', 'P2034', '40001'];
const isRetryable = (code: string) => retryableErrorCodes.includes(code);
@jhaynie
jhaynie / prisma.ts
Last active October 24, 2022 22:58
Example prisma retry
import { Prisma, PrismaClient } from '@prisma/client';
const sleep = (val: number) => new Promise((resolve) => setTimeout(resolve, val));
const maxRetryCount = 5;
const retryableErrorCodes = ['P1001', 'P2028', 'P2010', 'P2034', '40001'];
const isRetryable = (code: string) => retryableErrorCodes.includes(code);
const backoffMs = 100;
type TxCallback<R> = (
@jhaynie
jhaynie / install_github_runner.sh
Created April 14, 2022 16:05
install github runner
mkdir actions-runner && cd actions-runner# Download the latest runner package
curl -o actions-runner-linux-x64-2.289.2.tar.gz -L https://github.com/actions/runner/releases/download/v2.289.2/actions-runner-linux-x64-2.289.2.tar.gz# Optional: Validate the hash
tar xzf ./actions-runner-linux-x64-2.289.2.tar.gz
@jhaynie
jhaynie / test.json
Last active March 25, 2021 18:31
test
{"a":5}
@jhaynie
jhaynie / install.ps1
Created July 8, 2018 00:41
install agent on windows
Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/pinpt/agent/master/install.ps1'))
##
## This is the installer for the Pinpoint Agent.
##
## For more information, see: https://github.com/pinpoint/agent
##
## This script was adapted from https://github.com/buildkit/agent
$installDir = "C:\pinpoint-agent"
$arch = "amd64"
$ErrorActionPreference = "Stop"
@jhaynie
jhaynie / airflow_config.go
Created March 25, 2017 06:15 — forked from kozikow/airflow_config.go
Airflow config
// Generate airflow config to stdout.
// To start service the from scratch, put this in src/airflow_config/airflow_config.go and run:
// export GOPATH=$(pwd)
// export PATH=$PATH:$GOPATH/bin
// go get k8s.io/client-go/1.4/kubernetes
// go install airflow_config && airflow_config > airflow.yaml
// kubectl create -f airflow.yaml
package main
import (
@jhaynie
jhaynie / keybase.md
Created February 10, 2017 17:28
My keybase

Keybase proof

I hereby claim:

  • I am jhaynie on github.
  • I am jhaynie (https://keybase.io/jhaynie) on keybase.
  • I have a public key ASBm7VnUGbfzuKnIG-1HQW_oANnKwse2nb1D4RK5a77aOAo

To claim this, I am signing this object:

@jhaynie
jhaynie / example.spec.js
Last active September 4, 2023 14:35
Cypress.io login to github with node app using passport
import url from 'url';
describe('Login', function() {
it('cy.should - assert that <title> is correct', function() {
cy.visit('http://localhost:5001');
cy.get('#login').should('contain', 'Login with Github');
cy.request({
url: '/login',
followRedirect: false
})
@jhaynie
jhaynie / gist:b3dc157d197f3115614a
Created April 7, 2015 01:57
Example for Arrow using File
var Arrow = require('arrow');
var API = Arrow.API.extend({
group: 'file',
path: '/api/fileexample',
method: 'POST',
nickname: 'fileexample',
description: 'Example for file upload',
parameters: {
file: {description:'file to publish', type:'body'}