Skip to content

Instantly share code, notes, and snippets.

View ehzawad's full-sized avatar
🎃
Wasteland Baby!

ehzawad ehzawad

🎃
Wasteland Baby!
View GitHub Profile
# PyTorch 2.x; Apple Silicon; runs on MPS if available, else CPU.
import math
import torch
if torch.backends.mps.is_available(): # official API to detect MPS
device = torch.device("mps")
else:
device = torch.device("cpu")
# --- Quantization helpers (per-tensor, symmetric) ---
import React, { useMemo, useRef, useState, useEffect } from "react";
// Simple FAISS-like toy: IndexFlatL2
class IndexFlatL2 {
constructor(d) {
this.d = d; // dimensionality
this.vectors = []; // each item: {id, x: number[], label?: string}
this._nextId = 1;
}
add(vecs) {

Looking at your GeForce RTX 2050 laptop GPU, here's what I recommend:

Best Driver Options for RTX 2050 Laptop:

1. nvidia-driver-575-open (RECOMMENDED)

  • Version: 575.64.03
  • Why: Ubuntu specifically recommends this for your RTX 2050
  • Benefits for laptops: the driver also added NVIDIA Dynamic Boost support for Linux notebooks running on battery power
  • CUDA: Fully compatible with CUDA 12.9
#!/usr/bin/env python3
"""
Run GPT-OSS using the Metal implementation for Apple Silicon
This requires downloading and converting the model first.
"""
import os
import subprocess
import sys
// file: vecadd_test.cu
#include <cstdio>
#include <cstdlib>
#define CUDA_CHECK(call) do { \
cudaError_t err = call; \
if (err != cudaSuccess) { \
fprintf(stderr, "CUDA error %s:%d: %s\n", \
__FILE__, __LINE__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
import re
from typing import Any, Text, Dict, List
bn_num_string = [
'শূন্য', 'এক', 'দুই', 'তিন', 'চার', 'পাঁচ', 'ছয়', 'সাত', 'আট', 'নয়', 'দশ', 'এগারো', 'বারো', \
'তেরো', 'চৌদ্দ', 'পনেরো', 'ষোলো', 'সতেরো', 'আঠারো', 'উনিশ','বিশ','একুশ', 'বাইশ', 'তেইশ', 'চব্বিশ', 'পঁচিশ', 'ছাব্বিশ', \
'সাতাশ', 'আঠাশ', 'উনোতিরিশ', 'তিরিশ', 'একতিরিশ', 'বতিরিশ', 'তেতিরিশ', 'চৌতিরিশ', 'পঁয়তিরিশ', 'ছতিরিশ', 'সাঁইতিরিশ', 'আটতিরিশ', 'উনোচল্লিশ',\
'চল্লিশ','একচল্লিশ', 'বিয়াল্লিশ', 'তেতাল্লিশ', 'চুয়াল্লিশ', 'পঁয়তাল্লিশ', 'ছেচল্লিশ', 'সাতচল্লিশ', 'আটচল্লিশ', 'উনোপঞ্চাশ', 'পঞ্চাশ', 'একান্ন',\
'বাহান্ন', 'তিপ্পান্ন', 'চুয়ান্ন', 'পঞ্চান্ন', 'ছাপ্পান্ন', 'সাতান্ন', 'আটান্ন', 'উনোষাট','ষাট','একষট্টি', 'বাষট্টি', 'তেষট্টি', 'চৌষট্টি', 'পঁয়ষট্টি', \

---- resume-to-JSON prompt ----

parser_prompt = f""" You are an intelligent resume parser for the HR department. Read the raw CV text delimited by <<< and >>>, then return a single valid JSON object—no markdown, no commentary.

<<< {text}

Schema to follow exactly:

@ehzawad
ehzawad / lecun.py
Created June 14, 2025 19:33
LeCun neural network implementation
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.utils.data import random_split, DataLoader
from multiprocessing import freeze_support
def main():
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m'
get_size() {