Skip to content

Instantly share code, notes, and snippets.

View bmwant's full-sized avatar
🇺🇦
Hold strong Ukraine

Misha Behersky bmwant

🇺🇦
Hold strong Ukraine
View GitHub Profile
@bmwant
bmwant / ansbile_tips.yml
Last active July 9, 2021 09:53
ansible quick tips for some modules
# Check existing
- name: Ansible check file exists.
stat:
path: /etc/filename
register: file_status
- debug:
msg: "File exists..."
when: file_status.stat.exists
- debug:
msg: "File not found"
@bmwant
bmwant / install_db5.sh
Created May 2, 2021 09:46
Script for installing Berkeley DB version 5.1.29
#!/bin/sh
export LC_ALL=C
set -e
if [ -z "${1}" ]; then
echo "Usage: $0 <base-dir> [<extra-bdb-configure-flag> ...]"
echo
echo "Must specify a single argument: the directory in which db5 will be built."
echo "This is probably \`pwd\` if you're at the root of the dogecoin repository."
@bmwant
bmwant / check.qb
Created June 1, 2020 17:04
quick backend generated file 01
list 611
constructor Defun 3
literal string 27
Prelude_46_Bool_46__38__38_
list 2
literal string 18
_123_arg_95_0_125_
literal string 18
_123_arg_95_1_125_
list 5
@bmwant
bmwant / bp.py
Created May 8, 2019 12:09
Balance parentheses
OPEN_BRACKETS = '[{('
CLOSING_BRACKETS = ']})'
def is_matching(open_bracket: str, close_bracket: str) -> bool:
return OPEN_BRACKETS.index(open_bracket) == \
CLOSING_BRACKETS.index(close_bracket)
def is_balanced(input_string: str) -> bool:
@bmwant
bmwant / pyproject.toml
Created May 4, 2019 14:34
Poetry show
[tool.poetry]
name = "venv"
version = "1.0"
description = "venv project"
authors = ["venv"]
[tool.poetry.dependencies]
python = "^3.5.2"
Django = "=1.11.14"
stripe = "=1.43.0"
@bmwant
bmwant / simple_nn.py
Created November 13, 2018 15:23
Update with predict to simple neural network
class NeuralNetwork(object):
...
def predict(self, x):
layer1 = sigmoid(np.dot(x, self.weights1))
output = sigmoid(np.dot(layer1, self.weights2))
return output
x_seen = np.array([1, 1, 0])
@bmwant
bmwant / outdated_branches_cleanup.sh
Last active March 26, 2019 16:45
Delete git outdated branches
#!/usr/bin/env bash
set -e
# Reset in case getopts has been used previously in the shell.
OPTIND=1
DRY_RUN=0
KEEP_MONTHS=6 # remove only branches older than keep value
GIT_REF_PREFIX="refs/remotes/origin"
EXCLUDE=('INT' 'QA' 'STAGE' 'master')
@bmwant
bmwant / carmax.py
Created February 28, 2019 10:58
RL random agent for carmax problem
import random
from abc import ABC, abstractmethod
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
class EnvData(object):
def __init__(self, step: int, gas_price: float, consumption: float):
@bmwant
bmwant / shell_tips.sh
Last active April 22, 2018 10:00
Same useful shell commands
#!/usr/bin/env bash
# help set
set -e # Exit immediately if a command exits with a non-zero status.
set -x # Print commands and their arguments as they are executed.
# Export same evironment as process has
strings /proc/$PID/environ
strings /proc/20316/environ | awk '{ print "export "$1}' >> export_env.sh
source export_env.sh
@bmwant
bmwant / script.sh
Last active April 22, 2018 09:34
Some shell hints and boilerplate code
#!/usr/bin/env bash
set -ex
## This is current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
######
# Add variables to travis encrypted section
######