This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |