Skip to content

Instantly share code, notes, and snippets.

@franzalex
franzalex / copy_lockscreen_wallpapers.py
Created January 29, 2022 11:34
Copies cached Windows 10 (and Windows 11) lock screen images to a specified directory.
#! /usr/bin/python3
"""Copies cached Windows 10 lockscreen images to a specified directory."""
from pathlib import Path
from shutil import copy2 as copy
from os import getenv
from argparse import ArgumentParser
import imghdr
import struct
@franzalex
franzalex / PeekEnumerator.Extensions.cs
Last active April 14, 2021 15:18
Peek Enumerator for C#
using System.Collections.Generic;
public static class PeekEnumeratorExtensions
{
/// <summary>Returns a <see cref="PeekEnumerator{T}" /> that iterates through the collection.</summary>
/// <typeparam name="T">The element type of objects to enumerate.</typeparam>
/// <param name="collection">The collection to be enumerated.</param>
/// <returns>A <see cref="PeekEnumerator{T}" /> that can be used to iterate through the collection.</returns>
public static PeekEnumerator<T> GetPeekEnumerator<T>(this IEnumerable<T> collection)
{
@franzalex
franzalex / readme.md
Last active January 28, 2021 12:03
How to Calculate IDW

Calculating IDW

For a given number (n) of neighbouring points (p) within a given radius, the IDW value for a point of interest (v) is calculated as follows.

  1. Calculate the Euclidean distance between each of the neighboring points (pi)
    ![Euclidean Distance Formula][Eq1]

  2. Normalize the Euclidean distances calculated as a ratio relative to the

@franzalex
franzalex / TextArea_Backup_with_Expiry_Fix.user.js
Last active April 3, 2018 08:24
Creates a backup of input and textArea fields for restoration after data loss. It offers similar functionality as the Lazarus Firefox extension which is no longer supported.
// ==UserScript==
// @author Crend King
// @contributor Franz Alex Gaisie-Essilfie
// @version 2.4.20170620
// @name Textarea Backup with expiry Fix
// @namespace http://users.soe.ucsc.edu/~kjin
// @description Fix @grant https://greasyfork.org/zh-CN/forum/discussion/8161
// @description Retains text entered into textareas and contentEditables, and expires after certain time span.
// @include http://*
// @include https://*
@franzalex
franzalex / RepeatedHover.cs
Created May 18, 2017 00:30
This class allows a control to raise the MouseHover multiple times without having to move the mouse outside the control after each MouseHover event.
/****************************************************************************************
* Name: RepeatedHover.cs
* Author: Franz Alex Gaisie-Essilfie
* Description: Allows a control to raise the MouseHover event multiple times without
* having to move the mouse outside the control after each MouseHover event.
*
* Premise: From the documentation⁽¹⁾, a control's mouse events are as follows:
* > MouseEnter
* > MouseMove
* > MouseHover / MouseDown / MouseWheel
@franzalex
franzalex / Taskbar.cs
Last active August 6, 2022 18:45
Class to get the taskbar's position, size and other properties.
/******************************************************************************
* Name: Taskbar.cs
* Description: Class to get the taskbar's position, size and other properties.
* Author: Franz Alex Gaisie-Essilfie
* based on code from https://winsharp93.wordpress.com/2009/06/29/find-out-size-and-position-of-the-taskbar/
*
* Change Log:
* Date | Description
* -------------|--------------------------------------------------------------
* 2017-05-16 | Initial design
@franzalex
franzalex / randomForest sample.R
Last active July 6, 2021 03:02
Random Forest image classification in R
# Random Forest image classification
# Adapted from http://gis.stackexchange.com/a/57786/12899
#' Performs a random forest classification of the specified raster.
#'
#' @param rasterPath The full path to the raster file to be classified.
#' @param samplesPath The full path to the .SHP file of the training samples.
#' @param samplesCol The column in the training samples shape file that contains the class names.
#' @param classifiedPath The full path to the output classified image.
#'
@franzalex
franzalex / FolderSelectDialog.vb
Last active August 29, 2015 14:27
Changed to soft wrap mode.
Imports System.Reflection
'' ------------------------------------------------------------------
''
'' Wraps System.Windows.Forms.OpenFileDialog to make it present a vista-style dialog.
''
'' ------------------------------------------------------------------
Namespace Global.System.Windows.Forms
''' <summary>