Skip to content

Instantly share code, notes, and snippets.

View olegbrz's full-sized avatar
🎯
Focusing

Oleg Brezitsky olegbrz

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage
from scipy.spatial.distance import squareform
import matplotlib.pyplot as plt
@olegbrz
olegbrz / post_install.sh
Created October 4, 2021 11:25 — forked from waleedahmad/post_install.sh
Ubuntu post installation script for installing software of your choice.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
else
#Update and Upgrade
echo "Updating and Upgrading"
apt-get update && sudo apt-get upgrade -y
@olegbrz
olegbrz / GitCommitEmoji.md
Created May 31, 2020 22:23 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
group: biomed
AFILIADO_A = {
DEPARTAMENTO_NOM_DEP:string, EMPRESA_EXT_NOMBRE_EMP:string
}
BECARIO = {
NOMBRE:string, APELLIDOS:string, NIF:string , UNIVERSIDAD_NOMBRE_UNI:string, UNIVERSIDAD_NOMBRE_EMP:string
@olegbrz
olegbrz / convex_hull.py
Created November 12, 2019 18:10
Get the hull of a cloud of points with scipy.spatial.ConvexHull
# Import dependencies
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import ConvexHull, convex_hull_plot_2db
# Create random points in a circle
num_samples = 200
theta = np.linspace(0, 2*np.pi, num_samples)
r = np.random.rand((num_samples))
x, y = r * np.cos(theta), r * np.sin(theta)
@olegbrz
olegbrz / cALC.py
Created November 11, 2019 12:45
Script para calcular la dosis letal máxima de un individuo según su peso y el equivalente de esa cantidad en botellas de diferentes bebidas alcoholicas.
drinks = [
['Cruzcampo','latas',330,4.8],
['Alhambra 1925 verde','botellines',330,6.4],
['Moët Chandon','botellas',750,12],
['Rioja Crianza','botellas',750,13.5],
['Jäggermeister','botellas',700,35],
['Vodka Absolut','botellas',700,40],
['Absenta', 'botellas', 700, 89.9],
['Alcohol medicinal', 'botes', 100, 96.6],
['Ballantines', 'botellas', 700, 40],
@olegbrz
olegbrz / linescounter.py
Last active November 9, 2019 13:57
Sometimes it can be interesting to know how many lines of Python code have you written for a project, or in total. So i've written this Python script that counts lines of code in *.py of a directory recursively.
import os
def linescounter(dir, lines=0, header=True, begin_dir=None):
if header:
print('{:>7} |{:>7} | {:<20}'.format('Lines', 'Total', 'File'))
print('{:->8}|{:->8}|{:->20}'.format('', '', ''))
for item in os.listdir(dir):
item = os.path.join(dir, item)
@olegbrz
olegbrz / progress_bars.py
Created October 20, 2019 18:43
Python examples of different progress bars
from time import sleep
def show_bar(perc):
print("[" + "#" * (perc//3) + "-" * (33 - (perc // 3)) + "]", perc, "%", end="\r")
def show_bar2(perc):
print("|" + "█" * (perc // 3) + " " * (33 - (perc // 3)) + "|", perc, "%", end="\r")
@olegbrz
olegbrz / quick_sort.py
Last active October 20, 2019 18:34
Python implementation of Quicksort Sort
from random import randint
def partition(A,low,high):
i = (low-1)
for j in range(low, high):
if A[j] <= A[high]:
i = i + 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[high] = A[high], A[i + 1]
return (i + 1)
@olegbrz
olegbrz / sort_algorithms.py
Last active October 20, 2019 18:35
Python implementation of Selection, Insertion and Bubble Sorts
def selection_sort(A):
i, j, minimum = 0, 0, 0
for i in range(len(A)):
minimum = i
for j in range(i, len(A)):
if A[j] < A[minimum]:
minimum = j
A[i], A[minimum] = A[minimum], A[i]
return A