Skip to content

Instantly share code, notes, and snippets.

View abodacs's full-sized avatar

Abdullah Mohammed abodacs

View GitHub Profile
@KristofferEriksson
KristofferEriksson / useDynamicTextareaSize.ts
Last active April 9, 2024 10:49
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>,
@s-casci
s-casci / shakespeare_gpt.py
Last active February 5, 2024 17:43
Train a GPT to write like Shakespeare
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim import AdamW
from torch.optim.lr_scheduler import LinearLR
from typing import List, Tuple
import subprocess
# Download "40,000 lines of Shakespeare from a variety of Shakespeare's plays"
subprocess.run(
@SandroMaglione
SandroMaglione / machine.ts
Created January 3, 2024 18:39
Setup code for an empty state machine in XState v5
import { setup } from "xstate";
const machine = setup({
types: {
context: {} as {},
events: {} as { readonly type: "event"; readonly params: {} },
},
actions: {},
}).createMachine({
id: "machine",
@masta-g3
masta-g3 / notes
Last active February 7, 2024 17:12
summary notes and more
import time
import json
from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage
from pydantic import BaseModel, ValidationError, ConfigDict
from typing import Type, Optional
import os
from dotenv import load_dotenv
load_dotenv()
# you can download the CSV from https://wandb.ai/costa-huang/tldr_summarize/runs/gb2dian5
import random
from openai import AsyncOpenAI
import pandas as pd
import asyncio
# client = OpenAI()
async_client = AsyncOpenAI()
@khalidx
khalidx / startup-success.md
Last active February 6, 2024 11:48
A distilled summary of Sam Altman's "How to Succeed with a Startup".

Sam Altman - How to Succeed with a Startup

Watch the full Y Combinator talk on YouTube from Aug 29, 2018 here: https://youtu.be/0lJKucu6HJc

Summary

  1. Build a product so good, people spontaneously tell their friends about it.
  2. Build a product that is easy to explain in a few words.
  3. Identify a market that is going to grow every year.
  4. A real trend is one where the early adopters use it obsessively.
@geohot
geohot / memcpy.py
Created November 21, 2023 19:21
Fast memcpy using GPUs
# tiny@tiny9:~/tinygrad$ python3 examples/benchmark_copies.py
# CPU copy 6.18 ms, 16.28 GB/s
# GPU copy 4.38 ms, 23.00 GB/s
# GPU 6x 1.85 ms, 54.54 GB/s
import time
def timeit(fxn):
tms = []
for _ in range(10):
st = time.perf_counter()
"use client";
import {
Dialog,
DialogContent,
DialogTitle,
DialogTrigger
} from "@/components/ui/dialog";
import useDragDrop from "@/hooks/useDragDrop";
import { cn, formatBytes } from "@/lib/utils";
@ceberly
ceberly / Makefile
Last active November 13, 2023 17:31
Row vs. Column access patterns
default:
gcc -O0 -g3 -Wall -Wextra -Wconversion -Wdouble-promotion \
-Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion \
main.c
format:
clang-format -i main.c