Skip to content

Instantly share code, notes, and snippets.

@gngdb
gngdb / tpu_configssh.py
Last active October 11, 2022 19:23
Script to do the same thing as https://cloud.google.com/sdk/gcloud/reference/compute/config-ssh but works for TPU VMs
View tpu_configssh.py
# script to add gcloud instances to ssh config
#
# Usage: tpu_configssh.py <instance_name> <instance_name> ...
#
# A version of this exists in gcloud compute config-ssh but it doesn't work for TPU VMs
#
# Works by parsing the output of dryrun mode of gcloud compute ssh, example:
# $ gcloud alpha compute tpus tpu-vm ssh instance-name --dry-run
# /usr/bin/ssh -t -i /home/user/.ssh/google_compute_engine -o CheckHostIP=no -o HashKnownHosts=no -o HostKeyAlias=<alias> -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/home/user/.ssh/google_compute_known_hosts user@IP
@gngdb
gngdb / .bashrc
Last active September 23, 2022 13:25
Add to bashrc to autocomplete nvim scp commands: `nvim <remote>:/path/to/file.py`
View .bashrc
# autocomplete nvim scp commands
nvim () {
local params=();
while [[ ! -z $1 ]]; do
if [[ "$1" =~ ^[a-z0-9-]*:/.*$ ]]; then
params=("scp://${1/:\//\/\//}" "${params[@]}");
else
params+=("$1");
fi;
shift;
@gngdb
gngdb / downloader.py
Last active July 26, 2021 20:48
Download utility for AIST++ edited to use aria2c https://google.github.io/aistplusplus_dataset/download.html
View downloader.py
# coding=utf-8
# Copyright 2020 The Google AI Perception Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@gngdb
gngdb / Pooling.ipynb
Created June 23, 2021 16:06
Pooling notebook for checking einops channel pooling correctness
View Pooling.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gngdb
gngdb / MLP_Mixer_without_Linear.ipynb
Created May 11, 2021 01:48
Technically an implementation of MLP-Mixer without nn.Linear
View MLP_Mixer_without_Linear.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View relational.py
import torch
from einops import rearrange, repeat, reduce
def relation(input, g, embedding=None, max_pairwise=None):
r"""Applies an all-to-all pairwise relation function to a set of objects.
See :class:`~torch.nn.Relation` for details.
"""
# Batch size, number of objects, feature size
b, o, c = input.size()
# Create pairwise matrix
@gngdb
gngdb / Grayscale Quantised Painting Avatar.ipynb
Last active March 31, 2021 17:56
Generating a new profile picture in the most convoluted way possible.
View Grayscale Quantised Painting Avatar.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Unpacked minGPT.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gngdb
gngdb / Basin Hopping.ipynb
Last active September 24, 2022 12:03
An example using scipy.optimize's basin hopping with torch calculating gradients
View Basin Hopping.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View README.md

This gist shows how to use rebase to change the Git history of a repo. Imagine you realise that the first commit to your repo should be different (maybe it's incomplete, includes something it shouldn't or simply could be cleaner). However, since then you and others have made many changes to the repo that you want to preserve. Here we show how to split the first commit into multiple and re-attach the remaining version history to these new commits.

Let's make a dummy git repo rebase-root and add two files to it. We commit them with the commit #1.