Skip to content

Instantly share code, notes, and snippets.

View ShuhuaGao's full-sized avatar
🎯
Focusing

Shuhua Gao ShuhuaGao

🎯
Focusing
View GitHub Profile
@ShuhuaGao
ShuhuaGao / stp2bool.jl
Created February 9, 2025 04:21
Convert a STP logical vector to its Boolean vector
"""
convert_STP_to_bool(n::Integer, i::Integer)::BitVector
Given a STP logical vector with `i`-th entry as 1, i.e., `δ_{2^n}^i`, recover its `n` Boolean variables.
# Arguments
- `n::Integer`: Number of Boolean variables.
- `i::Integer`: The position of the 1 in the STP logical vector.
@ShuhuaGao
ShuhuaGao / pythoncall-setup-local.md
Last active March 3, 2025 04:40
Setup PythonCall and reuse an existing local Python environment

PythonCall is a Julia package that allows us to call Python in Julia. This gist explains how to let PythonCall reuse a local Python environment we have configured. The benefit is that PythonCall itself will not download Python nor Python packages (which can be slow and erroeneous): we have prepared them in our environment ahead.

Set up local Python environment

  1. Create a Conda, Mamba or MicroMamba environment with the Python version you want. Suppose its name is "myenv".
  2. Install required Python packages into the above envrionment such as pandas, pyplot, etc.

Install PythonCall in Julia

Simply add PythonCall in your Julia environment

@ShuhuaGao
ShuhuaGao / build-view.md
Last active September 2, 2021 06:36
Combine build and view operations in LaTeX-Workshop VS Code
  1. Install the multi-command extension.
  2. Open "keybindings.json" in VS Code. (ctrl+shift+P, and search "Open Keyboard Shortcuts (JSON)")
  3. Add the following content:
    {
        "key": "F5",
        "command": "extension.multiCommand.execute",
        "args": {
            "sequence": [
 "latex-workshop.build",
@ShuhuaGao
ShuhuaGao / props.snippet
Created June 28, 2021 03:19
Property snippet with change notification in Stylet MVVM.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>props</Title>
<Shortcut>props</Shortcut>
<Description>Code snippet for property and backing field and notify with Stylet</Description>
<Author>Gao Shuhua</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@ShuhuaGao
ShuhuaGao / partial_correlation.py
Created January 26, 2019 13:27
Partial correlation matrix for pandas DataFrame
"""
Partial correlation measures the degree of association between two random variables, x and y,
with the effect of a set of controlling random variables z removed.
There is a `pandas.DataFrame.corr`, but no built-in partial correlation support is available.
Usage: given a pandas DataFrame `df`, simply call `par_corr(df)`.
"""
def par_corr_between(x, y, z):
"""
@ShuhuaGao
ShuhuaGao / .gitignore
Created June 27, 2016 08:27 — forked from kogakure/.gitignore
Git: .gitignore file for LaTeX projects
*.aux
*.glo
*.idx
*.log
*.toc
*.ist
*.acn
*.acr
*.alg
*.bbl