Skip to content

Instantly share code, notes, and snippets.

@brianv0
brianv0 / jog.py
Created October 13, 2023 19:26
jog
#!/usr/bin/env python3
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE,SIG_DFL)
import json
import sys
tty = True # sys.stdout.isatty()
continue_lines = []
max_continue = 10
@brianv0
brianv0 / pinit
Last active September 3, 2020 01:25
Pin it - Get versions of a package's installed dependencies from conda in a form which is good for the pinned file
#!/bin/bash
pkg=$1
# Get the current versions of a package's installed dependencies
# get dist_name for the package so we can find it's json file
pkg_dist_name=$(conda list --json | jq -r '.[] | select(.name=="'${pkg}'") | .dist_name')
# get dependencies in the form of a regex
name_regex=$(jq -r '.depends | map(. | split(" ")[0]) | join("$|")' ${CONDA_PREFIX}/conda-meta/${pkg_dist_name}.json)
# print list of dependency=version for installed dependencies
conda list --json | jq -r '.[] | select(.name | match("'${name_regex}'")) | "\(.name)=\(.version)"'
@brianv0
brianv0 / sorted_with_groups.txt
Created June 26, 2020 22:38
topologically sorted with groups
>0
afwdata d1c39c2f883e254a0e8fcd080721619ca496e1d3
eigen fd995628f7aa5534ef73c13f6d9660d0cbe3e416
fgcm eb24413433721e758ffc5b1d40d2ea00e837dd26
firefly_client 2f7191361c95bf70c3c206c0a249e7b5c0d47077
obs_decam_data 7048e9c24cba5cc4530673ac24056a5b64b15268
obs_lsst_data 62ccb5892d52e5b75f0b436c2600b091eb7ef257
obs_subaru_data 81f4c9d68cf177131792b9b3154afa53b545b045
obs_test_data b4dcb135d7fe475262c0b982b6f574d74ef90754
proxmin 9ef6562b68df5f7a32e27fc65bfdcc9a670c5547
@brianv0
brianv0 / shell outputh.sh
Last active May 22, 2020 22:09
Qserv instructions
docker run -it lsstdm/centos:7-stackbase-devtoolset-8
[root@2ad9f80b6ef1 /]# git clone https://github.com/lsst/lsstsw
Cloning into 'lsstsw'...
remote: Enumerating objects: 107, done.
remote: Counting objects: 100% (107/107), done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 2412 (delta 63), reused 69 (delta 38), pack-reused 2305
Receiving objects: 100% (2412/2412), 452.65 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1610/1610), done.
[root@2ad9f80b6ef1 /]# cd lsstsw/
@brianv0
brianv0 / pytest-obs_lsst.xml.failed
Created March 11, 2020 07:42
pyyaml 5.3 failures (conda-forge variant)
============================= test session starts ==============================
platform darwin -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.0
rootdir: /private/tmp/sss/stack/lsstsw/obs_lsst, inifile: setup.cfg
plugins: flake8-1.0.4, subtests-0.3.0, doctestplus-0.4.0, forked-1.1.2, xdist-1.31.0, session2file-0.1.9, cov-2.8.1
gw0 I / gw1 I / gw2 I / gw3 I / gw4 I / gw5 I / gw6 I / gw7 I / gw8 I / gw9 I / gw10 I / gw11 I
gw0 [382] / gw1 [382] / gw2 [382] / gw3 [382] / gw4 [382] / gw5 [382] / gw6 [382] / gw7 [382] / gw8 [382] / gw9 [382] / gw10 [382] / gw11 [382]
.............................................s.....s..s....s............ [ 18%]
.....s...ss...s.s.s..s......s...s.....s.ss.....................s.....s.s [ 37%]
..................ss......s..........ss.................s..........s..s. [ 56%]
@brianv0
brianv0 / encrypt_session_example.py
Created February 14, 2020 02:53
Prepare session for Redis
# Inject a session oauth2_proxy redis session store
import base64
import hashlib
import json
import os
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
def encrypt_field(field: str, oauth2_secret: str) -> bytes:
@brianv0
brianv0 / sites.csv
Created January 30, 2020 01:37
IIS Sites
IIS Site Hosts IIS Root Directory (under D:\inetpub\sites
www-sld www-sld.slac.stanford.edu www-bes.slac.stanford.edu www-midas.slac.stanford.edu sld
www-sldnt www-sldnt.slac.stanford.edu sldnt
java.freehep.org java.freehep.org java
lcsim lcsim.org www.lcsim.org lcsim
www.freehep.org www.freehep.org freehep
jas jas.freehep.org sldnt/jas
wired4 wired.freehep.org wired4.freehep.org wired4
wired1 wired1.freehep.org wired1
heprep heprep.freehep.org heprep
@brianv0
brianv0 / new_tsort.py
Last active December 13, 2019 12:34
new tsort algorithm
from typing import Iterator, Iterable, List, Mapping, Set, Tuple
class GraphError(Exception):
pass
def to_dep_graph(edges: Iterable[Tuple[str, str]]) -> Mapping[str, Set[str]]:
"""Takes an iterable collection of (object, dependency) pairs and returns
as a graph set"""
graph = {}
for node, dep in edges:
@brianv0
brianv0 / L1Proc-Singularity.xml
Created October 9, 2019 12:04
L1Proc Singularity+centos7
<?xml version="1.0" encoding="UTF-8"?>
<pipeline
xmlns="http://glast-ground.slac.stanford.edu/pipeline"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://glast-ground.slac.stanford.edu/pipeline https://glast-ground.slac.stanford.edu/Pipeline-II/schemas/2.1/pipeline.xsd">
<task name="L1Proc-Singularity" version="5.7" type="Data">
<variables>
<var name="baseVersion">0</var>
@brianv0
brianv0 / environment-export.osx.yml
Created September 30, 2019 15:15
DM-20864 Notes - OSX
name: lsst_test_env
channels:
- conda-forge
- defaults
dependencies:
- apipkg=1.5=py_0
- apr=1.6.5=h1de35cc_0
- asn1crypto=0.24.0=py37_1003
- asteval=0.9.15=pyh5ca1d4c_0
- astropy=3.2.1=py37h01d97ff_0