Skip to content

Instantly share code, notes, and snippets.

View WVAviator's full-sized avatar

Alexander Durham WVAviator

View GitHub Profile
@WVAviator
WVAviator / killport.sh
Last active July 10, 2025 15:46
Killport Function
# Paste this line into .zshrc or .bashrc
# Using this alias will identify the process running on the specified port and kill it
# Example: 'killport 8080' - kills the process running on port 8080
alias killport='function _killport(){kill -9 $(lsof -t -i:$1); }; _killport'
@WVAviator
WVAviator / defaultdict.ts
Last active June 3, 2023 16:21
Similar to Python's defaultdict, this function returns an object that will set a default value for any key that is not already present.
/**
* Similar to Python's defaultdict, this function returns an object that will set a default value for any key that is not present in the dictionary.
* @param initializer A function or constructor that returns the default value for the dictionary
*/
const defaultdict = <T>(initializer: () => T) => {
const dict: Record<string | symbol, T> = {};
const handler: ProxyHandler<typeof dict> = {
get: (dict, prop) => {
if (!(prop in dict)) {
dict[prop] = initializer();
@WVAviator
WVAviator / SkipLMS.js
Last active May 31, 2023 13:45
Tell the browser to automatically click the "next" button in a typical LMS course.
// Paste the below code in your browser console to automatically skip to the next slide of an LMS course
// as soon as the button becomes enabled. This saves time with highly interactive courses, and completely
// automates non-interactive courses. Note that with interactive courses, you may still need to click some
// items on each slide in order to enable the next button - but you will not need to click next.
// Modify the value in quotes with the CSS selector for the "Next" button in your LMS (most courses use '#next')
const nextSelector = '#next';
// A small delay in milliseconds prevents some LMS courses from skipping too quickly and showing partially incomplete
const clickDelay = 2500;
@WVAviator
WVAviator / Extensions.cs
Last active October 30, 2021 11:54
Unity - GetComponentsOnlyInChildren
using System.Collections.Generic;
using UnityEngine;
public static class Extensions
{
public static T[] GetComponentsOnlyInChildren<T>(this Component parent, bool includeInactive = false)
where T : Component
{
List<T> allComponents = new List<T>(parent.GetComponentsInChildren<T>(includeInactive));
if (parent.TryGetComponent(out T parentComponent)) allComponents.Remove(parentComponent);