Skip to content

Instantly share code, notes, and snippets.

View PeekEnumerator.Extensions.cs
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 Jan 28, 2021
How to Calculate IDW
View readme.md

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 Apr 3, 2018
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.
View TextArea_Backup_with_Expiry_Fix.user.js
// ==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
This class allows a control to raise the MouseHover multiple times without having to move the mouse outside the control after each MouseHover event.
View RepeatedHover.cs
/****************************************************************************************
* 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 Jul 29, 2020
Class to get the taskbar's position, size and other properties.
View Taskbar.cs
/******************************************************************************
* 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 Jul 6, 2021
Random Forest image classification in R
View randomForest sample.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 Aug 29, 2015
Changed to soft wrap mode.
View FolderSelectDialog.vb
Imports System.Reflection
'' ------------------------------------------------------------------
''
'' Wraps System.Windows.Forms.OpenFileDialog to make it present a vista-style dialog.
''
'' ------------------------------------------------------------------
Namespace Global.System.Windows.Forms
''' <summary>