Skip to content

Instantly share code, notes, and snippets.

View erdii's full-sized avatar
🪤

Josh Gwosdz erdii

🪤
View GitHub Profile
@erdii
erdii / multiwrap_test.go
Created September 5, 2023 22:32
Wrapping multiple errors in go
package playground
import (
"errors"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
package dev
import (
"context"
"fmt"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@erdii
erdii / crd_upgrade.sh
Created August 4, 2023 15:55
package-operator CRD v1.6.6 to v1.7.0 upgrade fix
#!/bin/bash
set -euxo pipefail
PKO_NAMESPACE="package-operator-system"
PKO_POD_SELECTOR="app.kubernetes.io/name=package-operator"
PKO_COS_SELECTOR="package-operator.run/package=package-operator"
# get rid of currently running PKO
kubectl delete deploy -n "$PKO_NAMESPACE" package-operator-manager
@erdii
erdii / retry.go
Created August 2, 2023 09:45
golang retry func() error
package retry
import (
"context"
"fmt"
"time"
"github.com/go-logr/logr"
)
@erdii
erdii / deployment.yaml
Last active September 8, 2023 21:42
jiralert manifests for kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: jiralert
namespace: default
spec:
selector:
matchLabels:
app: jiralert
template:
@erdii
erdii / ensure_pip
Last active July 18, 2020 22:11
import functions
ensure_pip() {
pip show "$1" > /dev/null || pip install "$1"
}
@erdii
erdii / README.md
Last active March 28, 2020 23:53
vlan interface with NetworkManager on Ubuntu Desktop 19.10

generate uuid

uuidgen -r

rights and location

# /etc/NetworkManager/system-connections $ ls -l vlan20
-rw------- 1 root root 145 Mär 28 18:27 vlan20
@erdii
erdii / aws.yaml
Last active March 22, 2021 18:20
allow an entity to: log into ecr and push images intp a specific repo, then create/update a task-definition, and then create/update a service in a specific ecs cluster
# place into .github/workflows/aws
# This workflow will build and push a new container image to Amazon ECR,
# and then will deploy a new task definition to Amazon ECS, on every push
# to the master branch.
#
# To use this workflow, you will need to complete the following set-up steps:
#
# 1. Create an ECR repository to store your images.
# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`.
# Replace the value of `ECR_REPOSITORY` in the workflow below with your repository's name.
@erdii
erdii / node-cache_clone-engine-bench.js
Created October 25, 2019 17:28
just something for demonstration
const NodeCache = require("node-cache");
const obj = {
_id: "5c7e533ce75227089bd93bbb",
texts: [
{ keywords: ["hi", "there"], language: "FR", title: "Art", description: "" },
{ keywords: [], language: "EN", title: "Art", description: "" },
],
extension: "jpg",
fileDate: "2019-03-18T17:38:52.553Z",
@erdii
erdii / copy_elasticsearch_index_to_other_server.sh
Last active December 28, 2022 10:43
Copy an elasticsearch index definition (settings and mapping - no data) to another server
# copy index definition
INDEX_NAME="my_index"
curl -X GET "http://source-server:9200/$INDEX_NAME" | curl -X PUT "http://destination-server:9200/$INDEX_NAME" -d @-
# copy mapping for "my_doc_type"
DOC_TYPE="my_doc_type"
curl -X GET "http://source-server:9200/$INDEX_NAME/_mapping" | jq .$INDEX_NAME.mappings.$DOC_TYPE | curl -X PUT "http://destination-server:9200/$INDEX_NAME/_mapping/$DOC_TYPE" -d @-