Skip to content

Instantly share code, notes, and snippets.

View naumvd95's full-sized avatar
🐙
breaking things, fixing things

Vladislav Naumov naumvd95

🐙
breaking things, fixing things
View GitHub Profile
@naumvd95
naumvd95 / rebase_pr_chain.md
Last active April 14, 2022 10:21
How to rebase a long chain of Pull Requests conditionally
  1. Imagine you have N Pull Requests. Each Pull Request created from the separate branch and each of them rebased on top of the previous one. Overall it will looks like:

    vladislav.naumov@jarvis:~$ git branch | grep vnaumov
    
    key/vnaumov/some-important-feature-7

keu/vnaumov/some-important-feature-6

@naumvd95
naumvd95 / tf_remote_state_etcd.sh
Created November 3, 2021 14:13
Simple example using etcdv3 as DB for tf states + locks (paxos comes in play ;))
#!/bin/bash
set -ex
# brew install etcd
etcd &
# check etcd
ETCDCTL_API=3 etcdctl put foo bar
ETCDCTL_API=3 etcdctl get foo
@naumvd95
naumvd95 / genereate_tf_sg_names.sh
Last active April 21, 2021 12:53
Generate random SG rule names in terraform
# we already have entities like " resource "openstack_networking_secgroup_rule_v2" "offline_secgroup_rule_extra_" {}"
# and want to generate uniq postfixes for them
for lineNum in $(grep -Rin "rule_extra" main.tf | cut -f2 -d:); do sed -i '' "${lineNum}s/rule_extra_/rule_extra_$(openssl rand -hex 3)/" main.tf; done
@naumvd95
naumvd95 / lint-only-changed-files.MD
Created March 5, 2021 11:54 — forked from seeliang/lint-only-changed-files.MD
How to lint only changed files?

find out the differences

use git diff to generate file list

git diff --name-only master

limited to certain file types

add ext filter

git diff --name-only master | grep -E "(.js$|.ts$|.tsx$)"

@naumvd95
naumvd95 / auto_mke_support_dump.sh
Created February 22, 2021 15:14 — forked from Richard-Barrett/auto_mke_support_dump.sh
auto_mke_support_dump.sh
#!/bin/bash
# ============================================
# Created by: Richard Barrett
# Date Created: 11/11/2020
# Purpose: MKE Auto Collector for Support Dump
# Company: Mirantis
# ============================================
#set -e
# keep track of the last executed command
@naumvd95
naumvd95 / export-google-docs-to-restructured-text.js
Created February 18, 2021 13:55 — forked from simonw/export-google-docs-to-restructured-text.js
Google Apps script to convert a Google Docs document into reStructuredText
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu('Convert to .RST')
.addItem('Convert to .RST and email me the result', 'ConvertToRestructuredText')
.addToUi();
}
// Adopted from https://github.com/mangini/gdocs2md by Renato Mangini
// License: Apache License Version 2.0
String.prototype.repeat = String.prototype.repeat || function(num) {
@naumvd95
naumvd95 / go_cpu_memory_profiling_benchmarks.sh
Created February 1, 2021 10:38 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@naumvd95
naumvd95 / git_gerrit_push_with_new_key.sh
Created January 25, 2021 12:55
git env var to manage ssh key path w/o changing git config
GIT_SSH_COMMAND='ssh -i ~/.ssh/test_key' git push --all
@naumvd95
naumvd95 / sshfs_fetch_to_remote.sh
Created November 9, 2020 13:45
Mount SSHFS & fetch logs on remote machine to speedup downloading in case of fucking slow home network speed
#!/bin/bash
set -ex
# MacOS quickstart: https://sbgrid.org/corewiki/faq-sshfs
: "${LOCAL_DIR:=sshfs_mount_point}"
: "${REMOTE_DIR:=/home/ubuntu}"
: "${USERNAME:=ubuntu}"
: "${HOST:=}"
: "${SSH_KEYPATH:=~/.ssh/id_rsa}"
sed -i '' "/line_u_wanted_to_insert_below/r add_new.txt" ./file.txt