Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
I may be slow to respond.

Vadim Ponomarev velp

😎
I may be slow to respond.
View GitHub Profile
@velp
velp / http_debug.md
Created Feb 11, 2021
Go HTTP client debug requests/responses
View http_debug.md

Add logging round tripper:

import (
	"fmt"
	"net/http"
	"net/http/httputil"
)

// This type implements the http.RoundTripper interface.
@velp
velp / log_colorized.md
Last active Jan 28, 2021
OpenStack log colorized
View log_colorized.md

It helps to analize OpenStack logs, example Screenshot 2021-01-28 at 14 41 27

Create sed rules file:

cat > /tmp/log_colorized.sed <<EOL
s/(INFO.*)/\x1B[32m\1\x1B[0m/
s/(ERROR.*)/\x1B[31m\1\x1B[0m/
s/(WARNING.*)/\x1B[33m\1\x1B[0m/
s/(CRITICAL.*)/\x1B[31m\1\x1B[0m/
@velp
velp / README.md
Last active Nov 22, 2020
Run minikube with cilium CNI for test
View README.md

System requirements:

  • OS: ubuntu 18.04+
  • CPU: 6+
  • RAM: 10+ Gb

Install minikube + cilium

# Run OS preparation
curl -s https://gist.githubusercontent.com/velp/151636fe01d8b8e3f9c626b30e3c2bc5/raw/prepare_system.sh | bash -s --
@velp
velp / runme_dockerfile.md
Last active Apr 22, 2020
How to add Dockerfile and test it locally
View runme_dockerfile.md

Step 1: check/create Dockerfile in root

Your repository should have Dockerfile in the root directory. Specification of Dockerfile you can find here: https://docs.docker.com/engine/reference/builder/

For Node.JS application it can be something like this:

FROM node:12.10.0

# Create directory where we will place the application
WORKDIR /usr/src/app
@velp
velp / golang_snippets.md
Last active Apr 20, 2020
Goalng code snippets
View golang_snippets.md

YAML parse string/array in one field and parse string/map in one field

import (
    "fmt"
    "strconv"
    "strings"
    "gopkg.in/yaml.v2"
)
@velp
velp / jexia_sdk_consumption_example.md
Last active Apr 5, 2020
How to use Jexia SDK for consumption API
View jexia_sdk_consumption_example.md

Install jexia-sdk

pip install jexia-sdk

Example:

from jexia_sdk.http import HTTPClient

JEXIA_PROJECT_ID = '<PROJECT_HERE>'
@velp
velp / jexia_apphosting_curl.md
Created Apr 3, 2020
How to use Jexia application hosting via CURL
View jexia_apphosting_curl.md

How to use Jexia application hosting via CURL

Step 1: set credentials

export JEXIA_EMAIL="<HERE_YOUR_EMAIL>"
export JEXIA_PASSWORD="<HERE_YOUR_PASSWORD>"
export JEXIA_PROJECT="<HERE_YOUR_PROJECT>"

Step 2: get token

@velp
velp / do-dns-update.py
Last active Apr 3, 2020
Update A records for domains in DO
View do-dns-update.py
import sys
import os
import requests
import json
DO_API = "https://api.digitalocean.com/v2/domains/%s/records"
def get_list_of_records(token, main_domain, sub_domains):
res = requests.get(
@velp
velp / go_remove_docker_image.md
Last active Apr 3, 2020
DigitalOcean Golang remove docker image from docker registry
View go_remove_docker_image.md

Check the image exists:

docker pull registry.runme.io/runme-50b2af51-f401-43fe-aaec-808868b7e3a0:latest
latest: Pulling from runme-50b2af51-f401-43fe-aaec-808868b7e3a0
092586df9206: Already exists
ef599477fae0: Already exists
4530c6472b5d: Already exists
d34d61487075: Already exists
87fc2710b63f: Already exists
@velp
velp / gpg_encrypt_file_for_me.md
Created Feb 13, 2020
How to encrypt file for me
View gpg_encrypt_file_for_me.md

Import public key from GitHub:

curl -s https://api.github.com/users/velp/gpg_keys | jq -r ".[0].raw_key" | gpg --import

Encrypt file:

gpg --output=<path_to_result_file> --encrypt --recipient=velizarx@gmail.com <path_to_source_file>