Skip to content

Instantly share code, notes, and snippets.

View velp's full-sized avatar
😎
I may be slow to respond.

Vadim Ponomarev velp

😎
I may be slow to respond.
View GitHub Profile
@velp
velp / rcon.py
Created January 26, 2019 22:44
RCON python client
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Reference: https://github.com/frostschutz/SourceLib/blob/master/SourceRcon.py
# Converted to Python3 by Guillaume "Elektordi" Genty (Tested on 3.7)
#------------------------------------------------------------------------------
# SourceRcon - Python class for executing commands on Source Dedicated Servers
# Copyright (c) 2010 Andreas Klauer <Andreas.Klauer@metamorpher.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@velp
velp / openstack-commands.md
Last active January 17, 2024 15:16
openstack-commands.md

Check all Floating IP by open TCP ports in Security Groups

openstack floating ip list -f value | while read fip; do echo -e "\e[32m===> Check IP $(echo $fip | awk '{print $2}')\e[0m"; openstack port show $(echo $fip | awk '{print $4}') -c security_group_ids -f json | jq '.security_group_ids[]' -r | while read sg; do openstack security group rule list $sg --ingress --protocol tcp --ethertype IPv4 -c "Port Range" -f value | while read ports; do nc -nzv -w2 $(echo $fip | awk '{print $2}') $(echo $ports | sed 's/:.*//g') ; done; done ; done
@velp
velp / markdown_to_confluence.py
Created December 15, 2016 07:43
Convert markdown to confluence XHTML
#/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
import markdown
from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension, parse_hl_lines
CODE_WRAP = '<ac:structured-macro ac:name="code">%s<ac:plain-text-body><![CDATA[%s]]></ac:plain-text-body></ac:structured-macro>'
@velp
velp / http_debug.md
Created February 11, 2021 15:04
Go HTTP client debug requests/responses

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 January 28, 2021 11:43
OpenStack log colorized

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 November 22, 2020 14:32
Run minikube with cilium CNI for test

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 April 22, 2020 08:18
How to add Dockerfile and test it locally

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 April 20, 2020 12:11
Goalng code snippets

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 April 5, 2020 12:35
How to use Jexia SDK for consumption API

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 April 3, 2020 10:33
How to use Jexia application hosting via CURL

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