Skip to content

Instantly share code, notes, and snippets.

View mikekenneth's full-sized avatar
🌍

Mike Houngbadji mikekenneth

🌍
View GitHub Profile
@mikekenneth
mikekenneth / clean_dataframe_with_pandera_schema.py
Created December 14, 2021 12:54
Clean pandas dataframe using pandera validation. The returned dataframe is the result of droping non-valid records.
import pandas as pd
import pandera as pa
def clean_dataframe_with_schema(dataframe, schema):
try:
return schema.validate(dataframe)
except (pa.errors.SchemaErrors, pa.errors.SchemaError) as err:
return dataframe.drop(labels=err.failure_cases['index'].to_list())
@mikekenneth
mikekenneth / streamlit_date_month_selector.py
Created May 4, 2023 10:10
Streamlit month picker using selectbox and radio.
import streamlit as st
from calendar import month_abbr
from datetime import datetime
with st.expander('Report month'):
this_year = datetime.now().year
this_month = datetime.now().month
report_year = st.selectbox("", range(this_year, this_year - 2, -1))
month_abbr = month_abbr[1:]
report_month_str = st.radio("", month_abbr, index=this_month - 1, horizontal=True)
@mikekenneth
mikekenneth / forticlient_vpn_installation.md
Created April 26, 2023 09:21
Installation of Forticlient VPN on Debian 11 Bulleyes

Original Post: https://gitlab.com/fhidalgo.dev/install-forticlient-on-debian-11-bullseye/-/blob/en/README.md

I am just adding this here for my sake of retrieving easily.

Install Forticlient on Debian 11 bullseye

In Debian 11 bullseye there is a package that has been removed called libappindicator1. This is used to display notifications. However, there are still many packages that have it as a dependency, such as the Forticlient VPN client.

To resolve that dependency, all you have to do is mock the package with equivs:

@mikekenneth
mikekenneth / minio in docker-compose.yaml
Created December 28, 2022 11:56
Starting MinIO using docker-compose
version: '3'
services:
minio:
image: minio/minio
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_storage:/data
@mikekenneth
mikekenneth / pandas_multiple_line_plot.py
Created September 27, 2022 08:16
Plotting multilple line plot with Pandas & Matplotlib
import pandas as pd
import matplotlib.pyplot as plt
data = {
'ip_address': ['10.10.1.2','10.10.1.3','10.10.1.4','10.10.1.5','10.10.1.6','10.10.1.7','10.10.1.8'],
'latency': [278,353,658,517,62,485,875],
'packet_size': [773,9860,4618,1056,9568,8124,4605]}
df = pd.DataFrame(data=data)
print(df.head())
@mikekenneth
mikekenneth / postgres_queries_and_commands.sql
Created September 12, 2022 17:23 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
import serial
import time
# Instantiate serial connection to the HD Ranger
hd_ranger_serial_port_id = '/dev/ttyUSB0' # 'COM5'
ser = serial.Serial(hd_ranger_serial_port_id, 115200) # open serial port
print(ser.name) # check which port was really used
# Get XON from HD Ranger
print(ser.read(1)) # Pour lire le XON
DROP TABLE if exists d_date;
CREATE TABLE d_date
(
date_dim_id INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
@mikekenneth
mikekenneth / rank_scores.py
Created June 28, 2022 10:58
Rank list of scores
# Code pour calculer les rangs
def rank_scores(scores:list):
return {moyenne: rang for rang, moyenne in enumerate(reversed(sorted(set(moyennes))), start=1)}
moyennes = [1, 2, 20 , 16, 19, 18, 0, 6, 6.5, 12.5, 0.5, 15.60, 17.8]
ranked_scores = rank_scores(moyennes)
# Ensuites on peut recupere les range en entrant la moyennes comme input
ranked_scores.get(2) # 10
@mikekenneth
mikekenneth / Install Python 3.7.5 on CentOS 7
Last active May 7, 2022 02:41 — forked from wpupru/Install Python 3.7.0 on CentOS 7
Install Python 3.7.5 on Centos 7
Install Python 3.7.5 on CentOS/RHEL 7
1.Requirements:
yum install gcc openssl-devel bzip2-devel libffi-devel
# Below requirement for djang projects
yum install readline-devel tk-devel tk-devel openssl-devel sqlite-devel openssl tk readline sqlite
2.Download Python 3.7: