Skip to content

Instantly share code, notes, and snippets.

View Piotr1215's full-sized avatar
🐺

Piotr Zaniewski Piotr1215

🐺
View GitHub Profile
@Piotr1215
Piotr1215 / __open-file.sh
Created April 20, 2024 16:57
Open multiple files in nvim based on fzf search
#!/usr/bin/env bash
# The set -e option instructs bash to immediately exit if any command has a non-zero exit status
# The set -u referencing a previously undefined variable - with the exceptions of $* and $@ - is an error
# The set -o pipefaile if any command in a pipeline fails, that return code will be used as the return code of the whole pipeline
# https://bit.ly/37nFgin
set -o pipefail
help_function() {
echo "Usage: __open_file.sh [query] [-h|--help]"
@Piotr1215
Piotr1215 / user_functions.lua
Created April 7, 2023 10:10
Quickly copy search results in neovim
function _G.yank_matching_lines()
local search_pattern = vim.fn.getreg('/')
if search_pattern ~= '' then
local matching_lines = {}
for line_number = 1, vim.fn.line('$') do
local line = vim.fn.getline(line_number)
if vim.fn.match(line, search_pattern) ~= -1 then
table.insert(matching_lines, line)
end
end
@Piotr1215
Piotr1215 / highlight.md
Created January 28, 2023 10:40
Highlight markdown text
! this should be highlighted !
@Piotr1215
Piotr1215 / connect-k8s.md
Last active April 18, 2022 12:22
Keep cluster connections separate

How to keep cluster connections cleanly separated

With time the .kube/config file will contain a mix of dev, test and prod cluster references. It is easy to forget switching off from a prod cluster context and make a mistake and run for example kubectl delete ns crossplane-system.

Direnv based setup

Use the following setup to avoid these kinds of errors and keep clusters separate.

Install direnv

@Piotr1215
Piotr1215 / script.sh
Last active February 26, 2022 19:12
Get repos locally using gh CLI with gh s plugin
#!/usr/bin/env bash
# Find a repo for my user and cd into it, clone and cd if not found on disk
function repo() {
# If repo name not provided, prompt for it rather than error out
if [[ -z "$1" ]]; then
export repo=$(ghs -u Piotr1215 | sed 's:.*/::')
else
export repo=$(ghs -u Piotr1215 $1 | sed 's:.*/::')
fi
@Piotr1215
Piotr1215 / Makefile
Created February 20, 2022 13:13 — forked from sighingnow/Makefile
Detect operating system in Makefile.
# Detect operating system in Makefile.
# Author: He Tao
# Date: 2015-05-30
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG += -D WIN32
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OSFLAG += -D AMD64
endif
@Piotr1215
Piotr1215 / setup-k3s.md
Last active February 11, 2022 15:21
K3s setup
@Piotr1215
Piotr1215 / tacos-comparison.md
Last active July 3, 2023 16:37
Below table provides a high level overview of various IaC capabilities and their support by a given provider.
Capability/Tool terraform Cloud terraform Enterprise Scalr Env0 Spacelift
Compliance ISO 27001, SOC 2 ISO 27001, SOC 2 SOC 2 ISO 27001, SOC 2
GitLab Integration
Hosting SaaS SaaS, On-Prem SaaS, On-Prem SaaS SaaS
Policy as Code Sentinel
@Piotr1215
Piotr1215 / install_rancher.sh
Created September 22, 2021 12:40 — forked from jwsy/install_rancher.sh
Script to install rancher on your macOS machine
#!/bin/bash -x
date
### 0. Install helm, kubectl (kubernetes-cli), and k3d with brew
brew install helm k3d kubectl
### 1. Create a cluster with k3d that connects port 443 to the loadbalancer provided by k3d
# Optionally install with more agents `--agents 3`
k3d cluster create k3d-rancher \
--api-port 6550 \
@Piotr1215
Piotr1215 / azure-pipeline.yaml
Created July 26, 2021 19:31
azure pipeline
trigger:
branches:
include:
- master
paths:
exclude:
# Exclude README.md from triggering content deployments
- README.md