Skip to content

Instantly share code, notes, and snippets.

Avatar
🇺🇦
Hold strong Ukraine

Misha Behersky bmwant

🇺🇦
Hold strong Ukraine
View GitHub Profile
@bmwant
bmwant / install_db5.sh
Created May 2, 2021
Script for installing Berkeley DB version 5.1.29
View install_db5.sh
#!/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 Jun 1, 2020
quick backend generated file 01
View check.qb
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
Balance parentheses
View bp.py
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:
View pyproject.toml
[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 / outdated_branches_cleanup.sh
Last active Mar 26, 2019
Delete git outdated branches
View outdated_branches_cleanup.sh
#!/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 Feb 28, 2019
RL random agent for carmax problem
View carmax.py
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 / simple_nn.py
Created Nov 13, 2018
Update with predict to simple neural network
View simple_nn.py
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 / shareme.py
Created Apr 3, 2018
Just share some code
View shareme.py
from html.parser import HTMLParser
class MyBase(object):
def __init__(self):
print('I want this called')
@bmwant
bmwant / shell_tips.sh
Last active Apr 22, 2018
Same useful shell commands
View shell_tips.sh
#!/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 Apr 22, 2018
Some shell hints and boilerplate code
View script.sh
#!/usr/bin/env bash
set -ex
## This is current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
######
# Add variables to travis encrypted section
######