Skip to content

Instantly share code, notes, and snippets.

View tarhan's full-sized avatar

Dmitriy Lekomtsev tarhan

  • Moscow, Russian Federation
View GitHub Profile
@tarhan
tarhan / grpc_asyncio.py
Created June 1, 2019 15:47 — forked from mmellison/grpc_asyncio.py
gRPC Servicer with Asyncio (Python 3.6+)
import asyncio
from concurrent import futures
import functools
import inspect
import threading
from grpc import _server
def _loop_mgr(loop: asyncio.AbstractEventLoop):
@tarhan
tarhan / pi_mount_usb.md
Created May 15, 2019 13:59 — forked from etes/pi_mount_usb.md
How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

Follow the simple steps in the order mentioned below to have your USB drive mounted on your Raspberry Pi every time you boot it.

These steps are required especially if your are setting up a Samba share, or a 24x7 torrent downloader, or alike where your Raspberry Pi must have your external storage already mounted and ready for access by the services / daemons.

Step 0. Plug in your USB HDD / Drive to Raspberry Pi If you are using a NTFS formatted drive, install the following

@tarhan
tarhan / base64.hpp
Created February 13, 2019 12:59 — forked from cls/base64.hpp
Straightforward constexpr Base64 block encoding in C++14
#include <array>
#include <tuple>
constexpr std::array<char, 4> base64(uint8_t octet0, uint8_t octet1, uint8_t octet2)
{
constexpr std::array<char, 64> table = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
@tarhan
tarhan / letsencrypt_2018.md
Created January 25, 2019 17:35 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@tarhan
tarhan / gist:fce3106bf913791aa5baf7b2fecdd10d
Created August 28, 2018 20:38 — forked from archeg/gist:8333021
Example of code that uses HID for Android to connect to the device through USB.
package com.company.app.PlatformMethods;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@tarhan
tarhan / migrate.sh
Created June 1, 2018 11:28 — forked from cedricziel/migrate.sh
Very simple migration script to move from gitlab to gogs
#!/bin/env bash
## Needs `jq` (https://stedolan.github.io/jq/) on PATH
## and a personal gogs token of yours.
## Obtain token from https://git.example.com/user/settings/applications
## Usage:
## ./migrate.sh $clone_url $project_name [$optional_group]
## Migrate a repository to gogs into the user namespace of the token-user
## ./migrate.sh [email protected]:group/repo.git repo
## Migrate a repository to gogs into the group namespace `group` (needs to exist)
@tarhan
tarhan / README.md
Created April 10, 2018 11:14 — forked from squidpickles/README.md
Multi-platform (amd64 and arm) Kubernetes cluster

Multiplatform (amd64 and arm) Kubernetes cluster setup

The official guide for setting up Kubernetes using kubeadm works well for clusters of one architecture. But, the main problem that crops up is the kube-proxy image defaults to the architecture of the master node (where kubeadm was run in the first place).

This causes issues when arm nodes join the cluster, as they will try to execute the amd64 version of kube-proxy, and will fail.

It turns out that the pod running kube-proxy is configured using a DaemonSet. With a small edit to the configuration, it's possible to create multiple DaemonSets—one for each architecture.

Steps

Follow the instructions at https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/ for setting up the master node. I've been using Weave Net as the network plugin; it see

@tarhan
tarhan / .eslintrc
Created November 25, 2017 11:45 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
}
int main(int argc, char* argv[])
{
const char * kInputFileName = "f:/Projects/Temp/testFFMPEG2/test/test_in.avi";
const char * kOutputFileName = "f:/Projects/Temp/testFFMPEG2/test/text_out.avi";
@tarhan
tarhan / gist:3764a8a515521071cf7a890db5dcf867
Created June 4, 2017 04:21 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt