Skip to content

Instantly share code, notes, and snippets.

@JonasDoe
JonasDoe / test.yml
Created April 8, 2024 18:52
Run Test for PR with /test comment
name: Test
on:
workflow_dispatch:
inputs:
used-branch:
description: Branch the test shall be run on
default: master
required: true
push:
@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 / 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 / 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"