Skip to content

Instantly share code, notes, and snippets.

View Louis-7's full-sized avatar
πŸ•ΉοΈ

Louis Louis-7

πŸ•ΉοΈ
View GitHub Profile
@Louis-7
Louis-7 / background-color.js
Last active June 4, 2025 05:39
Determine font color based on the background color
// suppose background color is: rbg(0, 23, 255)
function textColorBasedOnBackground(backgroundColor) {
backgroundColor = backgroundColor.substring(1);
const r = parseInt(backgroundColor.substring(0,2), 16); // 0 ~ 255
const g = parseInt(backgroundColor.substring(2,4), 16);
const b = parseInt(backgroundColor.substring(4,6), 16);
const srgb = [r / 255, g / 255, b / 255];
const x = srgb.map((i) => {
if (i <= 0.04045) {
@nicksieger
nicksieger / ruby-3.0.x.patch
Created September 25, 2024 21:48
Patch to build ruby-3.0.x on Sequoia
--- ext/bigdecimal/bigdecimal.c.orig 2024-09-25 16:24:50
+++ ext/bigdecimal/bigdecimal.c 2024-09-25 16:25:15
@@ -65,7 +65,7 @@
static ID id_half;
/* MACRO's to guard objects from GC by keeping them in stack */
-#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
+#define ENTER(n) volatile VALUE vStack[n];int iStack=0
#define PUSH(x) (vStack[iStack++] = (VALUE)(x))
#define SAVE(p) PUSH((p)->obj)