Skip to content

Instantly share code, notes, and snippets.

Create self-signed certificate

openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout server.key -out server.crt -subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"

View certificate and key

Certificate

@ofen
ofen / go-gitlab-ci.yml
Last active March 31, 2022 16:16
.gitlab-ci.yml for golang projects w/ private modules
---
build:
variables:
GOPRIVATE: git.example.com/*
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
script:
- mkdir -p /kaniko/.docker
@ofen
ofen / Dockerfile
Created September 29, 2020 15:28
AIOHTTP alpine docker
FROM python:3-alpine
WORKDIR /app
COPY . .
RUN adduser appuser --disabled-password \
--gecos "" --home /nonexistent \
--shell /sbin/nologin --no-create-home \
--uid 1000 \
@ofen
ofen / Go.sublime-build
Created September 23, 2020 08:58
"gofmt + go run" Sublime Text 3 build system
{
"shell_cmd": "gofmt -w \"$file\" && go run \"$file\"",
"selector": "source.go",
"file_regex": "go$"
}
@ofen
ofen / backtick-surround.json
Last active July 16, 2020 08:38 — forked from beechnut/backtick-surround.js
Surround with backticks in Sublime Text 3
// Copy the following into Preferences > Key Bindings -- User
// Thanks to:
// http://sublimetext.userecho.com/topic/86166-backtick-quoting-selected-text-does-not-work-like-single-quotes-and-double-quotes/
[
{
"keys": [
"`"
],
"command": "insert_snippet",
@ofen
ofen / _helper.tpl
Last active May 12, 2023 08:40
Helm helper to convert label map to comma-separated string
{{/*
Convert labels to string like: key1="value1", key2="value2", ...
*/}}
{{- define "chart.external_labels" -}}
{{- $list := list -}}
{{- range $k, $v := .Values.external_labels -}}
{{- $list = append $list (printf "%s=\"%s\"" $k $v) -}}
{{- end -}}
{{ join ", " $list }}
{{- end -}}
@ofen
ofen / monokai-dark.theme
Last active July 9, 2020 17:42 — forked from tsbarnes/monokai-dark.theme
Monokai color scheme for XFCE4 terminal, place it in /usr/share/xfce4/terminal/colorschemes
[Scheme]
Name=Monokai (dark)
TabActivityColor=#a6a6e2e22e2e
ColorCursor=#f8f8f8f8f2f2
ColorForeground=#f8f8f8f8f2f2
ColorBackground=#272728282222
ColorPalette=#272728282222;#f9f926267272;#a6a6e2e22e2e;#f4f4bfbf7575;#6666d9d9efef;#aeae8181ffff;#a1a1efefe4e4;#f8f8f8f8f2f2;#757571715e5e;#f9f926267272;#a6a6e2e22e2e;#f4f4bfbf7575;#6666d9d9efef;#aeae8181ffff;#a1a1efefe4e4;#f9f9f8f8f5f5
@ofen
ofen / fetch_grafana.sh
Last active July 7, 2020 12:27
Export Grafana dashboards via API
#!/usr/bin/env bash
HOST="http://grafana.local:3000"
mkdir dashboards && \
for dashboard in $(wget -qO- "$HOST/api/search?query=&" | jq -r .[].uri); do
wget -qO- "$HOST/api/dashboards/$dashboard" | jq -r '.dashboard | del(.uid)' > dashboards/"$(basename "$dashboard")".json
done
@ofen
ofen / webhook.groovy
Created June 23, 2020 08:15
Jenkins Glip webhook notification
def glip(java.util.LinkedHashMap params) {
def payload = [
activity: params.activity,
title: params.title,
icon: params.icon,
body: params.body
]
httpRequest(
acceptType: 'APPLICATION_JSON',
contentType: 'APPLICATION_JSON',
@ofen
ofen / rc-local.service
Last active May 9, 2020 22:18
Simple Bluetooth auto-connect script for systemd
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=simple
ExecStart=/etc/rc.local start
ExecStop=/etc/rc.local stop