Skip to content

Instantly share code, notes, and snippets.

View adnanalbeda's full-sized avatar

Adnan AlBeda adnanalbeda

View GitHub Profile
@adnanalbeda
adnanalbeda / DevExtensions.ts
Last active April 19, 2022 10:49
A group of extension methods to debug and log data.
/* eslint-disable no-extend-native */
/*
* Too lazy to debug?
* This file provides basic (alert and console) commands as extension methods for development purposes.
* It can be anywhere inside the project and it should work just fine.
* However, for better readability, it's better to be located inside /src/extensions directory.
*/
// Export as Module
// Insert an element after the selected element.
function insertElementAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
@adnanalbeda
adnanalbeda / Config Files Manual.md
Last active May 1, 2023 18:41
For future me, Here you'll find the configs setup you need when you create a new React project

Configs Files

.editorconfig

This is a basic config which is required in all languages. It's the basic config for IDEs and Editors on how to handle formatting, etc.

Create .editorconfig file then change the following as you wish:

# EditorConfig is awesome: https://EditorConfig.org
@adnanalbeda
adnanalbeda / ThemeManager.tsx
Last active January 23, 2024 14:31
Vite_React_Tailwind
// *******************************************************
// * for tailwind, in order for this to work, *
// * must have this config: (darkMode: "class"). *
// *******************************************************
import {
createContext,
useCallback,
useContext,
useEffect,
@adnanalbeda
adnanalbeda / gist:348a0901d82565a7cfecc1e41fba9bc3
Last active February 4, 2023 13:12 — forked from jaredatch/gist:5645033
Modify/change the default allowed tags for bbPress.
<?php
/**
* Modify/change the default allowed tags for bbPress.
*
* The default list (below) is in bbpress/includes/common/formatting.php, L24-66.
* Adjust below as needed. This should go in your theme's functions.php file (or equivilant).
*/
function ja_filter_bbpress_allowed_tags() {
return array(
@adnanalbeda
adnanalbeda / JSXChildrenUtils.tsx
Last active August 3, 2023 19:48
React Utility Components
export type XNode = JSX.Element | string | number | boolean | null | undefined;
export type XChild = XNode;
export type XC = XChild;
export type XCs = XChild[] | XChild;
export type ChildrenBuilder<T> = (options: T) => XC;
export type CB<T> = ChildrenBuilder<T>;
export type XC_CB<T> = ChildrenBuilder<T> | XCs;
export function buildChildren<T>(options: T, children?: XC_CB<T>) {
@adnanalbeda
adnanalbeda / debounce.ts
Last active March 4, 2023 18:39
Vanilla TS Utils
// limit execution of a function to one per x amount of time to the last interaction.
// Set 'immediate' to true to run the function then it waits for x time of no interaction.
// Keep it undefined or false for default behavior, which is to execute after x time no interaction.
export default function debounce(
func: () => void,
wait: number,
immediate?: boolean
) {
// 'private' variable for instance
// The returned function will be able to reference this due to closure.
@adnanalbeda
adnanalbeda / .editorconfig
Last active May 19, 2023 15:43
Mono Repo Configs
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# based on many repos:
# https://github.com/editorconfig/editorconfig/blob/master/.editorconfig
[*]
charset = utf-8 # Set default charset
indent_style = space
import flattenColorPalette from "tailwindcss/lib/util/flattenColorPalette";
import plugin from "tailwindcss/plugin";
const scrollGradientPlugin = plugin(
({ addUtilities, theme, e, matchUtilities }) => {
addUtilities({
".scroll-gradient-y": {
/* variants */
/* size */
"--tw-scroll-gradient-size": "8px",
@adnanalbeda
adnanalbeda / multiDialog.tsx
Last active March 13, 2025 10:23
React-RadixUI
import {
Children,
cloneElement,
createContext,
useCallback,
useContext,
useMemo,
useState,
} from "react";
import { Slot, SlotProps } from "@radix-ui/react-slot";