Skip to content

Instantly share code, notes, and snippets.

View dtxe's full-sized avatar

Simeon Wong dtxe

View GitHub Profile
@dtxe
dtxe / plot_atlas_on_surf.py
Created July 25, 2024 20:13
Plot atlas on brain surface
from typing import Literal, List
import surfplot
import matplotlib as plt
import nibabel as nib
import numpy as np
import pandas as pd
def plot_atlas_on_surf(atlas_path: str,
@dtxe
dtxe / code.gs
Created June 21, 2024 03:56
Google AppScript to parse sheet of walk up songs for spotify soundboard
/**
* The event handler triggered when editing the spreadsheet.
* @param {Event} e The onEdit event.
* @see https://developers.google.com/apps-script/guides/triggers#onedite
*/
function onEdit(e) {
// columns
// PlayerName Number SpotifyURL StartTime EndTime
// get the sheet and the range of data
@dtxe
dtxe / Instructions.md
Last active April 26, 2024 21:41
Installing DSI studio on Ubuntu 20.04

Install packages

pip install aqtinstall
aqt install-qt linux desktop 6.5.0 -m qtcharts --outputdir /opt/qt6
sudo apt install libxcb-cursor-dev

Set environment variables

export QTDIR="/opt/qt6/6.5.0/gcc_64"
@dtxe
dtxe / kt_pca.py
Created March 5, 2024 20:34
Kernel Trick PCA
from typing import Tuple
import numpy as np
def kt_pca(X:np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
"""
This is an implementation of the linear kernel PCA method ("kernel trick")
described in "Kernel PCA Pattern Reconstruction via Approximate Pre-Images"
by Schölkopf et al, ICANN, 1998, pp 147-15
Parameters
@dtxe
dtxe / google_to_porkbun.py
Created January 26, 2024 20:00
Transfer DNS records from Google Domains YAML format to Porkbun via the Porkbun API
import yaml
import requests
import json
# Load config file
with open('domain.YAML', 'r') as f:
data = list(yaml.safe_load_all(f))
with open('apikeys.yml', 'r') as f:
apikeys = yaml.safe_load(f)
@dtxe
dtxe / porkbun_ddns.py
Last active January 26, 2024 20:06
Dynamic DNS address updater for Porkbun
import os.path
import yaml
import requests
import logging
from typing import Tuple
logging.basicConfig(level=logging.INFO)
class Porkbun():
@dtxe
dtxe / Lesson3notes.md
Created January 19, 2024 14:01
DSI Session 2 - Unix lesson 3 notes

Notes from Shell Lesson 3

Doing things faster in bash

Keyboard shortcuts

  • A good (albeit comprehensive) cheatsheet is found here: https://gist.github.com/tuxfight3r/60051ac67c5f0445efee
  • You'll eventually find a subset of the shortcuts that you use most often.
  • My personal list is:
    • Ctrl + A / Home key: move to the beginning of the line
    • Ctrl + E / End key : move to the end of the line
  • Ctrl + K : delete from cursor to end of the line
@dtxe
dtxe / quickinstall_gcm.sh
Created January 4, 2024 18:36
Install and configure GCM using defaults for DSI course
#!/bin/bash
# download gcm
wget https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.4.1/gcm-linux_amd64.2.4.1.deb
sudo apt install ./gcm-linux_amd64.2.4.1.deb
# configure
git-credential-manager configure
git config --global credential.credentialStore cache
git config --global credential.cacheOptions "--timeout 14400"
@dtxe
dtxe / latex_to_pgml.cs
Last active December 20, 2023 16:10
Convert Latex mathematical notations to PGML for use in WebWork: Clipboard Fusion Macro
// This Clipboard Fusion macro makes it easy to copy Latex from the Learning Standards Project into WebWork compatible formats
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
// The 'text' parameter will contain the text from the:
// - Current Clipboard when run by HotKey
// - History Item when run from the History Menu
// The returned string will be:
@dtxe
dtxe / temperature anomalies.csv
Created November 27, 2023 05:22
MAT188H1-2023F-HW5 temperature anomalies data
Year Value
1880 -0.17
1881 -0.09
1882 -0.11
1883 -0.18
1884 -0.29
1885 -0.34
1886 -0.32
1887 -0.37