Skip to content

Instantly share code, notes, and snippets.

View bilalesi's full-sized avatar
🏠
Working from home

Bilal MEDDAH bilalesi

🏠
Working from home
View GitHub Profile
@bilalesi
bilalesi / pytry
Created November 19, 2024 10:53 — forked from miraculixx/pytry
try a python package in its own venv
#!/bin/bash
function setup() {
python -m venv .pytry
source .pytry/bin/activate
pip install $packages
}
function tryimport() {
toimport=$1
@bilalesi
bilalesi / building-sync-systems.md
Created October 30, 2024 20:14 — forked from pesterhazy/building-sync-systems.md
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@bilalesi
bilalesi / coverflow-animation.tsx
Created October 29, 2024 15:52 — forked from devalade/coverflow-animation.tsx
Coverflow animation
import { PropsWithChildren, useEffect, useState } from "react";
import { Container } from "~/components/container";
import { ArrowLeft, ArrowRight } from "lucide-react";
import { range } from "~/utils/range";
const IMAGES = [
{
id: 1,
url: "https://images.pexels.com/photos/1366919/pexels-photo-1366919.jpeg",
},
@bilalesi
bilalesi / invoice.ts
Created October 25, 2024 14:49
midday invoice
import { Document, Font, Image, Page, Text, View } from "@react-pdf/renderer";
import QRCodeUtil from "qrcode";
import { EditorContent } from "../components/editor-content";
import { LineItems } from "../components/line-items";
import { Meta } from "../components/meta";
import { Note } from "../components/note";
import { PaymentDetails } from "../components/payment-details";
import { QRCode } from "../components/qr-code";
import { Summary } from "../components/summary";
@bilalesi
bilalesi / create_pr.sh
Created October 13, 2024 12:02 — forked from slavingia/create_pr.sh
Create a (draft) pull request using GitHub CLI
#!/bin/bash
# Create a (draft) pull request using GitHub CLI.
# It assigns the PR to the current user, fills in the title from the first commit,
# and uses the PR template file for the description.
set -euo pipefail
# Colors for output
RED='\033[0;31m'
@bilalesi
bilalesi / docker-compose.yml
Created October 2, 2024 08:58 — forked from seanhandley/docker-compose.yml
How To Set Up Docker For Mac (Mojave) with Native NFS
version: '2'
services:
api:
volumes:
- "nfsmount:${CONTAINER_DIR}"
volumes:
nfsmount:
driver: local
driver_opts:
"use strict";
import type { LexicalEditor, LexicalNode } from "Lexical";
import type { Binding, Provider } from "LexicalYjs";
import {
createBinding,
syncLexicalUpdateToYjs,
syncYjsChangesToLexical,
} from "LexicalYjs";
@bilalesi
bilalesi / useFetch.ts
Created February 11, 2024 18:18 — forked from KristofferEriksson/useFetch.ts
A generic React fetch hook for API calls with caching, error handling, and refetch capability
import { useCallback, useEffect, useState } from "react";
type FetchState<T> = {
data: T | null;
isLoading: boolean;
error: Error | null;
isCached: boolean;
refetch: () => void;
};
@bilalesi
bilalesi / useUndo.ts
Created February 11, 2024 18:18 — forked from KristofferEriksson/useUndo.ts
A React hook that enhances your components with powerful undo/redo functionality
import { useCallback, useEffect, useRef, useState } from "react";
interface UseUndoHook<T> {
value: T;
onChange: (newValue: T) => void;
undo: () => void;
redo: () => void;
clear: () => void;
canUndo: boolean;
canRedo: boolean;
@bilalesi
bilalesi / useDynamicTextareaSize.ts
Created February 11, 2024 18:17 — forked from KristofferEriksson/useDynamicTextareaSize.ts
A simple React hook to dynamically adjust the height of a textarea based on its content
/**
* Custom hook for dynamically resizing a textarea to fit its content.
* @param {React.RefObject<HTMLTextAreaElement>} textareaRef - Reference to the textarea element.
* @param {string} textContent - Current text content of the textarea.
* @param {number} maxHeight - Optional: maxHeight of the textarea in pixels.
*/
import { useEffect } from "react";
const useDynamicTextareaSize = (
textareaRef: React.RefObject<HTMLTextAreaElement>,