Skip to content

Instantly share code, notes, and snippets.

@mal1kc
mal1kc / ai_generated_python_42_bsq_solution.py
Created March 5, 2025 18:23
ai_generated_python_42_bsq_solution.py
import sys
def read_map_from_file(file_path):
"""Reads the map from a file and returns a list of strings representing the map."""
with open(file_path, "r") as file:
# Skip the first line (the number of lines)
map_data = file.readlines()[1:]
# Strip any trailing newline characters
#!/usr/bin/env dash
unused_packages_file="$HOME/gecici/unused_packages.txt"
echo "do you want a clean $unused_packages_file file ? y/N"
read -r clean_file
if [ "$clean_file" = "y" ]; then
echo "" >"$unused_packages_file" # clean up
fi
echo "deleting"
@mal1kc
mal1kc / website_downloader.py
Created January 18, 2025 15:43
static website_downloader
import os
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin, urlparse
from concurrent import futures as cfutures
def download_file(url, base_folder):
try:
response = requests.get(url)
@mal1kc
mal1kc / mono_to_stereo.js
Created November 5, 2024 20:10
javascript code to convert current tabs audio stream to stereo
(function() {
// Check if there is an audio or video element on the page
const mediaElements = document.querySelectorAll('audio, video');
if (mediaElements.length === 0) {
console.log('No media elements found on this page.');
return;
}
// Create an AudioContext
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
@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.
"""
@mal1kc
mal1kc / ch_wallpaper.py
Last active January 17, 2025 21:58
wezterm, wallust, 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(wallpapers_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 / 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 / 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 / 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"