Skip to content

Instantly share code, notes, and snippets.

View rhaps0dy's full-sized avatar
💭
solving AI alignment

Adrià Garriga-Alonso rhaps0dy

💭
solving AI alignment
View GitHub Profile
@rhaps0dy
rhaps0dy / analyze.py
Created November 11, 2025 06:44
Analyze CVE data
import json
from pathlib import Path
cves_dir = Path('cves/2025')
severity_count = {'CRITICAL': 0, 'HIGH': 0, 'MEDIUM': 0, 'LOW': 0, 'UNKNOWN': 0}
total = 0
for json_file in cves_dir.rglob('*.json'):
total += 1
try:
import math
import numpy as np
def logsumexp(a, b):
"""Stable log(exp(a) + exp(b))"""
m = np.maximum(a, b)
return m + np.log(np.exp(a - m) + np.exp(b - m))
@rhaps0dy
rhaps0dy / latexsub.el
Created October 12, 2020 14:58
LaTeX -> unicode substitution as used in Julia
;;; packages.el --- latexsub layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Adrià Garriga Alonso <adria@k9>
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
@rhaps0dy
rhaps0dy / natural_variational_distribution.py
Created July 9, 2020 20:12
Natural variational distribution + tests
#!/usr/bin/env python3
import abc
import torch
from gpytorch.distributions import MultivariateNormal
from gpytorch.lazy import CholLazyTensor
from gpytorch.variational._variational_distribution import \
_VariationalDistribution
@rhaps0dy
rhaps0dy / a.txt
Created February 2, 2018 12:45
Images for Spacemacs issue
fdsf
@rhaps0dy
rhaps0dy / cartpole.xml
Created December 23, 2017 08:13
Bullet CartPole simulation files
<mujoco model="inverted pendulum">
<compiler inertiafromgeom="true"/>
<default>
<joint pos="0 0 0" armature="0" damping="0" frictionloss="0" limited="true"/>
<geom pos="0 0 0" contype="0" conaffinity="0" friction="0 0 0"
rgba="0.7 0.7 0 1"/>
<tendon/>
<motor ctrlrange="-1 1" ctrllimited="true"/>
</default>
<option gravity="0 0 -9.81" integrator="RK4" timestep="0.02"/>
@rhaps0dy
rhaps0dy / howto.md
Last active December 11, 2016 12:43
Vote for a charity in Project Awesome

#How to use this?

  1. Go to a charity's page, such as the AMF or the GFI.

  2. Click. one of the videos and vote, normally. This is so you complete the captcha thing.

  3. Go back to the charity page.

  4. Open the browser console.

@rhaps0dy
rhaps0dy / quine.c
Created December 17, 2015 00:23
Quine in C
#include<stdio.h>
void f(char*b){while(*b){if(*b=='"'||*b=='\\')putchar('\\');if(*b=='\n') printf("\\n"),b++; else putchar(*b++);}}
void g(char *c){printf("%s", c); putchar('"'); f(c); printf("\");}\n");}
int main(){g("#include<stdio.h>\nvoid f(char*b){while(*b){if(*b=='\"'||*b=='\\\\')putchar('\\\\');if(*b=='\\n') printf(\"\\\\n\"),b++; else putchar(*b++);}}\nvoid g(char *c){printf(\"%s\", c); putchar('\"'); f(c); printf(\"\\\");}\\n\");}\nint main(){g(");}
@rhaps0dy
rhaps0dy / char-rnn-tf.py
Created November 21, 2015 18:37
NaNoGenMo character-based RNN, based on Karpathy's blog and code.
#!/usr/bin/env python2
import tensorflow as tf
import numpy as np
import time
# Hyperparameters
learning_rate = 1e-1
n_hidden = 100
seq_length = 25
n_show = 2500 // seq_length
(setv test
(let [[a 5]
[b 7]]
(print a b)))
(print (type test))