Skip to content

Instantly share code, notes, and snippets.

View chrisburr's full-sized avatar

Chris Burr chrisburr

  • CERN
  • Geneva, Switzerland
View GitHub Profile
# See https://www.anaconda.com/understanding-and-improving-condas-performance/ for more info.
# help debug channel issues
show_channel_urls: true
# pip will always be installed with python
add_pip_as_python_dependency: true
# strict priority and conda-forge at the top will ensure
# that all of your packages will be from conda-forge unless they only exist on defaults
@alexpearce
alexpearce / db.py
Created October 2, 2018 07:31
Snakemake remote file support for a Python dictionary backed by a shelve database.
import shelve
import string
import time
class MeasurementDB(object):
r"""Database for storing measurements, with export to LaTeX macros.
Example usage:
@gdamjan
gdamjan / ssl-check.py
Last active April 14, 2024 07:16
Python script to check on SSL certificates
# -*- encoding: utf-8 -*-
# requires a recent enough python with idna support in socket
# pyopenssl, cryptography and idna
from OpenSSL import SSL
from cryptography import x509
from cryptography.x509.oid import NameOID
import idna
from socket import socket
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@alexpearce
alexpearce / triple_gaussian.py
Created September 2, 2015 14:21
Define a triple Gaussian PDF in RooFit
# Name of the delta mass variable in the workspace
dmass_var = 'Dst_delta_M'
# Species of the PDF we're about to build
species = 'sig'
workspace.factory('mu_dm_{0}[141, 146]'.format(species))
workspace.factory('sigma_one_dm_{0}[1, 0, 5]'.format(species))
workspace.factory('nsigma_two_dm_{0}[1.5, 1, 3]'.format(species))
workspace.factory('nsigma_three_dm_{0}[1.5, 1, 3]'.format(species))
workspace.factory((
'expr::sigma_two_dm_{0}('
# Assume you have a git repo that contains some code
# you would like to use the same repo to create snapshots
# of how exactly the repo looked at certain moments in
# time. For example every time you run `amazing_script.py`
# You want to capture all the things, not just files already
# part of the repo, you don't care about conflicts, just
# take a picture of the directory as it was right at that
# moment.
#
# Is this a good way of doing this?
@alexpearce
alexpearce / sweights_example.png
Last active June 24, 2018 03:37
Example of sWeight generation and sWeight distributions in RooFit
sweights_example.png
@pbugnion
pbugnion / ipython_notebook_in_git.md
Last active October 22, 2023 12:25
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

@thomasfr
thomasfr / autossh.service
Last active January 5, 2024 08:11
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)