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 / iterm2-solarized.md
Created October 22, 2016 13:36 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font (OS X / macOS)

Solarized

@velp
velp / rpki-validator-docker_instructions.md
Last active November 24, 2016 12:59
docker container with RIPE NCC RPKI validator
@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>'
# install requerements
sudo apt-get -y update
sudo apt-get -y install pkg-config libx11-dev libxfixes-dev libssl-dev libpam0g-dev libtool libjpeg-dev flex bison gettext autoconf libxml-parser-perl libfuse-dev xsltproc libxrandr-dev python-libxml2 nasm xserver-xorg-dev fuse
sudo apt-get -y install git
sudo apt-get -y install xfce4 xfce4-goodies tightvncserver xfonts-base xfonts-75dpi xfonts-100dpi
sudo apt-get -y install xrdp
sudo apt-get -y remove xrdp
cd /tmp
# build xrdp
package main

import (
	"fmt"
)

func main() {
	// slice of string
	sl := []string{"one", "two"}

Example use of the 'mock' module for unit testing in Python

import time
import unittest
try:
    from unittest import mock
except ImportError: # pragma: no cover
    import mock
@velp
velp / neutron-manage-tags.py
Created August 20, 2018 10:03
The script for management to networks tags in Neutron
import os
import sys
from multiprocessing.pool import ThreadPool
from functools import partial
from contextlib import contextmanager
from keystoneauth1.session import Session as KeystoneSession
from keystoneclient.auth.identity.v3 import Password as PasswordClient
from neutronclient.neutron.client import Client as NeutronClient
@velp
velp / stdout.md
Last active August 20, 2018 10:48
Example of use 'taskflow' module
# python ./taskflow-example.py
call AllocateSubnet.execute(client=some_client)
call CreateSubnet.execute(client=new_client, subnet_id={'id': '111222333'})
call PrintSubnet.execute(client=some_client, subnet={'subnet': {'id': {'id': '111222333'}, 'name': 'test'}})
revert PrintSubnet task with kwargs={'subnet': {'subnet': {'id': {'id': '111222333'}, 'name': 'test'}}, 'result': None, 'flow_failures': {'__main__.ErrorTask': <taskflow.types.failure.Failure object at 0x7f07b4eac910>}}
revert CreateSubnet task with kwargs={'result': {'subnet': {'id': {'id': '111222333'}, 'name': 'test'}}, 'flow_failures': {'__main__.ErrorTask': <taskflow.types.failure.Failure object at 0x7f07b4eac910>}}
revert AllocateSubnet task with kwargs={'result': {'id': '111222333'}, 'flow_failures': {'__main__.ErrorTask': <taskflow.types.failure.Failure object at 0x7f07b4eac910>}}
Traceback (most recent call last):
  File "./test-task-flow.py", line 61, in <module>
@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 / nginx_certbot.md
Created October 22, 2019 10:19
Nginx + Certbot

How to create Let's encrypt certificates

Create directories

mkdir -p /root/data/nginx
mkdir -p /root/data/certbot/conf
mkdir -p /root/data/certbot/www

Nginx config for first step (file /root/data/nginx/step-1.conf)