Skip to content

Instantly share code, notes, and snippets.

View Piotr1215's full-sized avatar
🐺

Piotr Zaniewski Piotr1215

🐺
View GitHub Profile
@Piotr1215
Piotr1215 / nvim-autocommands.md
Last active July 29, 2024 19:02
Neovim Autocommands
Command Description
:autocmd Lists all currently defined auto commands in Neovim.
:autocmd {event} Shows auto commands for a specific event (e.g., BufWritePost).
:verbose :autocmd {event} Provides detailed information about auto commands for a specific event
:augroup {group} | autocmd | augroup END Displays all auto commands within a specific group.
:autocmd * {pattern} Lists all auto commands that match a specific pattern (e.g., *.lua).
Telescope autocommands Lists all auto commands and fuzzy find.
@Piotr1215
Piotr1215 / nvim-replace.md
Last active July 24, 2024 09:52
neovim search&replace cheatsheet
Command Description
:%s/old/new/g Replace all occurrences of 'old' with 'new' in the entire file
:s/old/new/g Replace all occurrences of 'old' with 'new' in the current line
:s/\Cold/new/g Case-sensitive replace of 'old' with 'new' in the current line
:s/\v(\d+)-(\d+)/\2-\1/g Swap two groups of digits separated by a hyphen in the current line
:g/^$/d Delete all empty lines in the file
:g/pattern/norm gU$ Convert matching lines to uppercase
`:argdo %s/old/new/gc update`
@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 October 18, 2024 16:59
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