Skip to content

Instantly share code, notes, and snippets.

@n18l
n18l / Hot Corners.ahk
Last active July 20, 2024 15:15
An AutoHotKey script for hot corner functionality, similar to macOS.
#NoTrayIcon
#NoEnv
#Persistent
#SingleInstance Force
SendMode Input
CoordMode, Mouse, Screen
; Tracks whether a hot corner was just activated, preventing it from being
; activated repeatedly.
global PreviousCorner := "None"
@n18l
n18l / partitionArray.js
Last active December 8, 2021 23:27
A function for partitioning an array based on the result of a filter function, rather than discarding the failed filter results. Sane people can also just run two `Array.filter()` methods.
/**
* Divides one array into two based on a filter function, returning the results
* of the filter as a [pass, fail] tuple.
*
* @param array The array to partition into separate arrays based on the provided filter.
* @param filterFunction The filter function to use to determine how each array item should be partitioned.
*
* @returns A tuple of partitioned array items, functionally equivalent to `[pass, fail]` in relation to the provided
* filter function.
*/
@n18l
n18l / content.md
Last active November 12, 2021 23:44
Blog / 2021-11-12T21:50:16Z / A Second Blog Post Test

Ground Control to Major Malfunction

Thomas had never seen such bullshit before.

@n18l
n18l / attempt.js
Last active September 8, 2021 22:44
Repeatedly attempts to execute a function based on provided criteria that are reevaluated on each attempt. A dumb function for dumb situations that shouldn't exist.
/**
* Repeatedly attempts to execute a function based on provided criteria that are
* reevaluated on each attempt.
*
* @param {Function} criteria The criteria to evaluate on each attempt to determine if the
* success handler should be invoked. Note that the result of this
* function will be coerced to a boolean value.
* @param {Function} onSuccess A function to invoke if an attempt evaluates the criteria as true.
* @param {Function} onFailure A function to invoke if all attempts evaluate the criteria as false.
* @param {Number} intervalMs How frequently (in milliseconds) to reevaluate the criteria.
@n18l
n18l / content.md
Last active November 12, 2021 23:43
Blog / 2021-08-24T15:53:32Z / A Test of Gists as Blog Posts

This is Only a Test

Look, this post has content!

@n18l
n18l / debug_log.php
Created March 31, 2020 22:07
Readable logging for PHP
/**
* Writes a formatted line to the current environment's error log.
*
* @param mixed... $items_to_log One or more items to output to the log.
*
* @since 2020.2.0
* @author Nick Brombal <[email protected]>
*/
function debug_log(...$items_to_log): void
{
@n18l
n18l / css-selector-regex.php
Last active February 21, 2020 22:29
Regular expression to capture a selector within a stylesheet
<?php
/**
* Creates a regular expression string for properly capturing a specific CSS
* selector within a stylesheet. This regular expression ensures that the
* captured selector isn't actually a substring of another selector.
*
* As always, regular expressions should be considered a last resort for most
* string manipulation due to their high probablity of human error. Think hard
* about whether or not this solution is truly the last or best one available to
@n18l
n18l / .gitconfig
Created April 5, 2019 22:45
Nick's git Aliases
[alias]
st = status
graph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
# I use tug and weld to simplify my branch management. I often want to
# keep a branch distinct even when it could be fast-forwarded, so weld
# saves me a second there. I use tug to update a branch without
# automatically initiating a merge when I don't mean to.
tug = pull --ff-only
@n18l
n18l / countdown.js
Last active August 29, 2015 14:21
Javascript countdown timer with page redirect
$(function() {
// If target date is specific to one timezone, set to true and specify it
var absoluteTarget = true;
var targetTimeZone = -5;
var targetDateUTC = new Date(Date.UTC(2015,05,22)).getTime();
var currentDate = new Date();
var timeZoneOffset = (absoluteTarget ? targetTimeZone * -60 : currentDate.getTimezoneOffset()) * 60 * 1000;
var targetDate = targetDateUTC + timeZoneOffset;