Skip to content

Instantly share code, notes, and snippets.

View agoose77's full-sized avatar
🏠
Working from home

Angus Hollands agoose77

🏠
Working from home
View GitHub Profile
label: dos
label-id: 0x000e4547
device: /dev/sdb
unit: sectors
/dev/sdb1 : start= 2048, size= 204800, type=17
/dev/sdb2 : start= 206785, size= 1324167231, type=f
/dev/sdb5 : start= 206848, size= 1324167168, type=7
def gen_primes() -> Iterator[int]:
yield 2
n = 3
def is_prime(x: int) -> bool:
return all(x % i for i in range(2, int(x ** 0.5) + 1))
#!/usr/bin/env bash
get_local_packages(){
comm -23 <(apt-mark showmanual | sort -u) \
<(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
return 0;
}
get_latest_diff() {
@agoose77
agoose77 / sync.py
Created October 23, 2017 09:18
Synchronise packages with remote repository. Change the directory and package_list_name variables to define where repository is held & specify the filename of the sync file
#!/usr/bin/python3.6
import sh
import re
from sys import exit
from collections import namedtuple
from tempfile import mkstemp
from os import fdopen, remove
@agoose77
agoose77 / .profile
Last active May 22, 2020 09:30
My .profile
RET=$(pwd) && cd /opt/geant4/bin && . ./geant4.sh && cd $RET
PATH="$HOME/.local/bin:$PATH"
export PYTHONPATH="$HOME/GIT/geant4/environments/g4py/lib"
# Fix for local users connecting to display
xhost +local:
# Add texlive
PATH=/usr/local/texlive/2017/bin/x86_64-linux:$PATH; export PATH
@agoose77
agoose77 / build_gemc.sh
Last active November 6, 2017 10:01
GEMC build helper
export JLAB_ROOT=~/jlab
export JLAB_VERSION=devel
. $JLAB_ROOT/$JLAB_VERSION/ce/jlab.sh
export PYTHONPATH=$JLAB_ROOT/$JLAB_VERSION/scons_bm/$JLAB_VERSION:$PYTHONPATH
# Should we use debug symbols?
DEBUG=0
while getopts d option
from collections import deque, namedtuple
from time import time
from enum import auto, Enum
from operator import itemgetter
class Trap(Enum):
SLEEP = auto()
SPAWN = auto()
WHOAMI = auto()
from collections import deque, namedtuple, defaultdict
from time import time
from types import coroutine
from enum import auto, Enum
from operator import itemgetter
def async_contextmanager(func):
class ctx:
def __init__(self, *args, **kwargs):
<gcard>
<!-- Define the materials, and detectors -->
<definitions>
<material path="scintillator" factory="TEXT"/>
<material path="other_materials/" factory="TEXT"/>
<material table="scintillator_materials"/>
<detector path="basic_detector" factory="TEXT"/>
<detector path="basic_cad_detector" factory="CAD"/>
<detector path="basic_cad_detectors/" factory="CAD"/>
</definitions>
G4MaterialPropertyVector* f_AddProperty(G4MaterialPropertiesTable* table, const char *key,
np::ndarray& PhotonEnergies, np::ndarray& PropertyValues)
{
if (PhotonEnergies.get_nd() != 1 || PropertyValues.get_nd() != 1)
throw std::invalid_argument("Expected single dimension for PhotonEnergies and PropertyValues arrays");
const Py_intptr_t *shape = PhotonEnergies.get_shape();
int n_values = shape[0];
if (PropertyValues.get_shape()[0] != n_values)