Skip to content

Instantly share code, notes, and snippets.

@ultranity
ultranity / snippets.ahk
Created April 30, 2018 12:39
[AHK snippets]AutoHotKey_L(1.1) #AutoHotKey
if not A_IsAdmin ;running by administrator
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
@ultranity
ultranity / Slurm-sbatch-email-with-output.sh
Created August 9, 2022 14:24
Slurm-sbatch-email-with-output
#!/bin/bash
#SBATCH -J MyModel
#SBATCH -n 1 # Number of cores
#SBATCH -t 1-00:00 # Runtime in D-HH:MM
#SBATCH -o JOB%j.out # File to which STDOUT will be written
#SBATCH -e JOB%j.out # File to which STDERR will be written
#SBATCH --mail-type=BEGIN
#SBATCH --mail-user=my@email.com
secs_to_human(){
@ultranity
ultranity / pad2shape.py
Created November 16, 2022 14:56
pytorch pad tensor to target shape
def pad(x:torch.Tensor, shape:torch.Size, mode='right with zero'):
p = [0]*len(shape)*2
for i, s in enumerate(shape):
p[2*(len(shape)-1-i)+1] = s - x.size(i)
return torch.nn.functional.pad(x, p)