Skip to content

Instantly share code, notes, and snippets.

@avanavana
avanavana / ipUtils.js
Last active January 2, 2021 20:50
ipUtils – Utilities for working with IP address whitelist/blacklist patterns
/**
* @file Utilities for working with IP address whitelist/blacklist patterns
* @author Avana Vana
* @module ipUtils
* @version 2.0.2
*/
module.exports = {
/*
@avanavana
avanavana / plusCodeUtils.js
Last active April 11, 2024 07:37
plusCodeUtils – Module exposing encode and decode methods for Open Location/Plus Codes (from/to map coordinates)
/**
* @file Open Location/Plus Code Encoding/Decoding Utilities
* @author Avana Vana <dear.avana@gmail.com>
* @module plusCodeUtils
* @version 2.6.0
*/
/**
* @constant {string} _numerals - string listing official base-20 open location/plus code numerals
* @readonly
@avanavana
avanavana / async-iteration.js
Last active February 6, 2021 19:34
Demonstrates two methods for iterating over arrays of data sequentially, while applying asynchronous functions to each element. The first, queueAsync(), is to be used with Array.prototype.map(), or any functor, while the second, loopAsync(), is to be used with non-functor, non-mapping 'for'-type loops.
/**
* @file Async Iteration Demonstration
* @author Avana Vana <dear.avana@gmail.com>
* @version 1.2.0
*/
/**
* Simple sleep function, for simulating asynchronous operations
*
* @function sleep
@avanavana
avanavana / splitaudio.sh
Last active March 25, 2021 14:01 — forked from vi/split_by_silence.sh
Using FFmpeg to split multimedia file into parts based on audio volume level
#!/bin/bash
# Modified from original to encode as mp3, renamed to 'splitaudio', and made the usage text more substantial
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
@avanavana
avanavana / splitaudiokf.sh
Last active March 25, 2021 14:04 — forked from vi/split_by_silence_kf.sh
Video-enhanced split_by_silence.sh script.
#!/bin/bash
# updated from original to encode as mp3, renamed 'splitaudiokf', and improved usage file
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
@avanavana
avanavana / tzdb.sh
Last active March 26, 2021 12:51
Checks timezonedb.com to see if timezone sql and csv db files have been updated today, and downloads them both if they have. Meant to be run daily with crontab.
#!/bin/bash
# add to crontab with something like '* 0 * * * /path/to/tzdb.sh &>/dev/null'
# change the -o option's parameter to save the files in a different dir on your machine
date=`date "+%Y-%m-%d"`
if [[ ! `curl -s https://timezonedb.com/date.txt` < "$date" ]]; then
curl -s "https://timezonedb.com/files/timezonedb.{csv,sql}.zip" -o "tzdb-${date}-#1.zip"
fi
@avanavana
avanavana / algorithm-bubbleSort.ts
Last active April 30, 2024 15:08
[Algorithms] Bubble Sort - TypeScript Implementation
/**
* @file algorithm-bubbleSort.ts - A TypeScript implement of the bubbleSort algorithm
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n), Θ(n^2), O(n^2)
* - Space complexity: O(1)
*/
/**
* @function bubbleSort
@avanavana
avanavana / algorithm-selectionSort.ts
Last active March 25, 2024 03:39
[Algorithms] Selection Sort - Typescript Implementation
/**
* @file algorithm-selectionSort.ts - A TypeScript implementation of the Selection Sort algorithm
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n^2), Θ(n^2), O(n^2)
* - Space complexity: O(1)
*/
/**
* @function selectionSort
@avanavana
avanavana / algorithm-mergeSort.ts
Last active March 25, 2024 03:40
[Algorithms] Merge Sort - TypeScript Implementation
/**
* @file algorithm-mergeSort.ts - A TypeScript implementation of the Merge Sort algorithm using recursion
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n log(n)), Θ(n log(n)), O(n log(n))
* - Space complexity: O(n)
*/
/**
* @function mergeSort
@avanavana
avanavana / algorithm-quickSortInitialPivot.ts
Last active April 7, 2024 15:08
[Algorithms] Quick Sort (Initial Pivot) - TypeScript Implementation
/**
* @file algorithm-quickSortInitialPivot.ts - A TypeScript implementation of the Quick Sort algorithm using recursion and the first element of the input array as a pivot
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n log(n)), Θ(n log(n)), O(n^2)
* - Space complexity: O(n)
*/
/**
* @function quickSort