Skip to content

Instantly share code, notes, and snippets.

View yongrenjie's full-sized avatar

Jonathan Yong yongrenjie

  • 22:53 (UTC +01:00)
View GitHub Profile
@yongrenjie
yongrenjie / seaborn_palettes.md
Last active September 23, 2022 08:41
seaborn palettes for easy reference

Hex codes of colors in seaborn palettes

Palette 1 (blue) 2 (orange) 3 (green) 4 (red) 5 (purple) 6 (brown) 7 (pink) 8 (grey) 9 (yellow) 10 (cyan)
deep #4C72B0 #DD8452 #55A868 #C44E52 #8172B3 #937860 #DA8BC3 #8C8C8C #CCB974 #64B5CD
muted #4878D0 #EE854A #6ACC64 #D65F5F #956CB4 #8C613C #DC7EC0 #797979 #D5BB67 #82C6E2
pastel #A1C9F4 #FFB482 #8DE5A1 #FF9F9B #D0BBFF #DEBB9B #FAB0E4 #CFCFCF #FFFEA3 #B9F2F0
bright #023EFF #FF7C00 #1AC938 #E8000B #8B2BE2 #9F4800 #F14CC1 #A3A3A3 #FFC400 #00D7FF
dark #001C7F #B1400D #12711C #8C0800 #591E71 #592F0D #A23582 #3C3C3C #B8850A #006374
colorblind
@yongrenjie
yongrenjie / ppt_fonts.md
Last active August 13, 2021 15:17
custom body font in macOS PowerPoint

In Slide Master on macOS PowerPoint, it's not ordinarily possible to choose body fonts outside of a default set. In order to change this, navigate to the folder

/Applications/Microsoft\ PowerPoint.app/Contents/Resources/Office\ Themes/Theme\ Fonts

Duplicate any of the existing font themes, e.g. Arial.xml. Then edit the duplicate, replacing all instances of Arial with whichever font you want. Restart PowerPoint and the dropdown list should now have a new option corresponding to the font you just added... until Office gets updated.

Note that some or all of these steps may require superuser privileges (i.e. sudo).

@yongrenjie
yongrenjie / min_pshift
Last active January 12, 2022 17:36
Substantially faster version of pshift AU programme for 2D data
/* min_pshift
* ----------
*
* Minimal version of pshift. Only deals with 2D data. Lots of improvements to
* code, so runs much faster especially when the entire 2D dataset doesn't fit
* into memory.
*
* Jonathan Yong, University of Oxford
* 31 Oct 2020 */
@yongrenjie
yongrenjie / jupyterlab_3.8.plist
Created August 4, 2020 12:28
Launch daemon for JupyterLab
<!-- Starts JupyterLab upon login. Unfortunately, there's a slight hitch on Catalina: the process cannot
access user folders such as ~/Desktop, ~/Documents, etc. I tried giving everything full disk access, but
nothing works. Anyway, I have kept this code in case a workaround is found in the future.
To use: Just place this file in ~/Library/LaunchAgents.
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

Just a bunch of things I'm learning about :execute and :normal in Vim.

Some of this is picked up from https://learnvimscriptthehardway.stevelosh.com/chapters/16.html but mostly it's learnt by reading Vim's help and experimentation.

Basic usage of :execute

:execute {expr-string} essentially does some parsing on {expr-string} (see :h expr-string), then runs it as an Ex command, i.e. it does what would happen if you were to type in :{parsed-expr-string} at the Vim command line.

For example, :execute "write" does the same as :write, i.e. saves the file. Note that the string "write" has to be in quotes, otherwise Vim thinks it's a variable. Of course, this does mean that you can set a variable to be equal to "write, viz.:

TopSpin on macOS 13.x (Ventura)

Installing (or running a previously installed version of) TopSpin on Ventura can give a CodeMeter error. CodeMeter must be upgraded to the latest version: this can be obtained from https://www.wibu.com/support/user/user-software.html (click on "CodeMeter User Runtime for OS X, macOS").

I haven't done any extensive testing (my TopSpin-using days are pretty much over), but the permissions issue seems to have gotten much better on Ventura, so you might not need the rest of this gist—though if you do find that you have trouble accessing files, read on...

TopSpin on macOS 10.15 (Catalina) / 11.x (Big Sur) / 12.x (Monterey)

Due to new security measures introduced in Catalina (macOS 10.15), many apps including TopSpin don't work the way one might expect, especially when trying to access files on the Desktop and other protected folders.

function hsqc_si(x,cycle,J)
% Density matrix simulation of sensitivity-enhanced HSQC (not dependent on Spinach).
% Takes two parameters:
% x, which is t1 in seconds.
% cycle, which is the phase cycle number (from 1 to 8),
% J, the C-H coupling in Hz.
% Includes helder functions which plot the trajectory of a density matrix
% on a Bloch sphere. Set J(CH) to 150 Hz to visualise what happens with a
% 13C-1H pair, or 0 Hz for a 12C-1H pair.
@yongrenjie
yongrenjie / clr.py
Last active February 28, 2020 10:19
Python script to remove integrals and picked peaks in TopSpin
# Clears integrals and picked peaks in TopSpin
import os
ds = CURDATA()
if ds == None: EXIT() # dataset not selected
p = os.path.join(ds[3], ds[0], ds[1], "pdata", ds[2])
for fname in ["int", "int1d", "integrals.txt", "intgap", "intrng", "peaklist.xml", "peakrng", "peaks"]:
if os.path.isfile(os.path.join(p,fname)): os.remove(os.path.join(p, fname))
RE(ds)