Skip to content

Instantly share code, notes, and snippets.

View ekzhang's full-sized avatar

Eric Zhang ekzhang

View GitHub Profile
@ekzhang
ekzhang / posix_psutil_net.py
Created February 14, 2024 23:34
Standalone net_connections() function from psutil for POSIX
"""This is a vendored copy of parts of the 'psutil' Python package.
It only contains what's needed to run the `net_connections()` function, which
lists active network connections from all processes on the system.
"""
import base64
from collections import defaultdict, namedtuple
import errno
@ekzhang
ekzhang / plasmid_data.py
Created November 19, 2023 17:34
Fast API for plasmid data from PLSDB
import json
import subprocess
import numpy as np
import pandas as pd
from fastapi import HTTPException
from modal import Image, Stub, web_endpoint
stub = Stub("plasmid-data")
@ekzhang
ekzhang / Buildcarte.ipynb
Last active March 29, 2024 16:02
Build Systems à la Carte — Python edition
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ekzhang
ekzhang / block_event_loop.py
Created August 16, 2023 17:24
Demo of yield-dependent behavior when a coroutine blocks the event loop.
# Demo of yield-dependent behavior when a coroutine blocks the event loop.
#
# Vary the number of calls to asyncio.sleep(0.0) in either block, and behavior will change greatly.
#
# (4 in top block, 9 in bottom block)
# 0 3.0027458667755127
# 1 2.0022785663604736
# 2 8.320808410644531e-05
# 3 4.38690185546875e-05
# 4 3.838539123535156e-05
@ekzhang
ekzhang / go.mod
Created August 15, 2023 20:44
package r2test for baseline latency
module r2test
go 1.20
require (
github.com/aws/aws-sdk-go-v2 v1.20.1
github.com/aws/aws-sdk-go-v2/config v1.18.33
github.com/aws/aws-sdk-go-v2/credentials v1.13.32
github.com/aws/aws-sdk-go-v2/service/s3 v1.38.2
)
@ekzhang
ekzhang / gened.ipynb
Created July 20, 2023 22:41
Manually adding a bunch of GENED data to the AY 2023 classes.wtf dataset
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ekzhang
ekzhang / Buck2 Notes.md
Last active February 27, 2024 07:14
stumbling through buck2

Eric's Notes: Stumbling through Buck2

I tried to use Buck2 today, inspired by a tweet by @dtolnay.

I've never been especially fond of build systems. I've only written a couple Bazel files following patterns, and only used them if I absolutely had to. It was kind of a necessary but annoying incantation. But I have noticed some discomfort in the past with this, especially with larger and multi-language projects. I'm imagining that fancy build systems may help:

  • speed up builds (reduce redundant and slow steps)
  • make environments easier to reproduce (less “it works on my machine!”)
  • standardize processes across a company (less language-specific tools)
@ekzhang
ekzhang / matmul2.cu
Created April 30, 2023 20:24
Code from HSRG on matrix multiplication perf optimization — both are still incomplete
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_ERR 1e-4
#define CEIL_DIV(x, y) ((x) + (y) - 1) / (y)
#define checkCudaErrors(call) \
do { \
cudaError_t err = call; \
echo '* soft nofile 1048576' | sudo tee -a /etc/security/limits.conf
echo '* hard nofile 1048576' | sudo tee -a /etc/security/limits.conf
echo 'root soft nofile 1048576' | sudo tee -a /etc/security/limits.conf
echo 'root hard nofile 1048576' | sudo tee -a /etc/security/limits.conf
echo 'session required pam_limits.so' | sudo tee -a /etc/pam.d/common-session
echo 'DefaultLimitNOFILE=1048576:1048576' | sudo tee -a /etc/systemd/system.conf
@ekzhang
ekzhang / README.md
Last active January 29, 2024 22:44
Python runtime library bindings for Maelstrom (https://github.com/jepsen-io/maelstrom), starter files used by Harvard Systems Reading Group — This library has been merged upstream

Gossip Glomers

Welcome! You can create your first file with the following command:

cp echo.py YOURNAME-echo.py

Then run the simulator environment with: