Skip to content

Instantly share code, notes, and snippets.

View juniperfdel's full-sized avatar

Juniper F juniperfdel

View GitHub Profile
@juniperfdel
juniperfdel / test_oom.py
Created February 29, 2024 19:50
The Skyfield OOM testing script from my Satellite Calculator Repo
"""
A minimal working example of using tle, oom xml, and oom csv with the Skyfield Python Library
Licensed under the MIT license
Copyright (c) 2024 Juniper Foote
"""
from enum import Enum
from pathlib import Path
from urllib.request import urlopen
@juniperfdel
juniperfdel / displaylink_fedora_39_install.md
Created February 19, 2024 18:35
How I installed DisplayLink on Fedora 39 for my AOC USB Monitor
@juniperfdel
juniperfdel / loosly_typed_ifelse.cpp
Last active June 13, 2024 22:15
loosely typed if/else if/else C++ experiment
// if/else if/else std::variant type checking; By: Juniper Foote
// Using https://gist.github.com/juniperfdel/c5940f7d52d20f4c4a3903d94b2fc859 to see if the argument is a base value
// On g++; works for c++17 (with -fconcepts) and above
// On clang++; works for C++20 and above
#include <iostream>
#include <iomanip>
#include <string>
#include <type_traits>
#include <variant>
#include <vector>
@juniperfdel
juniperfdel / py_issubclass.cpp
Created October 19, 2023 13:33
Pythons issubclass and isinstance in C++ (my way - no standard model)
// Many other answers found here: https://stackoverflow.com/questions/307765/how-do-i-check-if-an-objects-type-is-a-particular-subclass-in-c
// A c++ way of doing what issubclass or isinstance in python does but without the standard library. The only limitation is that all inheritance
// must be public - otherwise you will get an error
// if applicable in any capacity - licensed under the unlicense
#include <iostream>
class A {};
class B : public A {};
class C : public B {};
class D {};
@juniperfdel
juniperfdel / Root2Duckdb.py
Created August 4, 2022 16:13
Convert a ROOT file to a DuckDB database as much as possible with uproot
import argparse
import os
from pathlib import Path
import awkward as ak
from pyarrow import parquet as pq
import uproot
@juniperfdel
juniperfdel / parallelize_with_asyncio.py
Last active June 17, 2022 17:10
A recipe to parallelize python functions with asyncio; written to be run in a juypter notebook
import asyncio
from asyncio import Task
import nest_asyncio
from functools import partial, wraps
import time
def slow_fn(i):
print("Called slow_fn with ", i)
time.sleep(1.)
@juniperfdel
juniperfdel / build_gcc.sh
Last active April 18, 2022 16:05
GCC build script with all dependencies; download and build all gcc dependencies then gcc itself. Set the --prefix option for each configure script to change the install directory.
mkdir ./libtool ./gmp ./mpc ./m4 ./automake ./bison ./autoconf ./texinfo ./binutils ./flex ./isl ./gcc ./mpfr
git clone --recursive --depth 1 https://github.com/westes/flex.git ./flex
wget https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz && tar --extract --file binutils-2.38.tar.gz --directory ./binutils --strip-components 1
wget https://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz && tar --extract --file autoconf-latest.tar.gz --directory ./autoconf --strip-components 1
wget https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.gz && tar --extract --file bison-3.8.2.tar.gz --directory ./bison --strip-components 1
wget https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.gz && tar --extract --file automake-1.16.5.tar.gz --directory ./automake --strip-components 1
wget https://ftp.gnu.org/gnu/texinfo/texinfo-6.5.tar.gz && tar --extract --file texinfo-6.5.tar.gz --directory ./texinfo --strip-components 1
wget https://ftp.gnu.org/gnu/m4/m4-latest.tar.bz2 && tar --extract --file m4-latest.tar.bz2 --directory ./m
@juniperfdel
juniperfdel / Root2Json.py
Last active March 29, 2022 12:58
Convert a ROOT file to a JSON file when the structure is just a list of TTrees with PyROOT
import argparse
import json
import sys
from ROOT import TTree,TFile
def root_to_dict(in_file):
root_fp = TFile(in_file)
file_kl = root_fp.GetListOfKeys()
@juniperfdel
juniperfdel / retweet_finder.js
Last active August 31, 2021 06:20
Output all usernames of people who retweeted into console
// ==UserScript==
// @name retweet_finder
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Output all usernames of people who retweeted into console
// @author Gregory Foote
// @match https://twitter.com/*
// @exclude https://twitter.com/*/*
// ==/UserScript==