From 94c3e6048ff76fe86364ae6f5356680acf616433 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 22 May 2025 16:11:43 -0500 Subject: [PATCH] feat: remove code --- .../extrema-circular-buffer/map.cpp | 51 ---------------- .../extrema-circular-buffer/monotonic.cpp | 59 ------------------- .../extrema-circular-buffer/naive.cpp | 38 ------------ .../code/algorithms/leetcode-daily/beauty.cpp | 26 -------- .../algorithms/leetcode-daily/cfps-naive.py | 11 ---- .../algorithms/leetcode-daily/cfps-twoptr.py | 16 ----- public/code/algorithms/leetcode-daily/cgn.cpp | 19 ------ .../code/algorithms/leetcode-daily/minend.cpp | 15 ----- .../algorithms/leetcode-daily/mnootmad.cpp | 13 ---- .../algorithms/leetcode-daily/msl-bitwise.py | 30 ---------- .../algorithms/leetcode-daily/msl-naive.py | 18 ------ .../git-server-ui.systemd | 12 ---- .../git-server.apacheconf | 30 ---------- .../hosting-a-git-server/gitconfig.git | 2 - 14 files changed, 340 deletions(-) delete mode 100644 public/code/algorithms/extrema-circular-buffer/map.cpp delete mode 100644 public/code/algorithms/extrema-circular-buffer/monotonic.cpp delete mode 100644 public/code/algorithms/extrema-circular-buffer/naive.cpp delete mode 100644 public/code/algorithms/leetcode-daily/beauty.cpp delete mode 100644 public/code/algorithms/leetcode-daily/cfps-naive.py delete mode 100644 public/code/algorithms/leetcode-daily/cfps-twoptr.py delete mode 100644 public/code/algorithms/leetcode-daily/cgn.cpp delete mode 100644 public/code/algorithms/leetcode-daily/minend.cpp delete mode 100644 public/code/algorithms/leetcode-daily/mnootmad.cpp delete mode 100644 public/code/algorithms/leetcode-daily/msl-bitwise.py delete mode 100644 public/code/algorithms/leetcode-daily/msl-naive.py delete mode 100644 public/code/software/hosting-a-git-server/git-server-ui.systemd delete mode 100644 public/code/software/hosting-a-git-server/git-server.apacheconf delete mode 100644 public/code/software/hosting-a-git-server/gitconfig.git diff --git a/public/code/algorithms/extrema-circular-buffer/map.cpp b/public/code/algorithms/extrema-circular-buffer/map.cpp deleted file mode 100644 index cb589aa..0000000 --- a/public/code/algorithms/extrema-circular-buffer/map.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include - -class ExtremaCircularBuffer { -public: - void push_back(double value) { - if (prices.size() == capacity) { - double front = prices.front(); - - if (--sorted_prices[front] == 0) - sorted_prices.erase(front); - prices.pop_front(); - } - - prices.push_back(value); - ++sorted_prices[value]; - } - - void pop_front() { - if (prices.empty()) { - throw std::out_of_range("Cannot pop_front() from empty buffer"); - } - - double front = prices.front(); - - if (--sorted_prices[front] == 0) - sorted_prices.erase(front); - prices.pop_front(); - } - - size_t size() const { return prices.size(); } - - double get_max() const { - if (prices.empty()) { - throw std::out_of_range("Cannot find max() of empty buffer"); - } - - return sorted_prices.rbegin()->first; - } - - double get_min() const { - if (prices.empty()) { - throw std::out_of_range("Cannot find min() of empty buffer"); - } - - return sorted_prices.begin()->first; - } - - /* methods & fields omitted for brevity */ -}; diff --git a/public/code/algorithms/extrema-circular-buffer/monotonic.cpp b/public/code/algorithms/extrema-circular-buffer/monotonic.cpp deleted file mode 100644 index 3581581..0000000 --- a/public/code/algorithms/extrema-circular-buffer/monotonic.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include - -class ExtremaCircularBuffer { -public: - void push_back(double value) { - if (prices.size() == capacity) { - double front_value = prices.front(); - pop_max(front_value); - prices.pop_front(); - } - - prices.push_back(value); - push_max(value); - } - - void pop_front() { - if (prices.empty()) { - throw std::out_of_range("Cannot pop_front() from empty buffer"); - } - - double front_value = prices.front(); - pop_max(front_value); - prices.pop_front(); - } - - double get_max() const { - if (prices.empty()) { - throw std::out_of_range("Cannot find max() of empty buffer"); - } - - return maxs.front().first; - } - -private: - void push_max(double value) { - size_t popped = 0; - - while (!maxs.empty() && maxs.back().first < value) { - popped += maxs.back().second + 1; - maxs.pop_back(); - } - - maxs.emplace_back(value, popped); - } - - void pop_max(double value) { - size_t popped = maxs.front().second; - - if (popped == 0) { - maxs.pop_front(); - } else { - --maxs.front().second; - } - } - - /* methods & fields omitted for brevity */ -}; diff --git a/public/code/algorithms/extrema-circular-buffer/naive.cpp b/public/code/algorithms/extrema-circular-buffer/naive.cpp deleted file mode 100644 index c43d3c8..0000000 --- a/public/code/algorithms/extrema-circular-buffer/naive.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -class ExtremaCircularBuffer { -public: - ExtremaCircularBuffer(size_t capacity) : capacity(capacity) {} - - void push_back(double value) { - if (prices.size() == capacity) { - prices.pop_front(); - } - - prices.push_back(value); - } - - void pop_front() { - if (prices.empty()) { - throw std::out_of_range("Cannot pop_front() from empty buffer"); - } - - prices.pop_front(); - } - - size_t size() const { return prices.size(); } - - double get() const { - if (prices.empty()) { - throw std::out_of_range("Cannot find max() of empty buffer"); - } - - return *std::max_element(prices.begin(), prices.end()); - } - -private: - std::deque prices; - size_t capacity; -}; diff --git a/public/code/algorithms/leetcode-daily/beauty.cpp b/public/code/algorithms/leetcode-daily/beauty.cpp deleted file mode 100644 index ab63688..0000000 --- a/public/code/algorithms/leetcode-daily/beauty.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -std::vector maximumBeauty(std::vector>& items, std::vector& queries) { - std::sort(items.begin(), items.end()); - std::vector> sorted_queries; - sorted_queries.reserve(queries.size()); - for (size_t i = 0; i < queries.size(); ++i) { - sorted_queries.emplace_back(queries[i], i); - } - std::sort(sorted_queries.begin(), sorted_queries.end()); - - int beauty = items[0][1]; - size_t i = 0; - std::vector ans(queries.size()); - - for (const auto [query, index] : sorted_queries) { - while (i < items.size() && items[i][0] <= query) { - beauty = std::max(beauty, items[i][1]); - ++i; - } - ans[index] = i > 0 && items[i - 1][0] <= query ? beauty : 0; - } - - return ans; -} diff --git a/public/code/algorithms/leetcode-daily/cfps-naive.py b/public/code/algorithms/leetcode-daily/cfps-naive.py deleted file mode 100644 index 1e882d8..0000000 --- a/public/code/algorithms/leetcode-daily/cfps-naive.py +++ /dev/null @@ -1,11 +0,0 @@ -def countFairPairs(self, nums, lower, upper): - nums.sort() - ans = 0 - - for i, num in enumerate(nums): - k = bisect_left(nums, lower - num, 0, i) - j = bisect_right(nums, upper - num, 0, i) - - ans += k - j - - return ans diff --git a/public/code/algorithms/leetcode-daily/cfps-twoptr.py b/public/code/algorithms/leetcode-daily/cfps-twoptr.py deleted file mode 100644 index 0636fa9..0000000 --- a/public/code/algorithms/leetcode-daily/cfps-twoptr.py +++ /dev/null @@ -1,16 +0,0 @@ -def countFairPairs(self, nums, lower, upper): - nums.sort() - ans = 0 - - def pairs_leq(x: int) -> int: - pairs = 0 - l, r = 0, len(nums) - 1 - while l < r: - if nums[l] + nums[r] <= x: - pairs += r - l - l += 1 - else: - r -= 1 - return pairs - - return pairs_leq(upper) - pairs_leq(lower - 1) diff --git a/public/code/algorithms/leetcode-daily/cgn.cpp b/public/code/algorithms/leetcode-daily/cgn.cpp deleted file mode 100644 index 4237eec..0000000 --- a/public/code/algorithms/leetcode-daily/cgn.cpp +++ /dev/null @@ -1,19 +0,0 @@ -class Solution { -public: - static constexpr long long MOD = 1e9 + 7; - long long mpow(long long a, long long b, long long mod=MOD) { - long long ans = 1; - while (b > 0) { - if (b & 1) { - ans = (ans * a) % MOD; - } - a = (a * a) % MOD; - b >>= 1; - } - return ans; - } - int countGoodNumbers(long long n) { - long long even_slots = (n + 1) / 2, odd_slots = n / 2; - return (mpow(5, even_slots) * mpow(4, odd_slots)) % MOD; - } -}; diff --git a/public/code/algorithms/leetcode-daily/minend.cpp b/public/code/algorithms/leetcode-daily/minend.cpp deleted file mode 100644 index 46a7222..0000000 --- a/public/code/algorithms/leetcode-daily/minend.cpp +++ /dev/null @@ -1,15 +0,0 @@ -long long minEnd(int n, long long x) { - int bits_to_distribute = n - 1; - long long mask = 1; - - while (bits_to_distribute > 0) { - if ((x & mask) == 0) { - if ((bits_to_distribute & 1) == 1) - x |= mask; - bits_to_distribute >>= 1; - } - mask <<= 1; - } - - return x; -} diff --git a/public/code/algorithms/leetcode-daily/mnootmad.cpp b/public/code/algorithms/leetcode-daily/mnootmad.cpp deleted file mode 100644 index 8f98c68..0000000 --- a/public/code/algorithms/leetcode-daily/mnootmad.cpp +++ /dev/null @@ -1,13 +0,0 @@ -class Solution { -public: - int minimumOperations(vector& nums) { - vector freq(101, 0); - int i; - for (i = nums.size() - 1; i >= 0; --i) { - if (++freq[nums[i]] == 2) { - return ceil((i + 1) / 3.0); - } - } - return 0; - } -}; diff --git a/public/code/algorithms/leetcode-daily/msl-bitwise.py b/public/code/algorithms/leetcode-daily/msl-bitwise.py deleted file mode 100644 index 148a4b2..0000000 --- a/public/code/algorithms/leetcode-daily/msl-bitwise.py +++ /dev/null @@ -1,30 +0,0 @@ -def minimumSubarrayLength(self, nums, k): - ans = sys.maxsize - - largest = max(*nums, k) - num_digits = floor((log(max(largest, 1))) / log(2)) + 1 - - counts = [0] * num_digits - l = 0 - - def update(x, delta): - for i in range(len(counts)): - if x & 1: - counts[i] += delta - x >>= 1 - - def bitwise_or(): - return reduce( - operator.or_, - (1 << i if count else 0 for i, count in enumerate(counts)), - 0 - ) - - for r, num in enumerate(nums): - update(num, 1) - while l <= r and bitwise_or() >= k: - ans = min(ans, r - l + 1) - update(nums[l], -1) - l += 1 - - return -1 if ans == sys.maxsize else ans diff --git a/public/code/algorithms/leetcode-daily/msl-naive.py b/public/code/algorithms/leetcode-daily/msl-naive.py deleted file mode 100644 index 509c6d0..0000000 --- a/public/code/algorithms/leetcode-daily/msl-naive.py +++ /dev/null @@ -1,18 +0,0 @@ -def minimumSubarrayLength(self, nums, k): - # provide a sentinel for "no window found" - ans = sys.maxsize - window = deque() - l = 0 - - # expand the window by default - for r in range(len(nums)): - # consider `nums[r]` - window.append(nums[r]) - # shrink window while valid - while l <= r and reduce(operator.or_, window) >= k: - ans = min(ans, r - l + 1) - window.popleft() - l += 1 - - # normalize to -1 as requested - return -1 if ans == sys.maxsize else ans diff --git a/public/code/software/hosting-a-git-server/git-server-ui.systemd b/public/code/software/hosting-a-git-server/git-server-ui.systemd deleted file mode 100644 index c2c77d1..0000000 --- a/public/code/software/hosting-a-git-server/git-server-ui.systemd +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Git Server UI -After=network.target - -[Service] -User=apache -WorkingDirectory=/srv/git/git-server-ui -ExecStart=/root/.local/bin/gunicorn --workers 3 --bind 0.0.0.0:8000 --chdir /srv/git wsgi:app -Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/public/code/software/hosting-a-git-server/git-server.apacheconf b/public/code/software/hosting-a-git-server/git-server.apacheconf deleted file mode 100644 index 8c8c62e..0000000 --- a/public/code/software/hosting-a-git-server/git-server.apacheconf +++ /dev/null @@ -1,30 +0,0 @@ - - ServerName - - SSLEngine on - SSLCertificateFile /etc/letsencrypt/live//fullchain.pem - SSLCertificateKeyFile /etc/letsencrypt/live//privkey.pem - - SetEnv GIT_PROJECT_ROOT /srv/git - SetEnv REMOTE_USER $REDIRECT_REMOTE_USER - - ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ - - - Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch - Require all granted - AllowOverride None - - - - AuthType Basic - AuthName "Git Access" - AuthUserFile /srv/git/.htpasswd - Require expr !(%{QUERY_STRING} -strmatch '*service=git-receive-pack*' || %{REQUEST_URI} =~ m#/git-receive-pack$#) - Require valid-user - - ProxyPassMatch ^/git/ ! - ProxyPreserveHost On - ProxyPass / http://127.0.0.1:8000/ - ProxyPassReverse / http://127.0.0.1:8000/ - diff --git a/public/code/software/hosting-a-git-server/gitconfig.git b/public/code/software/hosting-a-git-server/gitconfig.git deleted file mode 100644 index 2735de2..0000000 --- a/public/code/software/hosting-a-git-server/gitconfig.git +++ /dev/null @@ -1,2 +0,0 @@ -[safe] - directory = *