Skip to content

Instantly share code, notes, and snippets.

Connect via SSH to a Slurm compute job that runs as Enroot container

Being able to SSH directly into a compute job has the advantage of using all remote development tools such as using your IDE's debugger also for GPU jobs (VSCode, PyCharm, ...).

  • Slurm: Scheduling system that many HPC clusters use
  • Enroot: Container system like Docker for NVIDIA GPUs

General problem:

@leonletto
leonletto / 001-README.md
Created December 9, 2022 18:40 — forked from leandronsp/001-README.md
OOP in Bash script

OOP in Bash script

Wait, what?

Inspired by this awesome article.

Prelude about OOP

According to wikipedia, OOP is a programming paradigm or technique based on the concept of "objects". The object structure contain data and behaviour.

Data is the object's state, which should be isolated and must be private.

@leonletto
leonletto / ca-setup.md
Created November 11, 2022 20:45 — forked from nebulak/ca-setup.md
python mutual tls for client certificate validation
# sources:
# https://kb.op5.com/pages/viewpage.action?pageId=19073746#sthash.9gTMRKM1.dpbs
# https://stackoverflow.com/a/26093147
# https://jamielinux.com/docs/openssl-certificate-authority/sign-server-and-client-certificates.html
# additional ressource: https://gist.github.com/Soarez/9688998
# TODO: renew certificates and ca, add capability for authentication to client cert
# TODO ressources: https://gist.github.com/richieforeman/3166387

HKP_PATH=""

@leonletto
leonletto / gist:2d1d9dcd08b0b8de1104a1882f6a465a
Created October 30, 2022 18:56 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@leonletto
leonletto / stop-using-jwts.md
Created November 10, 2021 19:11 — forked from samsch/stop-using-jwts.md
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
@leonletto
leonletto / chatServer.js
Created August 24, 2016 22:37 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client

Keybase proof

I hereby claim:

  • I am leonletto on github.
  • I am leonletto (https://keybase.io/leonletto) on keybase.
  • I have a public key whose fingerprint is 5B6A CBD5 95EB 08C8 0962 8771 3CAB DA24 75AC 8597

To claim this, I am signing this object:

@leonletto
leonletto / powershell-web-server.ps1
Last active March 5, 2018 13:37 — forked from 19WAS85/powershell-web-server.ps1
Simple Windows WebServer for testing that ports are working
### Basic webserver to check ports are available
##
## copy into a directory - for example c:\test
## open a command prompt and cd into that directory
## run 'powershell' - enter
##
## the first time you run powershell you will need to allow scripts to run
## to do this type 'Set-ExecutionPolicy UnRestricted' - enter
##
## Now type '.\powershell-web-server.ps1 2010' - enter