Skip to content

Instantly share code, notes, and snippets.

@JonasDoe
JonasDoe / timeout_test.go
Last active January 9, 2020 18:56
Middleware timeouts don't not help against a faulty client
package demo
import (
"context"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"testing"
@JonasDoe
JonasDoe / AESEncryptionDecryption.go
Last active November 13, 2022 09:24
Full example of how to use AES with CBC mode and PKCS7 padding
package function
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
@JonasDoe
JonasDoe / redux.ts
Last active November 25, 2022 17:49
React-Redux with TypeScript
import { configureStore, createSlice, PayloadAction } from '@reduxjs/toolkit';
import { useSelector, useDispatch } from 'react-redux';
export const mySlice = createSlice({
name: 'MyItem',
initialState: { field1: 'hello, world', field2: 0 },
reducers: {
setField: (state: { field1: string; field2: number }, action: PayloadAction<string>) => {
state.field1 = action.payload;
},
@JonasDoe
JonasDoe / test.yml
Last active February 26, 2025 17:42
Run Test for PR with /test comment
name: Test
on:
push:
branches: ['main', 'master']
tags: ['!**']
issue_comment:
types: [created]
jobs: