Skip to content

Instantly share code, notes, and snippets.

View jmcph4's full-sized avatar

Jack McPherson jmcph4

View GitHub Profile
def ask_question(question, choices=None):
print(question)
if choices:
for i, choice in enumerate(choices, 1):
print(f"{i}. {choice}")
answer = input("Choose a number: ")
return choices[int(answer) - 1] if answer.isdigit() and 1 <= int(answer) <= len(choices) else None
else:
return input("Your answer: ")
digraph TensorFlow {
Tensor [shape = "rect"]
LazyBuffer [shape = "rect"]
LazyOp [shape = "rect"]
UOp [shape = "rect"]
Code [shape = "rect"]
"<computation>"
Tensor -> LazyBuffer [label = "Forward and backward passes occur here (`tinygrad/function.py`)"];
LazyBuffer -> LazyOp [label = "Breaking into kernels occurs here (`tinygrad/engine/schedule.py`)"];
import requests
from datetime import datetime
def get_contributions(username, start_date, end_date):
url = f'https://api.github.com/users/{username}/events'
start_date, end_date = map(lambda x: datetime.strptime(x, "%Y-%m-%d"), [start_date, end_date])
total_contributions = 0
page = 1
while True:
/* $ gcc tree.c -Wall -Wextra -Wshadow -std=c11 -pedantic -o tree */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
struct Vertex {
uint8_t data;
struct Vertex* left;
struct Vertex* right;

System Information

Version: 8ad7d05

$ uname -a
Linux [REDACTED] 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux
$ reth --version
reth Version: 1.1.0
Commit SHA: 1ba631ba9581973e7c6cadeea92cfe1802aceb4a
Build Timestamp: 2024-10-10T18:21:22.096485546Z
[package]
name = "checkpoint"
version = "0.1.0"
edition = "2021"
[dependencies]
alloy = { version = "0.6", features = ["full"] }
amms = { git = "https://github.com/darkforestry/amms-rs.git", rev = "8ad7d05" }
eyre = "0.6.12"
tokio = { version = "1.42.0", features = ["full"] }
@jmcph4
jmcph4 / endian.c
Last active December 15, 2024 23:44
C program to determine the endianness of the host machine. It must print "B" or "L" to standard output if the host machine is big or little endian, respectively.
#include <stdio.h>
int main(){unsigned int x=1;char*c=(char*)&x;*c?printf("B"):printf("L");}
fn r#match<'a>(
&mut self,
order: T,
opposing_side: impl Iterator<Item = (&'a F64, &'a mut VecDeque<T>)>,
) where
T: 'a,
{
let reduce_depth = |reduction| {
let curr_depth = *self.depth.read().unwrap();
match order.kind() {
@jmcph4
jmcph4 / pumpgrad.py
Created November 30, 2024 01:30
Retrieve upcoming Pump.fun graduations and write them to the standard output in a tabulated, human-readable format
from typing import List, Tuple
import requests
def get_graduations() -> List[Tuple[str, str, float]]:
url = "https://advanced-api.pump.fun/coins/about-to-graduate"
resp = requests.get(url)
if resp.status_code == 200:
return [
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>