Skip to content

Instantly share code, notes, and snippets.

View kapb14's full-sized avatar
😤

Aleksandr Karushin kapb14

😤
View GitHub Profile
@kapb14
kapb14 / PyYapf.sublime-settings
Created December 20, 2018 16:46
User settings of PyYapf plugin for Sublime3
{
"yapf_command": "C:\\www\\env\\Scripts\\yapf.exe",
"on_save": false,
"use_entire_file_if_no_selection": true,
"popup_errors": false,
"config": {
// The column limit.
"COLUMN_LIMIT": 120,
// The number of columns to use for indentation.
"INDENT_WIDTH": 4,
@kapb14
kapb14 / flask_otp_example.py
Created November 2, 2018 06:33
flask otp simplest example
# -*- coding: utf-8 -*-
from flask import Flask, render_template_string, request, Response, session, redirect
import logging, os, sys, time
import random
app = Flask(__name__)
app.config["SECRET_KEY"] = "SECRETKEYSECRETKEYSECRETKEYSECRETKEYSECRETKEY"
app.config["DEBUG"] = os.environ.get("FLASK_DEBUG", True)
app.config["JSON_AS_ASCII"] = False
@kapb14
kapb14 / base.html
Created October 17, 2018 07:14
Flask simplest realtime log file viewer
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" class="uk-height-1-1">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>flasktest</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" />
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
@kapb14
kapb14 / README.md
Created October 15, 2018 14:04
pyenv configuration for fish shell
@kapb14
kapb14 / README.md
Created October 9, 2018 07:53
QT5 with python first steps
@kapb14
kapb14 / run_powershell_cmdlet.py
Created September 28, 2018 07:28
Run PowerShell commandlet or .ps1 file with parameters from python (2.7) script
#-*- coding: utf-8 -*- .
import subprocess, os, sys, json
MY_PROCESS = "chrome"
print("MY_PROCESS: %s" % MY_PROCESS)
p = subprocess.Popen([
"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
"-ExecutionPolicy", "Bypass",
"-NoLogo",
@kapb14
kapb14 / README.md
Last active September 24, 2018 10:44
Simple and useful interactive menu for ssh-config with percol
@kapb14
kapb14 / editrc.bash
Created September 14, 2018 09:14
Bash function to select, edit and then source one of .bashrc* files in user's home directory
function editrc () {
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "help" ]]; then
cat <<EOF
Usage: editrc [--help|-h|help] [ID]
[ID] - first column in output (index number)
It may be executed without arguments and select the file with interactive prompt.
EOF
return
@kapb14
kapb14 / mnt-mail-var.automount
Created September 13, 2018 13:30
Automount SSHFS share with systemd
[Unit]
Description=SSHFS share with logs
Requires=network-online.target
[Automount]
Where=/mnt/mail/var
TimeoutIdleSec=301
[Install]
WantedBy=graphical.target
@kapb14
kapb14 / fpm-status
Created July 2, 2018 15:04
php fpm status commandline script with pool name as argument
#!/bin/bash
if [[ -z $1 ]]; then
pool_name="www"
elif [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "help" ]]; then
echo "Usage: $(basename $0) [FPM_POOL_NAME]"
exit 1
elif [[ "$1" == "--list" ]] || [[ "$1" == "-l" ]] || [[ "$1" == "list" ]]; then
for p in $(grep -h "^\[" /etc/php/7.1/fpm/pool.d/*.conf | tr -d '[|]'); do
echo " ${p}"