Skip to content

Instantly share code, notes, and snippets.

@avanavana
avanavana / algorithm-quickSortMiddlePivot.ts
Last active April 7, 2024 15:08
[Algorithms] Quick Sort (Middle Pivot) - TypeScript Implementation
/**
* @file algorithm-quickSortMiddlePivot.ts - A TypeScript implementation of the Quick Sort algorithm using recursion and the middle element of the input array (or the element just left of center) as a pivot
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n log(n)), Θ(n log(n)), O(n^2) (rare)
* - Space complexity: O(n)
*/
/**
* @function quickSort
@avanavana
avanavana / algorithm-insertionSort.ts
Created March 29, 2024 07:43
[Algorithms] Insertion Sort - TypeScript Implementation
/**
* @file algorithm-insertionSort.ts - A TypeScript implementation of the Insertion Sort algorithm
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n), Θ(n^2), O(n^2)
* - Space complexity: O(1)
*/
/**
* @function insertionSort
@avanavana
avanavana / algorithm-quickSort.ts
Last active May 28, 2024 06:18
[Algorithms] Quick Sort (Middle Pivot, Optimized) - TypeScript Implementation
/**
* @file algorithm-quickSort.ts - A TypeScript implementation of the Quick Sort algorithm using recursion, incrementing/decrementing pointers instead of array mutation for optimization of space complexity, and a pivot selected in the middle (or just to the left of the middle) of an input array
* @author Avana Vana
* @desc Algorithmic complexity:
* - Time complexity: Ω(n log(n)), Θ(n log(n)), O(n^2) (rare)
* - Space complexity: O(log(n))
*/
/**
* @function quickSort
@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
@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-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-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 / 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 / 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 / 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