Skip to content

Instantly share code, notes, and snippets.

View jirfag's full-sized avatar

Denis Isaev jirfag

View GitHub Profile
@jirfag
jirfag / action_items.csv
Created August 7, 2024 18:50
Post-mortem action items
Action item Applicability to other incidents Effectiveness for this incident Verdict
Fine-tune alerts Low High Do: low-cost
Fix the segfault bug Low High Do: root cause
Database timeout automated tests Medium-low High Do: hygiene
Retry circuit breaker or retry budget High High Implement retry budget: key action item
Circuit breaker High Medium Not an action item for now: will take in the future
Deadline propagation High Medium-high Start as a long-term project
@jirfag
jirfag / Dockerfile
Last active June 1, 2021 03:20
Kubernetes PostgreSQL backups
FROM python:alpine
RUN pip install --no-cache-dir awscli
RUN apk update && apk add postgresql
COPY dumpDb.sh .
ENTRYPOINT [ "/bin/sh" ]
CMD [ "./dumpDb.sh" ]
@jirfag
jirfag / component.tsx
Last active August 8, 2024 18:23
React/Gatsby Table of Contents
import React, { createRef } from "react"
import throttle from "lodash/throttle"
// Import styled components (see the Styles section below).
import {
TocDiv,
TocLink,
TocIcon,
TocTitle,
TocToggleOpener,
@jirfag
jirfag / k8s_connect_to_db.sh
Created March 29, 2020 17:00
Kubernetes connect to PostgreSQL
#!/bin/bash
set -ue
PGPASSWORD=$(kubectl get secret -n postgres pg-su -o jsonpath="{.data.password}" | base64 --decode)
PGUSER=$(kubectl get secret -n postgres pg-su -o jsonpath="{.data.username}" | base64 --decode)
BASH_CMD="PGPASSWORD=${PGPASSWORD} psql -h pg-stolon-proxy.postgres -U ${PGUSER} -d api_prod"
kubectl -n postgres exec -ti pg-stolon-keeper-0 -- bash -c "${BASH_CMD}"
@jirfag
jirfag / k8s_port_forward_monitoring.sh
Created March 29, 2020 16:58
Kubernetes port forwarding
#!/bin/bash
set -x
echo "grafana is in http://127.0.0.1:7000/"
echo "use login admin"
echo "use password $(kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.adminPassword}" | base64 --decode)"
kubectl -n monitoring port-forward service/prometheus-operator-grafana 7000:80
#echo "prometheus is in http://127.0.0.1:9090/"
#kubectl -n monitoring port-forward service/prometheus-operator-prometheus 9090:9090
prometheus:
prometheusSpec:
resources:
requests:
memory: 200Mi
limits:
memory: 500Mi
additionalScrapeConfigs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
@jirfag
jirfag / GolangCI_CLA.md
Last active November 20, 2022 16:25
GolangCI CONTRIBUTION LICENSE AGREEMENT

CONTRIBUTION LICENSE AGREEMENT

This Contribution License Agreement (the “CLA”) is between the individual set forth in the signature block (“You”) and Golangci OÜ, (“GolangCI”), effective as of the date of Your signature and sets forth the terms pursuant to which You provides Contributions to GolangCI.

You accept and agree to the following terms and conditions for Your present and future Contributions submitted to GolangCI. In return, GolangCI will not use Your Contributions in a way that is contrary to GolangCI’s business objectives. Except for the license granted herein to GolangCI and recipients of software distributed by GolangCI, You reserve all right, title, and interest in and to Your Contributions.

Definitions. “Contribution” means any original work of authorship, including any modifications or additions to an existing work, that You intentionally submit to GolangCI for inclusion in, or documentation of, any of the products owned or managed by GolangCI (the “Work”). “Submit” means any form of elec

@jirfag
jirfag / logger.go
Created July 1, 2018 13:20
Depguard demo in golangci-lint
package logger
import (
"github.com/sirupsen/logrus" //nolint:depguard
)
@jirfag
jirfag / .golangci.yml
Created July 1, 2018 13:17
Golangci-Lint self config's snippet
linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
@jirfag
jirfag / nakedret.go
Created July 1, 2018 13:12
Issue found by nakedret linter in Beego
func (d *dbBase) collectValues(mi *modelInfo, ind reflect.Value, cols []string, skipAuto bool, insert bool, names *[]string, tz *time.Location) (values []interface{}, autoFields []string, err error) {
if names == nil {
ns := make([]string, 0, len(cols))
names = &ns
}
values = make([]interface{}, 0, len(cols))
for _, column := range cols {
var fi *fieldInfo
if fi, _ = mi.fields.GetByAny(column); fi != nil {