Skip to content

Instantly share code, notes, and snippets.

View rehno-lindeque's full-sized avatar

Rehno Lindeque rehno-lindeque

View GitHub Profile
@rehno-lindeque
rehno-lindeque / LICENSE
Last active December 24, 2023 07:24
hsv_to_rgb from torchvision/transforms/v2/functional/_color.py
BSD 3-Clause License
Copyright (c) Soumith Chintala 2016,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@rehno-lindeque
rehno-lindeque / layers-cheatsheet.md
Last active February 1, 2024 19:50
Personal PyTorch Cheatsheet: Low effort from scratch layers

PyTorch Cheatsheet: Low effort from scratch layers

  • b: Batch size
  • i: Input features (Linear)
  • o: Output features
  • c_in: Input channels
  • c_out: Output channels
  • n: Input/output length (1D sequence, often number of tokens)
  • n_in: Input length (1D sequence)
  • n_out: Output length (1D sequence)
@rehno-lindeque
rehno-lindeque / lorentz-boost-anim.py
Last active September 11, 2023 18:51
Lorentz boost animation
# Import necessary libraries
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Define the SplitComplex class
class SplitComplex:
def __init__(self, real, j_component):
self.real = real
self.j_component = j_component
@rehno-lindeque
rehno-lindeque / flake.nix
Created January 6, 2022 18:57
Flake example
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs, flake-utils }:
let
inherit (nixpkgs) lib;
# Add the flake's overlay to each of the pkgs
@rehno-lindeque
rehno-lindeque / README.md
Last active August 23, 2019 20:13
jupyterwith-experimental-nixos-service
@rehno-lindeque
rehno-lindeque / me-keyboard-layout.nix
Last active March 16, 2019 00:42
My personal keyboard layout switcher: nix-env -iE "$(curl -sL https://git.io/fjvfP)"
#! /usr/bin/env -S nix-env -if
{ pkgs ? import <nixpkgs> {}, ... }:
let
norman-layout = pkgs.fetchurl {
url = "https://gist.githubusercontent.com/rehno-lindeque/ad5fef21f15ad13a9a355bbbd41fdc0a/raw/aa7948603ee266bd2a0bb6c9778ae7dd8bd1eccb/xmodmap.norman";
sha256 = "14a63as7i35g6gkf0sqb324ck9k61w1vsdnz30sf8svnp4c0wjgq";
};
in
{
@rehno-lindeque
rehno-lindeque / quick-ssh.nix
Last active February 27, 2019 17:58
Quickly enable ssh in nixos ( https://git.io/fhNKV )
{ ... }:
# Temporarily enable ssh
{
services = {
# Enable the OpenSSH daemon.
openssh = {
enable = true;
# Use for initial login
@rehno-lindeque
rehno-lindeque / xmodmap.norman
Last active September 30, 2018 04:02
Personalised xmodmap for Norman keyboard layout
! My personalized version of the xmodmap for the Norman layout.
! http://normanlayout.info
! Originally from https://github.com/deekayen/norman
keycode 49 = grave asciitilde dead_tilde asciitilde
keycode 10 = 1 exclam exclamdown onesuperior
keycode 11 = 2 at masculine twosuperior
keycode 12 = 3 numbersign ordfeminine threesuperior
keycode 13 = 4 dollar cent sterling
keycode 14 = 5 percent EuroSign yen
@rehno-lindeque
rehno-lindeque / mask-freet.hs
Last active June 23, 2018 23:08
FreeT MonadMask experimentation
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [ text free exceptions_0_10_0 ])"
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixpkgs-unstable.tar.gz
-- #! nix-shell -i runghc -p haskellPackages.text haskellPackages.free "haskellPackages.callHackage ''exceptions'' ''0.10.0'' {}"
{-# language DeriveFunctor, FlexibleInstances #-}
-- | Historical background reading for this experiment (in historical order):
--
-- * https://stackoverflow.com/questions/41966893/why-is-there-no-monadmask-instance-for-exceptt
@rehno-lindeque
rehno-lindeque / deferred-build-experiment.nix
Last active June 3, 2018 13:15
Experimenting with deferred builds in nix
let
makeDeferredBuildService = package:
let
drvPath = builtins.unsafeDiscardOutputDependency package.drvPath;
outPath = builtins.unsafeDiscardStringContext package.outPath;
drvName = package.name;
gcrootDir = "/nix/var/nix/gcroots/deferred-builds";
deferredBuildScript =
with pkgs;