Skip to content

Instantly share code, notes, and snippets.

View ferretwithaberet's full-sized avatar
🐧
EndeavourOS Linux User

Andrei ferretwithaberet

🐧
EndeavourOS Linux User
  • Romania
  • 01:59 (UTC +03:00)
View GitHub Profile
@ferretwithaberet
ferretwithaberet / hoisted-value.tsx
Last active August 4, 2025 11:19
React utility to hoist deepest value to the root component
import isPlainObject from "lodash/isPlainObject";
import merge from "lodash/merge";
import {
createContext,
Dispatch,
EffectCallback,
SetStateAction,
useCallback,
useContext,
useEffect,
@ferretwithaberet
ferretwithaberet / Picker.js
Last active September 23, 2023 07:41
RNUI example Picker wrapper and RemotePicker implementation, integrated with react-query
import { useMemo, forwardRef, Children, memo } from "react";
import { useTranslation } from "react-i18next";
import {
View,
TextField,
Picker as _Picker,
Colors,
} from "react-native-ui-lib";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
import {
@ferretwithaberet
ferretwithaberet / get_throttle_policy.py
Last active September 23, 2023 08:04
Throttle policy poller to send notification on throttle policy change for asus-wmi driver
# This script can be bound to a shortcut to show the current throttle policy mode.
import subprocess
TTP_PATH = '/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy'
def send_message(message, icon):
print(message)
subprocess.Popen(['notify-send', '-a', 'Throttle policy', '-i', icon, '-t', '1000', message])
@ferretwithaberet
ferretwithaberet / all-ancestors.js
Last active June 17, 2025 22:04
Get all ancestors of an element matching a selector in javascript
const allAncestors = (element, selector, acc = []) => {
if (!element.parentElement) return acc;
const ancestor = element.parentElement.closest(selector);
if (!ancestor) return acc;
return allAncestors(ancestor, selector, [ancestor, ...acc]);
}