Skip to content

Instantly share code, notes, and snippets.

View thomasjo's full-sized avatar
🛰️

Thomas Johansen thomasjo

🛰️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am thomasjo on github.
  • I am thomasjo (https://keybase.io/thomasjo) on keybase.
  • I have a public key whose fingerprint is 688B 41C5 7B2C F991 EED4 9698 1F3F 91B0 71AA 313B

To claim this, I am signing this object:

@thomasjo
thomasjo / git-prs.md
Created July 7, 2016 17:56 — forked from weppos/git-prs.md
PRs as Git Branches

If you want to download GitHub PRs to your local repository, you can use a little trick to download them as local branches.

Open the repository configuration file (.git/config) and search for the origin block. Change it from:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:USERNAME/REPOSITORY.git
@thomasjo
thomasjo / pr.md
Created July 8, 2016 04:44 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@thomasjo
thomasjo / update-nvidia-driver.sh
Created September 4, 2017 06:23
Linux kernel post-installation script for re-installing the NVIDIA (CUDA) driver.
#!/bin/bash
set -eu
KERNEL_DRIVER="/lib/modules/$1/kernel/drivers/video/nvidia.ko"
INSTALLER="/usr/src/cuda-toolkit"
# Build new driver if it doesn't exist
if [ -e $KERNEL_DRIVER ] ; then
echo "NVIDIA driver already installed for this kernel" >&2
cd /sys/devices/pci0000\:00/0000\:00\:03.0/0000\:09\:00.0/0000\:0a\:10.0/0000\:0e\:00.0/
systemctl stop kubelet
systemctl stop docker
echo 1 > remove
systemctl start docker
systemctl start kubelet
@thomasjo
thomasjo / string_array.go
Created August 19, 2021 07:57
Go + YAML "string array" implementation
// Source: https://github.com/go-yaml/yaml/issues/100#issuecomment-901604971
type StringArray []string
func (a *StringArray) UnmarshalYAML(value *yaml.Node) error {
var multi []string
err := value.Decode(&multi)
if err != nil {
var single string
err := value.Decode(&single)
@thomasjo
thomasjo / .envrc
Last active October 27, 2021 10:59
VS Code + Python + Poetry + direnv + ...
# Save this file in the project root.
dotenv_if_exists
layout poetry
@thomasjo
thomasjo / global-protect.sh
Created April 19, 2022 12:23 — forked from kaleksandrov/global-protect.sh
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)