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
@agoose77
agoose77 / emoji.py
Created July 21, 2022 11:56
Sphinx extension to render emojis in XeLaTeX using emojicdn
import requests
import pathlib
import os
import re
from sphinx.util import logging
logger = logging.getLogger(__name__)
def emoji_to_identifier(emoji):
@agoose77
agoose77 / emoji-xelatex.sty
Created July 21, 2022 11:55
Emojis using a BW vector font in XeLaTeX
% Support emoji
\usepackage{fontspec}
\newfontfamily{\emojifont}{Noto Emoji}
\usepackage[Latin, Greek, Dingbats, TransportAndMapSymbols, MiscellaneousSymbolsAndPictographs]{ucharclasses}
\setTransitionsFor{MiscellaneousSymbolsAndPictographs}{\begingroup\emojifont}{\endgroup}
\setTransitionsFor{TransportAndMapSymbols}{\begingroup\emojifont}{\endgroup}
\setTransitionsFor{Dingbats}{\begingroup\emojifont}{\endgroup}
// ==UserScript==
// @name Hide Adverts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.amazon.co.jp/*
// @match https://smile.amazon.co.uk/*
// @match https://www.amazon.co.uk/*
// @match https://smile.amazon.com/*
import numba
import ast
import awkward as ak
import inspect
from numba import literal_unroll
ak.numba.register()
hist==2.6.1
numpy>=1.17
mplhep==0.3.23
@agoose77
agoose77 / example.py
Created April 12, 2022 11:21
Running binaries with arguments with a %%script magic
%%script env -S podman run --rm -i -w /source -v {cwd}:/source --entrypoint=python3 garfieldpp
import math
@nb.njit
def _reservoir_sample_prepare(n, w, i, out):
k = len(out)
out[:] = np.arange(k, dtype=out.dtype)
i[()] = k - 1
w[()] = 1
@ak._connect._numpy.implements("stack")
def stack(arrays, axis=0, merge=True, mergebool=True, highlevel=True, behavior=None):
"""
Args:
arrays: Arrays to concatenate along any dimension.
axis (int): The dimension at which this operation is applied. The
outermost dimension is `0`, followed by `1`, etc., and negative
values count backward from the innermost: `-1` is the innermost
dimension, `-2` is the next level up, etc.
merge (bool): If True, combine data into the same buffers wherever
def choose(a, choices, mode="raise", highlevel=True, behavior=None):
def getfunction(inputs, depth):
if not all(x.purelist_depth == 1 for x in inputs):
return
arrays = [nplike.asarray(x) for x in inputs]
a = arrays[0]
choices = arrays[1:]
out = np.choose(a, choices, mode=mode)
def promote_option(
array: ak.Array,
axis: int = None,
union: bool = True,
highlevel=True,
behavior=None,
) -> ak.Array:
nplike = ak.nplike.of(array)
layout = ak.to_layout(array)
posaxis = layout.axis_wrap_if_negative(axis)