Skip to content

Instantly share code, notes, and snippets.

View davegreenwood's full-sized avatar

Dave Greenwood davegreenwood

  • University of East Anglia
View GitHub Profile
@davegreenwood
davegreenwood / angle_diff.py
Created January 13, 2021 14:08
difference between rotation matrices
# %%
import torch
import torch.nn.functional as F
# compute rotation vector to get from a to b
def angleBetweenRT(a, b):
# find rotation axis
rotvec = torch.cross(a, b)
@davegreenwood
davegreenwood / gitrepo.sh
Created June 27, 2020 12:50
A script to initialise a git repo locally and GitHub.
#!/bin/bash
# Make executable with chmod +x <<filename.sh>>
# based on:
# https://www.freecodecamp.org/news/automate-project-github-setup-mac/
#
# but using a github personal access token:
# https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
@davegreenwood
davegreenwood / linear.py
Last active April 2, 2020 11:55
PyTorch demo to learn line parameters.
"""Fit a 2d line to data using auto differentiation to learn w, b."""
# %%
import torch
import matplotlib.pyplot as plt
# size of data - more data wil give a more accurate result
N = 500
# we can add noise to data to make it more realistic
noise = torch.randn(N)
@davegreenwood
davegreenwood / cmpgpusvr.md
Last active March 13, 2020 10:54
gpu server hints and tips

CMPGPUSVR hints and tips

Server is run on a be polite policy - it's not a right but a privilege :)

Etiquette

There are two main considerations for users.

GPU

@davegreenwood
davegreenwood / Dell1320c_32bit.ppd
Created December 13, 2019 10:32
DELL 1320C PPD description
*PPD-Adobe: "4.3"
*%
*% PPD file for Dell 1320 netork color printer
*%
*% Based on orginal file:
*%
*% FX DocuPrint C525 A-AP PPD file for CUPS.
*%
*% Copyright 2005 by Fuji Xerox Co.,Ltd.
*%
@davegreenwood
davegreenwood / scatter_image.py
Created September 14, 2019 09:30
scatter plot over image with point id hover data
from plotly.offline import init_notebook_mode, iplot
import plotly.graph_objs as go
init_notebook_mode()
# x, y is point data, image is a PIL image.
trace0 = go.Scatter(
x=x, y=y, mode='markers',
hovertext=[str(i) for i in range(len(x))],
hoverinfo="text",)
@davegreenwood
davegreenwood / OpenCVmatrix.txt
Created July 25, 2019 06:56
OpenCV to OpenGL projection
How to get the proper OpenGL projection matrix from the OpenCV camera calibration values?
For the simple common case where the OpenCV camera matrix has the form:
|fx 0 cx|
|0 fy cy|
|0 0 1|
The corresponding OpenGL projection matrix can be computed like this:
@davegreenwood
davegreenwood / python.json
Created July 8, 2019 09:33
vs code python snippets
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@davegreenwood
davegreenwood / jupyter-setup.md
Created June 15, 2019 11:24
Set up for jupiter notebooks, including dark themes.

Setting up jupyter notebook

First install jupyter themes to change appearance.

pip install jupyterthemes

Then, set the theme to taste

jt -t onedork \

@davegreenwood
davegreenwood / reorder.py
Created June 14, 2019 15:41
Example of how to reorder the vertex numbering in an obj file with a python script.
# %% reorder the vertices
import numpy as np
# %%
with open("oldorder.obj") as fid:
lines = fid.readlines()
print(lines)
# %%