Skip to content

Instantly share code, notes, and snippets.

View leimao's full-sized avatar
🦉
Hello Underworld. Hello 人工稚能.

Lei Mao leimao

🦉
Hello Underworld. Hello 人工稚能.
View GitHub Profile
@leimao
leimao / get_compute_capability.py
Created January 2, 2025 17:17
GPU Compute Capability Scraper
from bs4 import BeautifulSoup
import requests
def get_gpu_info(url):
"""Parses the given URL and extracts GPU, compute capability, and category information."""
try:
response = requests.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.content, 'html.parser')
@leimao
leimao / tqdm_download.py
Created June 12, 2018 03:41
Tqdm Download Example
"""
Tqdm Download Hook
Lei Mao
University of Chicago
Modified from https://github.com/tqdm/tqdm/blob/master/examples/tqdm_wget.py
"""
import os
@leimao
leimao / ClearInputBuff.cpp
Created December 30, 2019 07:44 — forked from manadream/ClearInputBuff.cpp
Clearing input buffer in C++ completely
#include <iostream>
#include <limits>
using namespace std;
int main(){
char var[10];
bool valid = false;
while(!valid){
cout << "Enter a string 9 characters long: ";
@leimao
leimao / GitHub-Forking.md
Created April 30, 2019 20:30 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@leimao
leimao / mm.cu
Last active October 25, 2023 04:25
Matrix Multiplication and Batched Matrix Multiplication Implementations Using C++ and CUDA.
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <random>
#include <stdexcept>
#include <vector>
#define BLOCK_DIM 32
@leimao
leimao / graph.py
Last active December 15, 2022 09:15
Graph Traversal
from typing import Iterable, List, Union, Set
class Graph:
def __init__(self) -> None:
# Adjacency set representation.
# key: node name, value: adjacency node name set.
self.edges = dict()
@leimao
leimao / jpeg2pdf.sh
Last active November 20, 2022 13:57
JPEG to PDF Conversion
# MIT License
# Copyright (c) 2021 Lei Mao <https://leimao.github.io/>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@leimao
leimao / chat_client.py
Created August 30, 2020 19:57
EdgeDB AsyncIO Tutorial ChatBot: https://youtu.be/SyiTd4rLb2s
from __future__ import annotations
from typing import IO
import asyncio
import sys
import contextlib
import aiofiles.threadpool
from chat_streams import split_lines, write, handle_writes
async def handle_reads(reader: asyncio.StreamReader) -> None:
@leimao
leimao / extract_ILSVRC.sh
Last active July 8, 2021 17:50 — forked from BIGBALLON/extract_ILSVRC.sh
script for ImageNet data extract.
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
This file has been truncated, but you can view the full file.
mkdir -p n01440764
mkdir -p n01443537
mkdir -p n01484850
mkdir -p n01491361
mkdir -p n01494475
mkdir -p n01496331
mkdir -p n01498041
mkdir -p n01514668
mkdir -p n01514859
mkdir -p n01518878