Skip to content

Instantly share code, notes, and snippets.

View binlf's full-sized avatar
🗑️
NaNi?

0xbin binlf

🗑️
NaNi?
View GitHub Profile
@perfectbase
perfectbase / await.tsx
Last active April 16, 2025 05:02
Await component for Next.js
import { Fragment, Suspense, type ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
type AwaitProps<T> =
| {
promise: Promise<T>;
children: (data: T) => ReactNode;
fallback?: ReactNode;
errorComponent?: ReactNode | null;
}
@t3dotgg
t3dotgg / try-catch.ts
Last active April 16, 2025 02:23
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@faustinoaq
faustinoaq / myAngular.html
Last active March 28, 2025 22:30
Front-end libraries (React, Vue, Angular) and the basic principles of how they work, all in a single file using pure JavaScript (VanillaJS).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Angular from Scratch</title>
<style>
.my-component {
font-family: Arial, sans-serif;
"use client";
import React, { useEffect, useId, useState } from "react";
import { motion, AnimatePresence, MotionConfig } from "framer-motion";
import { PlusIcon, XIcon } from "lucide-react";
import { createPortal } from "react-dom";
import { cn } from "@/lib/utils";
import { buttonVariants } from "../button";
const transition = {
import {
MotionValue,
useAnimationFrame,
useMotionValue,
} from "framer-motion";
import React from "react";
export interface Clock {
value: MotionValue<number>;
setRate: (rate: number) => void;
@adrianhajdin
adrianhajdin / App.scss
Last active November 10, 2024 20:19
Build and Deploy the Ultimate Web Development Portfolio
.app {
background-color: var(--primary-color);
font-family: var(--font-base);
}
.app__whitebg {
background-color: var(--white-color);
}
.app__primarybg {
@tonibardina
tonibardina / std.md
Created December 16, 2020 09:24 — forked from turbo/std.md
Git Commit Message Standard

Merged from https://github.com/joelparkerhenderson/git_commit_message and https://chris.beams.io/posts/git-commit/

General Rules

  • Commit messages must have a subject line and may have body copy. These must be separated by a blank line.
  • The subject line must not exceed 50 characters
  • The subject line should be capitalized and must not end in a period
  • The subject line must be written in imperative mood (Fix, not Fixed / Fixes etc.)
  • The body copy must be wrapped at 72 columns
  • The body copy must only contain explanations as to what and why, never how. The latter belongs in documentation and implementation.
@JLarky
JLarky / README.md
Last active October 29, 2024 14:16
Ultimate example of react context hook with nice type-safe (TypeScript) wrappers and reduced boilerplate by using `ReturnType`
@Zekfad
Zekfad / conventional-commits.md
Last active April 12, 2025 14:12
Conventional Commits Cheatsheet

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
@bradtraversy
bradtraversy / vscode_shortcuts.md
Last active March 19, 2025 14:37
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands