Skip to content

Instantly share code, notes, and snippets.

View Nusab19's full-sized avatar
😪
Bored

Nusab Taha Nusab19

😪
Bored
View GitHub Profile
@Nusab19
Nusab19 / textarea.tsx
Created February 1, 2025 20:48
Auto-growing Textarea of ShadCN
import * as React from "react";
import { cn } from "@/lib/utils";
const Textarea = React.forwardRef<
HTMLTextAreaElement,
React.ComponentProps<"textarea">
>(({ className, ...props }, ref) => {
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null);
const calculateHeight = React.useCallback(() => {
@GaspardP
GaspardP / sha256.js
Created June 4, 2015 15:21
SHA-256 with Javascript and Web Crypto
// Computes the SHA-256 digest of a string with Web Crypto
// Source: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
function sha256(str) {
// Get the string as arraybuffer.
var buffer = new TextEncoder("utf-8").encode(str)
return crypto.subtle.digest("SHA-256", buffer).then(function(hash) {
return hex(hash)
})
}