Skip to content

Instantly share code, notes, and snippets.

@mal1kc
mal1kc / system_hardware_info.py
Last active July 11, 2022 15:24
system hardware info with python3 ;psutil module and builtin platform,datetime modules
import psutil
import platform
from datetime import datetime
def get_size(bytes, suffix="B"):
"""
Scale bytes to its proper format
e.g:
1253656 => '1.20MB'
@mal1kc
mal1kc / wsl2_install_archlinux.md
Last active September 27, 2022 11:37
install archlinux to wsl 2

install archlinux to wsl 2

  1. install archlinux-bootsrap-<version>-x86_64.tar.gz from one of the mirrors file and verify its signature
  2. import using
   wsl --import <distro name> <install location> <location of archlinux-bootstrap.tar.gz file>
   # example
   wsl --import arch "d:\wslDistroStorage\arch" "d:\wslD*\archlinux-bootstarp.tar.gz"
@mal1kc
mal1kc / glob_rename.py
Last active July 3, 2023 23:22
enumarete filenames with glob pattern
from glob import glob
import os
from pathlib import Path
from pprint import pprint
import re
class Counter :
def __init__(self,name, start=0):
self.name = name
self.num = start
@mal1kc
mal1kc / encrypt_decrypt_filenames.py
Last active July 28, 2023 22:55
encrypt_decrypt_filenames
#!/bin/env python3
from cryptography.fernet import Fernet
import os
def generate_key():
# Generating a random 16-byte key (Base64-encoded)
return Fernet.generate_key()
def load_key(key_file_path):
if os.path.exists(key_file_path):
@mal1kc
mal1kc / focus_follows_mouse.ps1
Last active October 4, 2023 18:25
focus follows mouse in win10,11
# this is a powershell script to uset it download as raw and execute with pwsh (powershell)
# i found from internet
# - link https://superuser.com/a/1209478
# not tested in win11 but i think it will work fine
# ----
$signature = @"
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(int uAction, int uParam, ref
@mal1kc
mal1kc / ch_wallpaper.py
Created February 15, 2024 13:55
wezterm, pywal, powershell configuration for windows
import os
import random
import shutil
import ctypes
def main(wallpapers_path:str,cur_wall_path:str):
random_selected_image = wallpapers_path + str(random.choice(os.listdir(wallp
apers_path)))
print(f'{random_selected_image= }')
shutil.copyfile(random_selected_image,cur_wall_path)
@mal1kc
mal1kc / ieee_754.py
Created May 27, 2024 00:34
ieee_754 implementation in python
def float_to_binary_32(f):
"""
Converts a 32-bit floating-point number to its binary representation.
Args:
f (float): The floating-point number to encode.
Returns:
str: The binary representation of the floating-point number.
"""