Skip to content

Instantly share code, notes, and snippets.

View tbrlpld's full-sized avatar

Tibor Leupold tbrlpld

View GitHub Profile
@tbrlpld
tbrlpld / randavg.py
Created April 15, 2020 17:18
Checking the average return value of Python's random
# -*- coding: utf-8 -*-
"""Checking the return of random number generator."""
from random import random
def random_avgerage(trails):
"""Return average of a given number of randomly generated numbers."""
@tbrlpld
tbrlpld / lazylogging.py
Last active April 15, 2020 17:13
Avoid function execution for not logged messages
import logging
logger = logging.getLogger(__name__)
# Log level is INFO. So anything of lower level (DEBUG) should not execute
logger.setLevel(logging.INFO)
stream_handler = logging.StreamHandler()
logger.addHandler(stream_handler)
@tbrlpld
tbrlpld / center_vert_hor.css
Created March 25, 2018 13:08
Center div in div, vertically and horizontally
.center-vertical-horizontal{
margin: 0;
position: absolute;
/* top and left define the position of the object relative to the parent in
dimensions of the parent.*/
top: 50%;
left: 50%;
/* transform translate shifts the element aways from the defined position
in dimensions of it self. That means these 50% are 50% of the element sizes
them selfs.*/
@tbrlpld
tbrlpld / dynamic_square.html
Last active March 21, 2018 21:12
Square web element with dynamic size in pure CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.square_spacer {
width: 300px;
background-color: steelblue;
border: solid;
position: relative;