Skip to content

Instantly share code, notes, and snippets.

@danielballan
danielballan / logging-optimizations.md
Created January 28, 2021 16:47
Logging optimizations galaxy brain

Logging optimizations

We will examine the byte code to get a sense of how much work the interpreter is doing.

Setup

>>> import logging
>>> logger = logging.getLogger()
>>> from dis import dis
@bombs-kim
bombs-kim / install_custom_python_in_conda.sh
Created December 27, 2018 14:53
How to install a custom python binary(ex. python-dbg) in your conda environment.
# This instruction is for Unix-like OS users.
# I refered to the following guide when I wrote it.
# https://conda.io/docs/user-guide/tasks/build-packages/recipe.html
# Activate an environment if needed
conda activate myenv
# Install conda-build if you haven't. Ironically, installing conda-build
# includes installing python. This python will be effectively replaced with
# your new python binary so don't worry.
record(ao, "test:ao") {
field(ASG, "rps_threshold")
field(DRVH, "10")
field(DRVL, "0")
}
record(bo, "test:bo") {
field(ASG, "rps_lock")
field(ZNAM, "OUT")
field(ONAM, "IN")
@kevinvalk
kevinvalk / issue_collector.html
Last active May 12, 2022 10:42
Can be used to integrate JIRA issue collector as a iframe form in a page where javascript is not allowed. Call like https://cdn.rawgit.com/kevinvalk/ae09e21a522c378b2ceb419cf09a36a7/raw/a57cb1cb788fa6c141893dd1fdcf185d541c22af/issue_collector.html?url=<JIRA URL>#<ISSUE COLLECTOR ID>.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
<script type="text/javascript">
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
@danielballan
danielballan / deployment-plan.md
Last active May 17, 2016 18:36
Upgrade checklist, May 2016
  1. Create 'DAMA Software' logbook in beamline Olog.
  2. Run conda list -n collection > /tmp/conda-list-before-upgrade.txt and include it in an Olog entry as an attachment.
  3. Commit any uncomitted code in the IPython profile, which should be located (or linked to) at ~/.ipython/profile_colllection.
  4. Create a new directory inside the IPython profile, ~/.ipython/profile_collection/acceptance_tests.
  5. Write acceptance tests as short, standalone scripts that can be executed like ipython --profile=collection -i 01-some-test.py. See examples from XPD or CSX.
  6. Run acceptance tests successfully, and commit repo.
  7. Install packages. Use --no-deps to keep conda from installing things you don't want.
    • event_model>=1.0.2
    • bluesky==0.5.1
  • databroker==0.4.1
@simonw
simonw / gist:68d19a46e8edc2cd8c68
Last active October 13, 2021 00:04
Fix "Do you want the application "python" to accept incoming network connections?" by code signing the python executable in your virtualenv - copied here in case https://www.darklaunch.com/2014/02/02/fix-do-you-want-the-application-python-to-accept-incoming-network-connections ever goes away.
With the OS X firewall enabled, you can remove the "Do you want the application "python" to accept incoming network connections?" message.
Create a self-signed certificate.
Open Keychain Access. Applications > Utilities > Keychain Access.
Keychain Access menu > Certificate Assistant > Create a Certificate...
Enter a Name like "My Certificate".
Select Identity Type: Self Signed Root
Select Certificate Type: Code Signing
Check the Let me override defaults box
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pwuertz
pwuertz / PyQt5_OpenGl_TextureFromNumpy.py
Created October 27, 2014 09:44
PyQt5 Example: Create OpenGL texture from numpy array via mapped pixel buffer
from OpenGL import GL
from PyQt5 import QtWidgets, QtCore, QtGui, QtOpenGL
from OpenGL.GL.ARB.texture_rg import GL_R32F
import numpy as np
import ctypes
import time
w, h = 400, 400
class TestWidget(QtOpenGL.QGLWidget):
@ryin
ryin / tmux_local_install.sh
Last active October 2, 2024 14:23
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8