Skip to content

Instantly share code, notes, and snippets.

View ParadoxV5's full-sized avatar
🛬

ParadoxV5

🛬
View GitHub Profile
@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
Created October 18, 2024 21:16
魔塔语(大五码当GB读的乱码)
# ### 问:大五码系列和GB系列的字节长度“兼容”吗?
# 大五码系列用一或两个字节编码一个字符,而最新的 GB 18030 用一、二或四个。
# * 大五和GB的单字节范围都是 `00`–`7F`;大于这个范围的字节才表示多节的编码。
# * GB 18030 特有的驷节编码通过 `30`–`39` 范围的第二节辨识;这个范围小于大五*和GB*的双节编码的第二节范围。
# 排除上面后,大五码系列除了错误之外的双字节均对应GB系列的双字节————虽然有些大五范围超出了GB范围。
puts ARGV.map { _1
.encode(Encoding::Big5_HKSCS) # 大五码・香港增补字符集
.force_encoding(Encoding::GB18030) # 信息技术 中文编码字符集(码位最多)
}.join(' ').encode(Encoding.default_external)
@ParadoxV5
ParadoxV5 / Eudora.md
Last active October 3, 2024 18:58
Eudora Fast Dig 尤多拉速挖
@ParadoxV5
ParadoxV5 / 红龙贼学习笔记.md
Last active September 20, 2024 05:51
红龙贼学习笔记(未完待续)

(Should I compose an English edition as well?)

此番学习参考了[燁魔的教学][燁魔]。🙏

她早已像我这么强。🪦 (也是,我还给她介绍了向导学徒,说明她早已出师(不是四声)。)

无限火球、点燃、火妖、“水妖”(银樽)等哀绿法虽然自闭,但是不管过度再怎么顺滑,它们也依然有不低的门槛和技术天花板。 操作者要在面临烧绳的鸭梨下考虑牌序(比如“奥术脑洞”刷夜能在复制了太多法强后穿进疲劳紫砂),技术含量比♾️🚪、♾️🧊多多了。

@ParadoxV5
ParadoxV5 / Push–Relabel Maximum Flow.rb
Last active July 6, 2024 02:37
Ruby Discord Jurassic Challenge
# frozen_string_literal: true
# Goldberg–Tarjan Push–Relabel Algorithm
# with FIFO active set and BFS pre-labeling
# * https://www.adrian-haarbach.de/idp-graph-algorithms/implementation/maxflow-push-relabel/index_en.html
# * https://en.wikipedia.org/wiki/Push%E2%80%93relabel_maximum_flow_algorithm?oldid=1230043247
# variable names are in dummies’ terminologies
class PushRelabel
class Node
@ParadoxV5
ParadoxV5 / int2bytestr.rb
Created May 25, 2024 04:07
Pack an integer to a byte-sequence string. Discussed in https://discord.com/invite/ruby-518658712081268738 #general. I dedicate this to the Public Domain.
def int2bytestr(int, bytesize = int.size)
[
# Format to hex, left-pad with `0` (big-endian) for `bytesize * 2` nibbles
sprintf('%0*X', bytesize * 2, int)
].pack 'H*' # Pack string of hex chars to string of raw bytes
end
# Demo
print "actual\t"
p int2bytestr(0x4_20_69_de_ad_be_ef_13_37, 10)
# Marker module for “my library”
module MyError end
# Built-in exception class example
ZeroDivisionError.include MyError
puts begin
1 / 0
rescue MyError => e
e
end #=> divided by 0