Skip to content

Instantly share code, notes, and snippets.

View Benbb96's full-sized avatar
🚲
Biking

Benbb96

🚲
Biking
View GitHub Profile

Keybase proof

I hereby claim:

  • I am benbb96 on github.
  • I am benbb96 (https://keybase.io/benbb96) on keybase.
  • I have a public key ASCdLymXT9FPSHlA5FTUEnihbTbOYxnwJ-nWzB5rLyctRgo

To claim this, I am signing this object:

@Benbb96
Benbb96 / generate_random_hex_color.py
Created December 22, 2020 16:49
Use this function to generate a random HEX color in Python. You can set limit for the brightest or darkest possible colors thanks to the parameters.
from random import randint
def generate_random_hex_color(minimum=50, maximum=255):
"""
Generate a random HEX color (with a minimum brightness by default)
:param int minimum: the minimum value of each color (Red, Green, Blue)
:param int maximum: the maximum value of each color
:return: for example #B4F714
:rtype: str
@Benbb96
Benbb96 / index.html
Last active October 19, 2020 08:27
CSS Typing effect
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<link href="/styles.css" rel="stylesheet">
</head>
<body>
@Benbb96
Benbb96 / color_contrast.py
Last active July 19, 2022 12:53
Original PHP script from this stackoverflow question : https://stackoverflow.com/a/42921358/8439435 then updated to Python and following the WCAG 2.0 - G18.
BLACK_COLOR = "#000000"
WHITE_COLOR = "#FFFFFF"
def get_contrast_color(background_color: str) -> str:
"""
Util function to determine what's the best color between black or white to choose for a text
depending on the background color given in parameter.
Based on algorythm from WCAG 2.0 explained here : https://www.w3.org/TR/WCAG20-TECHS/G18.html#G18-tests
:param background_color: the background color in HEX format (eg: #9D412B)
@Benbb96
Benbb96 / PDO-Database-Wrapper.php
Last active December 13, 2018 08:14
PHP Class wrapper to handle a PDO connexion to a database.
<?php
class Database
{
// Database connexion informations to replace
private $host = '[localhost|127.0.0.1]';
private $user = '[usr]';
private $pass = '[pwd]';
private $dbname = '[db-name]';