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
// You can either use lock() and get a function that releases the lock, or you could use lockAndRun() to wrap around a function! Amazing! | |
class AsyncLock { | |
private promises = new Map<string, Promise<void>>(); | |
public async lock(key: string): Promise<VoidFunction> { | |
if (this.promises.has(key)) { | |
await this.promises.get(key); | |
} | |
let release: VoidFunction; | |
const lockPromise = new Promise<void>(resolve => { |
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
#!/bin/bash | |
set -e | |
if [[ $# -eq 0 ]]; then | |
echo "Usage: $(basename $0) [packages ...]" | |
exit | |
fi | |
if ! command -v yarn &> /dev/null; then |
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
{ | |
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", |
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
ssh -fN -L 0.0.0.0:8000:192.168.99.100:80 user@target |
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
# Usage: download-npm.sh <package-name> | |
#!/bin/bash | |
set -e | |
set -u | |
NC='\033[0m' | |
LIGHT_GREEN='\033[1;32m' | |
libName="$1" |
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
inotifywait -mq --format '%w%f/FOLDER_NAME/' --event=CREATE /path/to/containing/folder | while read DIR_TO_CLEAR | |
do | |
echo "$DIR_TO_CLEAR" | |
sleep 1 | |
find "$DIR_TO_CLEAR" -delete | |
mkdir -p "$DIR_TO_CLEAR" | |
done |
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
const string ZERO_TO_255 = "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])"; | |
static readonly string IP_REGEX_PATTERN = $@"({ZERO_TO_255}\.){{3}}{ZERO_TO_255}"; | |
static readonly Regex FindIPRegex = new Regex(IP_REGEX_PATTERN, RegexOptions.Compiled); | |
static readonly Regex ValidateIPRegex = new Regex($"^{IP_REGEX_PATTERN}$", RegexOptions.Compiled); |
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
#!/bin/bash | |
# Hit Ctrl+C a lot of times to stop | |
# Ping google's 8.8.8.8 DNS server | |
while true; do | |
timeout 1 ping -q -c 1 8.8.8.8 > /dev/null && echo $(date +%Y/%m/%d_%H:%M:%S) GOOD && sleep 1 || echo $(date +%Y/%m/%d_%H:%M:%S) NO INTERNET; | |
done |