Skip to content

Instantly share code, notes, and snippets.

@manzaloros
manzaloros / mini-pc.md
Last active February 8, 2024 06:00
Mini PC, windows / Linux dual boot

Machine

Beelink Ser7

What doesn't work

Ser7

  • Machine USB A port -> USB 2 Hub -> all 2.4g dongles
    • This will greatly increase the effective range of wireless devices, allowing true usage in a home theater environment.

Windows

  • Some games using Anti Cheat will freeze the entire PC after 4-5 minutes. This seems to be a problem with the Ser5 BIOS, I've seen it on multiple machines. However, booting the games on Linux rather than Windows seems to fix the issue
@manzaloros
manzaloros / convert_cue_to_chd.sh
Created November 22, 2023 04:35
Convert .cue files in current directory to chd
#!/bin/bash
# Loop over all files in the current directory with a ".cue" extension
for file in *.cue; do
# Invoke chdman createcd with input and output options
chdman createcd -i "${file%.*}.cue" -o "${file%.*}.chd"
done
@manzaloros
manzaloros / time-complexity.md
Last active October 25, 2022 16:47
Time Complexity Cheat Sheet

Top Down Recursive DP:

Non-memoized:

dp(n) => O((number of recursive calls) ^ (number of inputs))

  • recursive calls is how many times backtrack(...) is called recursively

Fibonacci:

         f(4)
 / \ 
@manzaloros
manzaloros / switch-arrays.js
Created August 3, 2021 12:17
Switching two arrays around
// If you have a function working on two arrays:
const compareArrays = (nums1, nums2) => {
...
}
// And you need the larger or smaller array to be in a certain position,
// you can do:
const compareArrays = (nums1, nums2) => {
// invoke function making smaller array first in the order:
if (nums1.length > nums2.length) return compareArrays(nums2, nums1);
@manzaloros
manzaloros / iterate-lowercase.js
Created July 24, 2021 18:27
Iterate over all lowercase letters
for (let i = 0; i < 26; i += 1) {
const currentLetter = String.charCodeFrom(i + 97);
}
@manzaloros
manzaloros / string-stuff.js
Last active November 8, 2022 16:05
String Stuff
const replace = (word, index, replacement) => {
return word.substr(0, index) + replacement + word.substr(index + replacement.length);
}
// another replace:
const replaceChar = (index, newChar, string) => {
if (index < string.length) return `${string.substring(0, index)}${newChar}${string.substring(index + 1)}`
}
const differByCase = (c1, c2) => Math.abs(c1.charCodeAt(0) - c2.charCodeAt(0) === 32)
@manzaloros
manzaloros / union-find-template.js
Created July 16, 2021 22:36
Union Find Template
const parent = Array(rows * cols).fill(0).map((value, index) => index);
const rank = Array(rows * cols).fill(0);
const find = (i) => {
if (parent[i] !== i) parent[i] = find(parent[i]);
return parent[i];
};
const union = (x, y) => {
@manzaloros
manzaloros / topoSort.js
Last active July 13, 2021 13:26
Topological sort using depth first search
// Time: O(number of vertices)
// Space: O(number of vertices)
// Using the params for course scheduler:
const findOrder = (numCourses, prerequisites) => {
/*
// Make graph adjacency list if needed:
const graph = new Map();
prerequisites.forEach(([course, prerequisite]) => {
@manzaloros
manzaloros / monotonic-queue-translated.md
Created June 15, 2021 19:01
Translated description of LC862. Shortest Subarray with Sum at Least K explanation

K is a sum you want to equal or be greater than in your window.

If you make an array of prefix sums, B, then you're looking for B[left] <= B[right] - K which means that the sum of the window in your original array A has to be >= K.

Given B[right], you're looking for B[left] such that B[left] <= B[right] - K.

You need to use an increasing monotonic queue because with each new B[i], the larger elements on the left won't work as candidates to make some future element B[j] &gt;= B[i] + K where j &gt; i.

array.sort((a,b) => a < b ? -1 : 1)