Skip to content

Instantly share code, notes, and snippets.

View thomasjo's full-sized avatar
👨‍🔬
Researching all the things

Thomas Johansen thomasjo

👨‍🔬
Researching all the things
View GitHub Profile
@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)
@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 / 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)
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 / 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
@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 / 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

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 / mintedSweave.R
Created February 5, 2016 19:24 — forked from rundel/mintedSweave.R
Modified Rweave driver and functions to use minted
RweaveLatexMinted <- function()
{
list(setup = RweaveLatexSetup,
runcode = RweaveLatexRuncodeMinted,
writedoc = RweaveLatexWritedocMinted,
finish = RweaveLatexFinish,
checkopts = RweaveLatexOptions)
}
makeRweaveLatexCodeRunnerMinted <- function(evalFunc=RweaveEvalWithOpt)
[{"_id":"553a61598da7834344688642","index":0,"guid":"b5925afe-f783-4306-aa31-87f8ee7c6941","isActive":false,"balance":"$2,225.73","picture":"http://placehold.it/32x32","age":33,"eyeColor":"green","name":"Best Waters","gender":"male","company":"DIGIFAD","email":"bestwaters@digifad.com","phone":"+1 (821) 590-2189","address":"667 Pooles Lane, Waikele, Texas, 4264","registered":"2014-04-04T06:56:57 +07:00","latitude":89.515886,"longitude":-51.082281,"tags":["non","officia","do","quis","pariatur","quis","quis"],"friends":[{"id":0,"name":"Haley Schroeder"},{"id":1,"name":"Cristina Hays"},{"id":2,"name":"Hanson Vaughan"}],"greeting":"Hello, Best Waters! You have 6 unread messages.","favoriteFruit":"banana"},{"_id":"553a615998479a1ea1e3bd2f","index":1,"guid":"e5ad5b96-fa57-455c-be7b-991cf88f8ac2","isActive":true,"balance":"$3,053.51","picture":"http://placehold.it/32x32","age":33,"eyeColor":"brown","name":"Nora Holland","gender":"female","company":"AVIT","email":"noraholland@avit.com","phone":"+1 (810) 590-3862","add