Skip to content

Instantly share code, notes, and snippets.

View mikkohei13's full-sized avatar

Mikko Heikkinen mikkohei13

View GitHub Profile
@mikkohei13
mikkohei13 / lyrics.sh
Created October 26, 2025 09:11
Combine mp3, jpg and srt into a lyrics video
ffmpeg -ss 0 -i 'input.mp3' -loop 1 -i 'input.jpg' \
-vf "subtitles='input.srt'" \
-c:v libx264 -tune stillimage -c:a aac -b:a 192k -shortest -pix_fmt yuv420p output.mp4
@mikkohei13
mikkohei13 / get_inaccurate.py
Created October 24, 2025 08:21
Script to get FinBIF observations with inaccurate coordinates
import sys
import os
import requests
import csv
import time
import json
secrets_path = os.path.join(os.path.dirname(__file__), '..', '_secrets')
sys.path.append(secrets_path)
import finbif_token
@mikkohei13
mikkohei13 / atlas_winter.py
Created March 14, 2025 18:00
Fetches atlas observations from winter period which can affect squre results
# Script that fetches winter period atlas observations and checks which of them might affect atlas results.
import os
import requests
import json
import time
from datetime import datetime
# Fetch atlas observations
@mikkohei13
mikkohei13 / augmentation.py
Last active March 8, 2025 19:40
Image augmentation for machine learning
# Image augmentation for machine learning
# Script that loops through images in subdirectories and replaces the background using rembg and does transformations to selected number of images in each directory
import rembg
from pathlib import Path
import random
from PIL import Image, ImageEnhance, ImageFilter
import numpy as np
import gc
import time
@mikkohei13
mikkohei13 / convert_to_flac.ps1
Created February 26, 2025 15:10
PowerShell script that converts all wav files in a folder (and subfolders) into flac format.
# Check if FFmpeg is installed
try {
ffmpeg -version | Out-Null
} catch {
Write-Error "FFmpeg is not installed or not in PATH. Please install FFmpeg first."
exit 1
}
# Allow user to specify the root directory or use current directory as default
$rootDirectory = Read-Host "Enter the root directory path (press Enter to use current directory)"
# PowerShell script for Windows.
# This script finds directories with 10 or more photos in them,
# matching the patterns used by digital camera: IMG_, DSC_, or DSCN.
param(
[Parameter(Mandatory=$true)]
[string]$DirectoryPath
)
# Verify the directory exists
# Join en and sv names from Syke's file to original Lely habitat file
# Habitat file, tab separated values
habitat_file = 'habitat_classification_v1.0.tsv'
"""
Example data of habitat_classification_v1.0.tsv:
Enum Vihkon elinympäristö 1.taso 2. taso 3. taso Swedish English
MY.habitatEnumValue1 Metsät Metsä Skog Forest
# Python script that creates a CSV file with image file paths and their corresponding categories
# Should work on both Linux & Windows, and with unicode filenames
'''
Input format:
directory;category
./lepidoptera/adult;adult
./lepidoptera/adult_specimen;adult_specimen
./lepidoptera/egg;egg
@mikkohei13
mikkohei13 / convert.py
Last active January 7, 2025 13:55
Convert Luke atlas dataset 2024 to FinBIF Data Bank format
'''
Converts "Luken aineistokooste 4. lintuatlakseen" tsv file into FinBIF Data Bank secondary data format.
Mikko Heikkinen 2023-12-29, updated 2025-01-07
'''
import pandas as pd
# Save file from Excel as UTF-8 CSV
# Load the file into a Pandas dataframe using tab as the delimiter. Keep "NA" as a value.
file_path = 'Luke_lintuatlasdata_2023-2024.csv'
@mikkohei13
mikkohei13 / parse_chatgpt_conversations.py
Created December 14, 2024 15:38
Script to parse ChatGPT conversations.json file to analyze how many messages were sent by ChatGPT and users, and how many conversations were created per year and month.
# Script to parse ChatGPT conversations.json file to analyze how many messages were sent by ChatGPT and users, and how many conversations were created per year and month.
# conversations.json is a JSON file containing a list of conversations. You can get this by starting a data export in ChatGPT settings.
import json
from collections import defaultdict
from datetime import datetime
# Load the JSON file
file_path = "conversations.json"
with open(file_path, "r") as file: