Skip to content

Instantly share code, notes, and snippets.

View araffin's full-sized avatar

Antonin RAFFIN araffin

View GitHub Profile
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from gymnasium import spaces
from stable_baselines3 import PPO
from stable_baselines3.common.env_util import make_vec_env
from stable_baselines3.common.vec_env import VecEnvWrapper
sns.set_theme()
@karpathy
karpathy / add_to_zshrc.sh
Created August 25, 2024 20:43
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@jeremystretch
jeremystretch / github_notifications_fix.md
Created June 12, 2024 14:11
Mark GitHub notifications as read

I've needed to do this several times to combat "ghost" notifications. These occur when a discussion is created and then deleted (e.g. for spam) before the notofication is read. You may see something like "1-0 of 4" at the bottom of the notifications page.

You can use the GitHub API client to show these notifications:

gh api notifications

To mark all notifications as read, send the API request below with curl. (Update the last_read date as needed.)

@araffin
araffin / halfcheetah_minimal.py
Last active September 2, 2025 13:09
Minimal implementation to solve the HalfCheetah env using open-loop oscillators
# MIT License Copyright (c) 2024 Antonin Raffin
import gymnasium as gym
import numpy as np
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv
# Env initialization
env = gym.make("HalfCheetah-v4", render_mode="human")
# Wrap to have reward statistics
env = gym.wrappers.RecordEpisodeStatistics(env)
mujoco_env = env.unwrapped
import gymnasium as gym
import numpy as np
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv
# Env initialization
env = gym.make("Swimmer-v4", render_mode="human")
# Wrap to have reward statistics
env = gym.wrappers.RecordEpisodeStatistics(env)
mujoco_env = env.unwrapped
n_joints = 2
@nmwsharp
nmwsharp / printarr
Last active October 7, 2025 13:57
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc. --- now on pip: `pip install arrgh`
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc.
Now on pip! `pip install arrgh` https://github.com/nmwsharp/arrgh
import urllib.request
from datetime import datetime
import wandb
import yaml
from yaml.loader import SafeLoader
atari_ids = [
# "AdventureNoFrameskip-v4",
# "AirRaidNoFrameskip-v4",
@janert
janert / running-gui-application-docker.md
Created October 12, 2022 00:27
Running GUI Applications in a Docker Container

Running GUI Applications in a Docker Container

Containers are not usually associated with GUI applications, but there may be times when one might still want to run such a program inside a container, for example to isolate the application's dependencies. Installing a GUI application in a container means that not only the application, but also all its specific dependencies are encapsulated inside the container (respectively, the container image), and can therefore reliably be removed from the system in a single step.

The primary challenge is to let a container communicate with the host's display system, so that it can create GUI windows on the host. A GUI application will likely also need to share files with the host system, which in turn requires the appropriate user permissions.

In this example, I will use the pinta paint program, which requires the Mono runtime. I do not use any other programs that depend on Mono, and as I like to keep my system installation re

@ppoffice
ppoffice / xstartup
Last active October 27, 2025 16:41
VNC xstartup for Ubuntu Desktop (Gnome)
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
export DESKTOP_SESSION=/usr/share/xsessions/ubuntu.desktop
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
dbus-launch --exit-with-session /usr/bin/gnome-session --systemd --session=ubuntu
@Starbuck5
Starbuck5 / ascii_video_player.py
Created April 10, 2022 10:03
ASCII Video Player
import cv2
import pygame
import numpy
import functools
# WHAT IS THIS?
# This script is a simple ascii video player made in Python / pygame
# It allows you to drop in videos, or to use the webcam
pygame.init()