Skip to content

Instantly share code, notes, and snippets.

View mrakitin's full-sized avatar

Max Rakitin mrakitin

View GitHub Profile
@mrakitin
mrakitin / find-python-modules.md
Created October 6, 2021 20:57
Find Python package modules
$ git clone https://github.com/NSLS-II/nslsii.git
$ cd nslsii/
$ find nslsii -name "*.py" | grep -v tests | sed 's/.__init__.py//g' | sed 's;/;.;g' | sed 's/\.py$//g' | sort
import os
from github import Github
token = os.getenv("GITHUB_ACCESS_TOKEN")
gh_org = os.getenv("GITHUB_ORG_UPDATE_TOPICS", "bluesky")
g = Github(token)
all_repos = {}
for repo in g.get_organization(gh_org).get_repos():
#!/bin/bash
# To be run as:
# $ docker run -it --rm -v $PWD:/build quay.io/condaforge/linux-anvil-comp7:latest bash /build/gen-conda-packed-env-nsls2-analysis-2021-1.2.sh
set -e
umask 0002
sudo yum install mesa-libGL -y
#!/bin/bash
# To be run as:
# $ docker run -it --rm -v $PWD:/build quay.io/condaforge/linux-anvil-comp7:latest bash /build/gen-conda-packed-env-tomviz.sh
set -e
umask 0002
. /opt/conda/etc/profile.d/conda.sh
#!/bin/bash
# To be run as:
# $ docker run -it --rm -v $PWD:/build quay.io/condaforge/linux-anvil-comp7:latest bash /build/gen-conda-packed-env-n2sn.sh
set -e
umask 0002
. /opt/conda/etc/profile.d/conda.sh
#!/bin/bash
# To be run as:
# $ docker run -it --rm -v $PWD:/build quay.io/condaforge/linux-anvil-comp7:latest bash /build/gen-conda-packed-env-bmm-analysis.sh
set -e
umask 0002
. /opt/conda/etc/profile.d/conda.sh
#!/bin/bash
# This was tested in the VirtualBox VM from
# https://slaclab.github.io/pydm-tutorial/intro.html. `htop` and `terminator`
# were installed via 'sudo apt-get install ...'
# Documentation: https://gnome-terminator.readthedocs.io/en/latest/advancedusage.html.
terminator -e "bash -i -l <<< '. /etc/profile.d/conda.sh && conda activate tutorial && exec </dev/tty && ipython'" &
sleep 2
import bluesky.plan_stubs as bps
import bluesky.plans as bp
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.run_engine import RunEngine
from bluesky.utils import install_kicker
from databroker import Broker
from ophyd.sim import det, motor
import matplotlib.pyplot as plt
plt.ion()
import bluesky.plan_stubs as bps
import bluesky.plans as bp
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.run_engine import RunEngine
from bluesky.utils import install_kicker
from databroker import Broker
from ophyd.sim import det, motor
import matplotlib.pyplot as plt
plt.ion()
@mrakitin
mrakitin / switch-proxy.sh
Last active October 20, 2020 00:32
Switch ssh proxy configuration via a bash function
switch_proxy() {
allowed_values=("o", "i")
cfg_file="$HOME/.ssh/config"
tmp_file="${cfg_file}_tmp"
ssh_base="ssh"
# ProxyCommand ssh -q -W %h:22 issh
current_pattern="ProxyCommand ssh -q -W %h:22 .${ssh_base}"
current_proxy=$(grep -e "${current_pattern}" ${cfg_file} | head -1 | tail -1 | awk '{print $NF}')