Skip to content

Instantly share code, notes, and snippets.

View ParadoxV5's full-sized avatar
🎮

ParadoxV5

🎮
View GitHub Profile
@ParadoxV5
ParadoxV5 / ≠ and ≶ are different.md
Created August 17, 2025 03:42
≠ and ≶ are different.

Today, I realized that != and <> can be different.

Of course, they are equivalent in the ideal domain, but we live in a polymorphic world where two values can be incomparable with each other. For example, 1, a number, is incomparable to "Hello", a string of text. This relation is mathematically known as a Partial Ordering.

Arguably, "Hello" doesn’t literally equal one, which we can denote as "Hello" ≠ 1. On the other hand, "Hello" ≶ 1 doesn’t quite hold. Their mutual incomparability means that neither is less or greather than the other; it would instead be "Hello" ≸ 1.

@ParadoxV5
ParadoxV5 / My Containers.rbs
Created July 19, 2025 02:10
Concepts of a Containers Std.Lib.
# Basics
module Container[V, E = V]: _Container[V, E]
include Enumerable[E]
interface _Container[V, E = V]
def self.from: (Enumerable[E] other) -> instance
def include?: (V value) -> bool
def add?: (E entry) -> E?
@ParadoxV5
ParadoxV5 / C++ Type Array.cpp
Created July 17, 2025 04:32
C++ Compile-time Fixed-Size Array of Types
#include <cstdint>
#include <tuple>
#include <type_traits>
#include <iostream>
using std::size_t;
/** Compile-time Fixed-Size Array of Types */
template<typename... T> struct TypeArray {
using TupleType = std::tuple<T...>;
template<size_t i> using At =
#include <stddef.h>
#include <stdint.h>
/**
Here is my Standard-compliant, SIMD-capable version of
https://pzemtsov.github.io/2016/11/06/bug-story-alignment-on-x86.html.
I wonder which one is faster in a benchmark?
*/
_Bool check_ip_header_sum(const char *p, size_t size)
{
#include <optional>
#include <cstdio>
int main() {
std::optional<int> optional_of_none(std::nullopt);
std::optional<std::optional<int>> optional_of_optional(optional_of_none);
std::printf(
"optional_of_none.has_value():\t%d\n"
"optional_of_optional.has_value():\t%d\n",
@ParadoxV5
ParadoxV5 / golf.rb
Created May 14, 2025 01:51
Sow and Tell – Ruby Discord Mother’s Day 2025 challenge
puts$*[0].gsub(/(.)\1*/){'_🌷🌼🪻'[it.size]+$1}
@ParadoxV5
ParadoxV5 / null_lambda.cpp
Created February 28, 2025 05:03
Yes, there are null lambdas in C++!
// Lambda is a type of *value*, and *values* can’t be null.
// But y’know what can? *References* to values.
#include <functional>
#include <stdio.h>
const auto lambda = [] () -> const char* {
return "Hello from lambda!";
};

ぷよ World

Primp

The main world est. Fever designed to “modernize” the ぷよぷよ franchise

  • Primp Town
    • Primp Magic School: a village school with a wing emblem
      • Ms. Accord & Popoi
      • Amitie, Klug, Sig, Raffina, Lidelle
        • Possessed Klug
  • Yu & Rei, the Ocean Prince
@ParadoxV5
ParadoxV5 / vampire.rb
Created October 27, 2024 18:54
Ruby Discord Halloween 2024 Challenge
VAMPIRES = ARGV.each_with_index.filter_map do|input, idx|
number = Integer input
length = input.length
next if length.odd?
fangs = input.chars.permutation(length).filter_map do|digits|
digits2 = digits.pop(length/2)
next if digits.last == '0' and digits2.last == '0' # This isn’t counted
a = Integer digits .join, 10
b = Integer digits2.join, 10
@ParadoxV5
ParadoxV5 / 魔塔语.rb
Last active July 10, 2025 04:19
魔塔语(大五码当GB读的乱码)
# ### 问:大五码系列和GB系列的字节长度“兼容”吗?
# 大五码系列用一或两个字节编码一个字符,而最新的 GB 18030 用一、二或四个。
# * 大五和GB的单字节范围都是 `00`–`7F`;大于这个范围的字节才表示多节的编码。
# * GB 18030 特有的驷节编码通过 `30`–`39` 范围的第二节辨识;这个范围小于大五*和GB*的双节编码的第二节范围。
# 排除上面后,大五码系列除了错误之外的双字节均对应GB系列的双字节————虽然有些大五范围超出了GB范围。
puts ARGV.map { it
.encode(Encoding::Big5_HKSCS) # 大五码・香港增补字符集
.force_encoding(Encoding::GB18030) # 信息技术 中文编码字符集(码位最新最全)
.encode(Encoding.default_external)