Skip to content

Instantly share code, notes, and snippets.

View JasonLo's full-sized avatar

Jason Lo JasonLo

View GitHub Profile
@JasonLo
JasonLo / break.py
Last active April 2, 2020 16:05
Flow control snippet for #psychopy
# Add this component code in a break routine
# Select when to break after trial no. x
break_after_trial = [2, 5]
# Terminate this routine if this trial no. is not in break_after_trial
# Note: trials.thisN is the current item no. with zero indexing
# i.e., 1st item a participant see is 0, 2nd item is 1...
if not((trials.thisN + 1) in break_after_trial):
continueRoutine = False
@JasonLo
JasonLo / .pre-commit-config.yaml
Created November 21, 2021 02:44
Formatting and clear output pre-commit hook #pre-commit
repos:
- repo: https://github.com/psf/black
rev: 21.11b1
hooks:
- id: black
language_version: python3.8.10
exclude: references/
- repo: local
hooks:
- id: jupyter-nb-clear-output
@JasonLo
JasonLo / git_2_remote.sh
Last active January 6, 2022 22:59
git tracking differnt remote branch
# Assume we already have a remote called origin linked to this repo
# Add a new remote called "upstream"
git remote add upstream https://github.com/owner/repo.git
# Set local master branch to track from upstream master
git branch -u upstream/master master
# Create a new private branch for development
git checkout -b dev
@JasonLo
JasonLo / alt_no_max.py
Last active January 8, 2022 18:11
Altair disable max row
# Altairs by default will not take dataframe with more than 5000 rows.
# This command will disable this limit.
alt.data_transformers.disable_max_rows()
@JasonLo
JasonLo / git_post_pr.sh
Last active January 8, 2022 06:44
git post PR cleanup
git checkout master
git pull
git checkout -b feature
git push --set-upstream origin feature
@JasonLo
JasonLo / git_alias_multi.sh
Last active January 8, 2022 18:10
git alias with multiple steps
# .gitconfig
# single-command alias: lg
# multi-command alias: mp
[alias]
lg = log --all --decorate --oneline --graph
mp = !git checkout master && git pull
@JasonLo
JasonLo / gcp_rsync.sh
Last active October 8, 2022 16:20
rsync to bucket
export BUCKET=gs://<bucket-name>
gsutil mb -l us-central1 $BUCKET
gsutil lifecycle set <lifecycle-json-file> $BUCKET
gsutil -m rsync -r runs/<run-name>/ $BUCKET
@JasonLo
JasonLo / lifecycle.json
Created October 8, 2022 16:03
GS lifecycle setting json example
{
"rule": [
{
"action": {
"type": "SetStorageClass",
"storageClass": "COLDLINE"
},
"condition": {
"age": 3,
"matchesSuffix": [".h5", ".parquet", ".csv"]
@JasonLo
JasonLo / mkdocs.yml
Created January 20, 2023 20:56
mkdocs and deploy to github page
name: mkdocs
on:
push:
branches:
- main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
@JasonLo
JasonLo / list_gpu_occupants.sh
Created October 25, 2024 21:15
GPU occupant
#!/bin/bash
# Check if nvidia-smi is available
if ! command -v nvidia-smi &> /dev/null; then
echo "nvidia-smi not found. Please ensure NVIDIA drivers are installed."
exit 1
fi
# Get GPU processes using nvidia-smi
process_list=$(nvidia-smi --query-compute-apps=gpu_uuid,pid --format=csv,noheader,nounits)