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 / go_remove_docker_image.md
Last active April 3, 2020 13:38
DigitalOcean Golang remove docker image from docker registry

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 / do-dns-update.py
Last active April 3, 2020 13:37
Update A records for domains in DO
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 / gpg_encrypt_file_for_me.md
Created February 13, 2020 11:15
How to encrypt file for me

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= --encrypt --recipient=velizarx@gmail.com 
@velp
velp / jexia_curl.md
Created February 6, 2020 09:27
Curl examples for Jexia platform

Authenticate API

curl -X POST -d '{"method":"apk","key":"ff5b2d94-35f0-4696-92ca-cd2cf2f78bb3","secret":"..."}' "https://41724d4f-2d2f-4106-ab6c-075481c2f903.app.jexia.com/auth" | jq .access_token

Athenticate UMS

@velp
velp / create-usb.sh
Created November 18, 2019 11:56 — forked from bmatcuk/create-usb.sh
Creating a Bootable Windows USB from ISO on a Mac
# First, we need to find our device. BEFORE inserting your USB drive, run the
# following:
diskutil list
# This will output a bunch of info about all of the disk drives connected to
# your Mac. Each entry will have a header in the form "/dev/diskX", where X is
# some number starting at 0. Now, insert your USB drive and run the command
# again. You should see a new entry. Make note of the name (ie, /dev/diskX).
diskutil list
@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)

@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 / 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

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
package main

import (
	"fmt"
)

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