Skip to content

Instantly share code, notes, and snippets.

View h3ct0r's full-sized avatar
☢️
Quarantine

Héctor Azpúrua h3ct0r

☢️
Quarantine
View GitHub Profile
@h3ct0r
h3ct0r / microgpt.py
Created February 11, 2026 21:33 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT LLM in pure, dependency-free Python.
Differences from GPT-2 are minor: rmsnorm instead of layer norm, no biases, square ReLU instead of GeLU nonlinearity.
The contents of this file is everything algorithmically needed to train a GPT. Everything else is just efficiency.
Art project by @karpathy.
"""
import os # for os.path.exists
import math # for math.log, math.exp
import random # for random.seed, random.choices
@h3ct0r
h3ct0r / query_gpu_usage_ssh.bash
Created July 2, 2021 17:26
Query GPU usage (with nvdia-smi) on a list of servers via SSH. It ask for password for all machines and store it on a variable which is cleared after the script is finished (no password is kept in the bash logs).
read -p "User please: " -s USER && read -p "Password please: " -s PASS && echo -e "\nBeginning SSH query with user: $USER\n" && for host in '150.164.212.21' '150.164.212.23' '150.164.212.24' '150.164.212.25' '150.164.212.26' '150.164.212.27' '150.164.212.28' '150.164.212.33' '150.164.212.36' '150.164.212.37' '150.164.212.40' '150.164.212.42' '150.164.212.43' '150.164.212.45' '150.164.212.71' '150.164.212.72' '150.164.212.73' '150.164.212.75' '150.164.212.76' '150.164.212.80' '150.164.212.81' '150.164.212.117' '150.164.212.141' '150.164.212.148' '150.164.212.164' '150.164.212.171' '150.164.212.204' '150.164.212.226'; do sshpass -p $PASS ssh -oStrictHostKeyChecking=no $USER@$host 'echo "host:$(hostname) GPU usage: $(nvidia-smi --query-gpu=utilization.gpu,memory.free,memory.total --format=csv,noheader)"' 2> /dev/null; done && PASS="" && USER=""
@h3ct0r
h3ct0r / COPPELIA_4.1.0_UBUNTU_16.04.md
Created March 22, 2021 19:54
How to Install CoppeliaSim 4.1.0 in Ubuntu 16.04 with ROS Bridge and the Velodyne plugin

How to Install CoppeliaSim 4.1.0 in Ubuntu 16.04 with ROS Bridge and the Velodyne plugin

Install Tutorial Coppeliasim - Espeleo Simulation

@h3ct0r
h3ct0r / .block
Created June 5, 2019 01:12 — forked from mapio/.block
Force-based label placement (d3.v5.js)
license: gpl-3.0
height: 600
@h3ct0r
h3ct0r / hold_current_kernel_ubuntu_16.04.sh
Created June 4, 2019 15:19
Mark the kernel as hold so its never updated. Useful for cases where a kernel upgrade breaks your cuda/nvidia/etc environment.
echo linux-image-generic hold | sudo dpkg --set-selections
dpkg -l linux-image-generic
echo linux-headers-generic hold | sudo dpkg --set-selections
dpkg -l linux-headers-generic
sudo apt update
apt-mark showhold
@h3ct0r
h3ct0r / python_keyboard_release.py
Created February 27, 2019 16:42
Python keyboard bindings with "key release"
#!/usr/bin/env python
import sys, select, termios, tty
def getKey():
tty.setraw(sys.stdin.fileno())
rfds, wfds, efds = select.select([sys.stdin], [], [], 0.3)
print(rfds, wfds, efds)
if len(rfds) > 0 or len(wfds) > 0 or len(efds) > 0:
key = sys.stdin.read(1)
@h3ct0r
h3ct0r / spotify_keybindings
Created June 29, 2018 15:12 — forked from jbonney/spotify_keybindings
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
@h3ct0r
h3ct0r / test_bad_nodes_network.py
Last active February 24, 2018 21:02
Check for 'bad' or 'slow' nodes on paths using a metric for every path. Python + networkx.
import networkx as nx
import matplotlib.pyplot as plt
import random
import numpy as np
def outliers_modified_z_score(ys):
threshold = 1.5
median_y = np.median(ys)
@h3ct0r
h3ct0r / python_node_link_counter.py
Created February 9, 2018 17:05
Python node link analyser
@h3ct0r
h3ct0r / recall_precision_ap.py
Created November 22, 2017 00:36
Calculate recall and precision of a hit/miss query
def calc_precision(rel):
"""
return the precision from a series of hit or miss data
"""
p = []
hit = 0
for i in xrange(len(rel)):
if rel[i] > 0:
hit += 1