Skip to content

Instantly share code, notes, and snippets.

@paprikati
paprikati / gist:82c58b025e3e7a0ce685e9e441f5970f
Created October 19, 2023 08:46
react-hook-form setValue bug repro
import "./styles.css";
import {
useForm,
FormProvider,
useController,
useFormContext
} from "react-hook-form";
import React, { useState } from "react";
import ReactAsyncSelect from "react-select/async";
@paprikati
paprikati / readme.MD
Last active March 18, 2023 21:35
safedb: using a gorm hook to check that queries are scoped by organisation ID

SafeDB

This gist is associated with the blog post "Building safe-by-default tools in our Go web application".

It contains the gorm hooks that we use to ensure our queries are correctly scoped.

@paprikati
paprikati / error_with_urgency.go
Last active April 13, 2022 10:09
At incident.io, we use Sentry to manage our exceptions, and PagerDuty to handle our on-call rota and escalate to an engineer. This code allows us to set the 'urgency' on an error, and apply rules in Sentry so we don't page on specific errors.
package errors
import "context"
// ErrorWithUrgency represents an error with a specified urgency. We currently
// support two urgencies:
// page - this means we will escalate to the on-call engineer. This is the default behaviour.
// sentry - this means we will send it to Sentry, but won't page someone.
type ErrorWithUrgency struct {
cause error
@paprikati
paprikati / check_organisation_scope.go
Last active December 3, 2021 15:55
CheckOrganisationScope: using middleware to check that API responses are scoped by organisation ID
package mw
import (
"context"
"reflect"
"github.com/incident-io/core/server/api/gen/billing"
"github.com/incident-io/core/server/api/gen/insights"
"github.com/incident-io/core/server/api/gen/system"
"github.com/incident-io/core/server/api/gen/typeaheads"
{
"content": [
{
"text": "Long Text",
"style": "h1",
"margin": [
5,
5,
5,
20
@paprikati
paprikati / test_pdf.json
Created November 6, 2019 12:42
PDF Make unbreakable test
{
"content": [
{
"text": "Long Text",
"style": "h1",
"margin": [
5,
5,
5,
20