Skip to content

Instantly share code, notes, and snippets.

View antonu17's full-sized avatar
🦀
Coding

Anton Ustyuzhanin antonu17

🦀
Coding
View GitHub Profile
#!/bin/bash
set -e
function replace {
local readonly secret="$1"
data="$(vault kv get -format=json -field=data "$secret")"
updated=$(sed -e s/"$search"/"$replace"/g <(echo "$data"))
@antonu17
antonu17 / main.go
Last active February 4, 2020 12:26
type state struct {
sync.RWMutex
co2 int
temperature float64
}
func (s *state) getCo2() int {
s.RLock()
defer s.RUnlock()
return s.co2
package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"strings"
)
@antonu17
antonu17 / gist:dc61853eb6a9d0d6700d5e4e0099ef41
Created November 29, 2019 17:45
kubectl logs -n catalog -l app=catalog-catalog-controller-manager --tail=1000 | grep test1 > catalog-controller-manager-log.txt
I1129 17:33:14.823238 1 round_trippers.go:419] curl -k -v -XPATCH -H "Content-Type: application/strategic-merge-patch+json" -H "Accept: application/json, */*" -H "User-Agent: service-catalog/v0.3.0 (linux/amd64) kubernetes/f950e68/service-catalog-controller-manager" -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJjYXRhbG9nIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InNlcnZpY2UtY2F0YWxvZy1jb250cm9sbGVyLW1hbmFnZXItdG9rZW4tdmJsemIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoic2VydmljZS1jYXRhbG9nLWNvbnRyb2xsZXItbWFuYWdlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjFkYTA5N2VhLTAyNmEtMTFlYS1iYzkyLTAyNWE4NGMwNWE5MCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpjYXRhbG9nOnNlcnZpY2UtY2F0YWxvZy1jb250cm9sbGVyLW1hbmFnZXIifQ.1zK_F0ZZtz7jc4Mc1p-gcHqt-9aC4U7jQSJUB7CKsVOpmlcav74DWHUvM6bOTkjqSDvH2Q0pN5pWaMKsE4fYt2w2wuGKoy7B4hHPNa3dU10j0mtPDwwn
sacli vpnstatus | jq -r '.. | .client_list? | values? | ..[][0]' | sort | uniq -c | sort -rn
#!/usr/bin/env python
def dict_update(dict, path, value):
"""
data = {
'browsers': [
{
'name': 'chrome',
'version': 70
},
@antonu17
antonu17 / gist:404acd209e6cf806713ff9cace85c23e
Created September 3, 2018 12:11
Golang: Read from an io.ReadWriter without losing its content
// Read the content
var bodyBytes []byte
if c.Request.Body != nil {
bodyBytes, _ = ioutil.ReadAll(c.Request.Body)
}
// Restore the io.ReadCloser to its original state
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
// Use the content
bodyString := string(bodyBytes)

Keybase proof

I hereby claim:

  • I am antonu17 on github.
  • I am antonu17 (https://keybase.io/antonu17) on keybase.
  • I have a public key whose fingerprint is 0DCC 76EB 4E83 DF61 C8CD 9A25 EAD4 F30B 01D6 F00F

To claim this, I am signing this object:

@antonu17
antonu17 / equivalent-binary-trees.go
Last active July 27, 2017 12:28
Tour of Go Excercises
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@antonu17
antonu17 / mount_qcow2.md
Created May 15, 2017 04:00 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8