Skip to content

Instantly share code, notes, and snippets.

View hirusha-adi's full-sized avatar
🎯
Focusing

Hirusha Adikari hirusha-adi

🎯
Focusing
View GitHub Profile

Remove Password Policy in the Calamares Installer on Debian Live

You can download Debian Live install images from the official website. Both the stable and testing releases are available. Choose the one that suits your needs.

Steps:

  1. Boot into the Live environment.

  2. Open a terminal emulator.

@hirusha-adi
hirusha-adi / iso_8601.md
Created May 16, 2025 12:26
Store date/time properly

ISO 8601 Format

Timezones are a headache to begin with. Weird formats in how we represent time are even worse than having to deal with timezones. In Sri Lanka (and most of the world), when it comes to storing or sending date/time values, we go with the ISO 8601 format.

It basically avoids confusion compared to what the Americans use, as it’s more logical. We write everything in descending order. Otherwise, something like 01/02/03 could be Jan 2 or Feb 1 - and nobody would know. Sticking with ISO 8601 fixes this.

It stores your date/time like this. Note that the letter T separates the date and time:

YYYY-MM-DDTHH\:MM\:SS
@hirusha-adi
hirusha-adi / ip_check_advanced.py
Last active October 24, 2024 06:25
Python IPV4 / IPV6 Validation (Advanced)
# based on: https://docs.python.org/3/library/ipaddress.html
import ipaddress
import typing
def is_ipcheck(
value: str,
check_type: typing.Literal[
"addr",
@hirusha-adi
hirusha-adi / ip_check_python.py
Created October 24, 2024 05:57
Python IPV4 / IPV6 Validation
# based on: https://docs.python.org/3/library/ipaddress.html
import ipaddress
def is_ipaddr(input_str: str) -> bool:
"""
Checks if input string is a valid IP address (both IPv4 and IPv6).
Args:
input_str (str): The string to check.
@hirusha-adi
hirusha-adi / ip_regex_python.py
Last active October 24, 2024 05:54
Python IPV4 / IPV6 Regular Expressions (REGEX)
import re
def is_ipaddr(input_str: str) -> bool:
"""
Check if input string is a valid IP address (both IPv4 and IPv6).
Based on:
IPv4: https://stackoverflow.com/questions/5284147/validating-ipv4-addresses-with-regexp
IPv6: https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
Args:
@hirusha-adi
hirusha-adi / detect.md
Last active April 28, 2023 09:28 — forked from thaiphuong5/detect.py
Flask browser detection

Check weather the user request is from a mobile phone or a computer and perform actions accordingly with flask and python3

from flask import request, render_template
import re

browser = request.user_agent.browser
version = request.user_agent.version and int(request.user_agent.version.split('.')[0])
platform = request.user_agent.platform
uas = request.user_agent.string