Skip to content

Instantly share code, notes, and snippets.

View adnanalbeda's full-sized avatar

Adnan AlBeda adnanalbeda

View GitHub Profile
@adnanalbeda
adnanalbeda / effect.ts
Last active January 28, 2025 10:05
reactivity-vanillaJS
import { SignalGet, SignalUnsubscribe } from "./signal";
export type EffectDepsValues<T extends SignalGet<unknown>[]> = {
[k in keyof T]: T[k] extends SignalGet<infer R> ? R : never;
};
export type EffectCallback<
T extends [SignalGet<unknown>, ...SignalGet<unknown>[]]
> = (values: EffectDepsValues<T>) => unknown;
export type EffectCleanup = { (): void; isExecuted(): boolean };
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Microsoft.EntityFrameworkCore;
public static partial class UuidConverterExtensions
{
private static Action<PropertiesConfigurationBuilder<Uuid>> defaultValueDelegate = (_) => { };
private static Action<PropertiesConfigurationBuilder<Uuid?>> defaultNullableValueDelegate = (
_
) => { };
@adnanalbeda
adnanalbeda / Exception.cs
Last active August 15, 2024 10:50
Google ReCaptcha V3 - ASP API - C#
namespace Google.ReCaptcha.V3;
public class CaptchaRequestException : Exception
{
public CaptchaRequestException()
{
}
public CaptchaRequestException(string message)
: base(message)
{
@adnanalbeda
adnanalbeda / README.md
Last active May 27, 2024 01:06
Zod Utils

Zod Utils

Zod is a great library for shaping and validating data. So away from the long introductory, it misses few feature.

People tried to fix its issues with extended libraries.

But since some are not maintained or didn't meet my criteria, here's my fine-tuned version of them.

@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";
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 / .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
@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 / 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 / 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(