Skip to content

Instantly share code, notes, and snippets.

View angstyloop's full-sized avatar

Sean Allen angstyloop

View GitHub Profile
@angstyloop
angstyloop / gp-configure-privacy-settings.ps1
Last active December 2, 2023 05:07
This PowerShell script creates a GPO that configures Privacy Settings Registry values.
#!/bin/usr/pwsh
# Prefixes for registry key paths.
$currentVersion = 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion'
$consentStore = "${currentVersion}\CapabilityAccessManager\ConsentStore"
$deviceAccess = "${currentVersion}\DeviceAccess"
# A list of Objects like.
# { Description: String, RegistryKey: String, Value: Int }
@angstyloop
angstyloop / glev.c
Created October 13, 2023 20:53
C GLib Levenshtein Distance ( removal, substitution, or insertion; all weights are 1 )
#define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)))
/* LEVENSHTEIN DISTANCE
*
* @s1 and @s2 are character arrays of size @n1 and @n2, which represent two
* strings. Any null bytes are treated like a normal character, so strings
* without a terminating null byte are valid input.
*
* The LEVENSHTEIN DISTANCE between @s1 and @s2 is the smallest number of
* insertions, deletions, or substitutions needed to transform @s1 into @s2.
@angstyloop
angstyloop / gist:d7e6cdd5c813cd0304274ec5ad289b8f
Created October 10, 2023 22:00
Disable "scroll" event propagation on a widget that receives the "scroll" event in GTK4.
/* Disable scroll on a widget by adding a capture phase event handler and
* connecting a no-op callback to the "scroll" event.
*/
static GtkWidget *
disable_scroll( GtkWidget *w )
{
GtkEventController *ec;
ec = gtk_event_controller_scroll_new(
GTK_EVENT_CONTROLLER_SCROLL_VERTICAL );
@angstyloop
angstyloop / gist:cae639c1495f8c81e82b587e4a73630a
Created October 10, 2023 21:59
Disable scrolling on a GtkScale in GTK4.
/* No-op to prevent @w from propagating "scroll" events it receives.
*/
void disable_scroll_cb( GtkWidget *w ) {}
/* Disable scroll on a widget by adding a capture phase event handler and
* connecting a no-op callback to the "scroll" event.
*/
static GtkWidget *
disable_scroll( GtkWidget *w )
{
@angstyloop
angstyloop / gist:329c40500502a1c30e1b70edb5371ccc
Created October 10, 2023 21:01
Disable scrolling on a GtkSpinButton in GTK4.
/* No-op to prevent @w from propagating "scroll" events it receives.
*/
void disable_scroll_cb( GtkWidget *w ) {}
/* Disable scroll on a widget by adding a capture phase event handler and
* connecting a no-op callback to the "scroll" event.
*/
static GtkWidget *
disable_scroll( GtkWidget *w )
{
@angstyloop
angstyloop / g_match_with_mismatches_v3.c
Last active June 15, 2023 01:17
Like g_match_with_mismatches_v2.c, but the max pattern size is an argument to the preprocess and search functions. It is less optimized than the previous version, but now you can set the max pattern length to the size of the text every time if you want.
/* g_match_with_mismatches_v3.c
*
* Search for fuzzy matches of a pattern in text with @k or fewer mismatches
* (substitutions). Uses doubly-linked list GList from GLib.
*
* COMPILE
*
* gcc `pkg-config --cflags glib-2.0` -o g_match_with_mismatches_v3 g_match_with_mismatches_v3.c `pkg-config --libs glib-2.0`
*
* RUN
@angstyloop
angstyloop / g_match_with_mismatches_v2.c
Last active June 12, 2023 21:26
Like another one of my gists, g_match_with_mismatches.c. The search and preprocess functions were modified from the example code from "Fast and Practical Approximate String Matching" by Ricardo A. Baeza-Yates and Chris H. Perleberg, so that the maximum pattern length is a different constant than the length of the alphabet array, and not necessar…
/* g_match_with_mismatches_v2.c
*
* Search for fuzzy matches of a pattern in text with @k or fewer mismatches
* (substitutions). Uses doubly-linked list GList from GLib.
*
* COMPILE
*
* gcc `pkg-config --cflags glib-2.0` -o g_match_with_mismatches_v2 g_match_with_mismatches_v2.c `pkg-config --libs glib-2.0`
*
* RUN
@angstyloop
angstyloop / search_with_mismatches.c
Last active June 15, 2023 03:33
GTK4 demo app: search with mismatches. Search example strings with MAX_MISMATCHES number of mismatched characters (i.e. substitution errors). The search and preprocess functions were modified from the example code from "Fast and Practical Approximate String Matching" by Ricardo A. Baeza-Yates and Chris H. Perleberg.
/* search_with_mismatches.c
*
* COMPILE
*
* gcc `pkg-config --cflags gtk4` -o search_with_mismatches search_with_mismatches.c `pkg-config --libs gtk4`
*
* RUN
*
* search_with_mismatches
*
@angstyloop
angstyloop / g_match_with_mismatches.c
Last active June 12, 2023 20:57
Search for fuzzy matches of a pattern in text with @k or fewer mismatches (substitutions). Uses doubly-linked list GList from GLib. The search and preprocess functions were taken from the example code from "Fast and Practical Approximate String Matching" by Ricardo A. Baeza-Yates and Chris H. Perleberg. They make several optimizations, including…
/* g_match_with_mismatches.c
*
* Search for fuzzy matches of a pattern in text with @k or fewer mismatches
* (substitutions). Uses doubly-linked list GList from GLib.
*
* COMPILE
*
* gcc `pkg-config --cflags glib-2.0` -o g_match_with_mismatches g_match_with_mismatches.c `pkg-config --libs glib-2.0`
*
* RUN
@angstyloop
angstyloop / match_with_mismatches.c
Last active June 12, 2023 21:00
Search for fuzzy matches of a pattern in text with @k or fewer mismatches (substitutions) in C. The search and preprocess functions were taken from the example code from "Fast and Practical Approximate String Matching" by Ricardo A. Baeza-Yates and Chris H. Perleberg. This version is very optimized, and has a fixed maximum pattern length. For a …
/* match_with_mismatches.c
*
* Search for fuzzy matches of a pattern in text with @k or fewer mismatches
* (substitutions).
*
* COMPILE
*
* gcc -o match_with_mismatches match_with_mismatches.c
*
* RUN