Skip to content

Instantly share code, notes, and snippets.

# https://en.m.wikipedia.org/wiki/Electric_power
from collections import namedtuple
from typing import Tuple
def electric_power(voltage: float, current: float, power: float) -> Tuple:
"""
This function can calculate any one of the three (voltage, current, power),
fundamental value of electrical system.
examples are below:
@Komet-Kazi
Komet-Kazi / bash_commands.md
Last active June 10, 2021 16:37
Useful Or Frequent Bash commands

kill the service that hogs the raspberrypi camera module

sudo /etc/init.d/motion stop

Get IP address

hostname -I

@Komet-Kazi
Komet-Kazi / git_repo_notes.md
Last active May 22, 2021 01:49
Git - Notes to create or push repos to github

Create a new repository on the command line

echo "# Nice_Schedule" >> README.md git init git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/Komet-Kazi/.git git push -u origin main

Push an existing repository from the command line

@Komet-Kazi
Komet-Kazi / ADC_Device.py
Last active April 14, 2021 19:30
Sensors and Circuits
#!/usr/bin/env python3
########################################################################
# Filename : ADCDevice.py
# Description : Freenove ADC Module library.
# Author : www.freenove.com
# modification: 2020/04/21
########################################################################
import smbus
@Komet-Kazi
Komet-Kazi / pi_binary.py
Last active April 10, 2021 21:10
Binary Operations
# The bit position in a binary integer giving the units value, that is, determining whether the number is even or odd.
# The LSB is sometimes referred to as the low-order bit or right-most bit
# the most significant bit (MSB, also called the high-order bit) is the bit position in a binary number having the greatest value.
# The MSB is sometimes referred to as the high-order bit or left-most bit.
# "1" signifies a negative number and "0" signifies a positive number
# Example:
# if bite is currently b'0 0 0 0 0 0 0 1,
# bite << 1 would produce: b'0 0 0 0 0 0 1 0
@Komet-Kazi
Komet-Kazi / MIT.txt
Last active March 24, 2021 07:05
MIT License
# The MIT License (MIT)
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@Komet-Kazi
Komet-Kazi / snippets.py
Last active April 12, 2021 05:38
python snips
import os
import json
import sys
import logging
from functools import wraps
def create_logger():
# create a logger object
@Komet-Kazi
Komet-Kazi / log_EntryExit.py
Created March 13, 2021 19:29
loguru Log Enter, args, Exit, Results
# log entry and exit values of a function.
# use decorator '@logger_wraps()' above function to log entry, its arguments, and its return
import functools
from loguru import logger
def logger_wraps(*, entry=True, exit=True, level="DEBUG"):
"""Use decorator '@logger_wraps()' above function to log entry into function, its arguments, and its return"""
def wrapper(func):
# split_pairs.py --> Split the string into pairs of two characters.
# If the string contains an odd number of characters, then the missing second character of the final pair should be replaced with an underscore ('_').
# Input: A string.
# Output: An iterable of strings.
# Precondition: 0<=len(str)<=100
def split_pairs(a: str):
# find length of string. check if odd. if odd append "_" to the list
stringSize = len(a)
@Komet-Kazi
Komet-Kazi / grid_fluid_columns.css
Last active January 14, 2021 09:38
fluid width columns that break into more or less columns as space is available, with no media queries!
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
/* This is better for small screens, once min() is better supported */
/* grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); */
grid-gap: 1rem;
/* This is the standardized property now, but has slightly less support */
/* gap: 1rem */
}
.grid > div {