Skip to content

Instantly share code, notes, and snippets.

View geoffreygarrett's full-sized avatar
🇺🇦

Geoffrey Garrett geoffreygarrett

🇺🇦
  • Delft University of Technology
  • Netherlands
View GitHub Profile
@geoffreygarrett
geoffreygarrett / github-repository-dispatch.sh
Created February 18, 2022 09:42
How to create a dispatch on a target repository with bash.
# TODO: replace event_type, token, repo and optional_json.
curl -H "Authorization: token {{ token }}" \
-H 'Accept: application/vnd.github.everest-preview+json' \
"https://api.github.com/repos/{{ owner }}/{{ repo }}/dispatches" \
-d '{"event_type": "{{ event_type }}", "client_payload": {{ optional_json | {} }}}'
@geoffreygarrett
geoffreygarrett / fiftyone_predictions.py
Last active February 5, 2022 15:24
Adding predictions to a `fiftyone` dataset.
# Add predictions to samples
with fo.ProgressBar() as pb:
for sample in pb(dataset.view()):
# Load image
image = cv2.imread(sample.filepath)
h, w, c = image.shape
# Perform inference
results = model_best(image, size=3050, augment=False)
// --------------------------------------------------------
// Both are the same functions, with two different designs.
// --------------------------------------------------------
//! Compute gravitational acceleration.
/**
*
* @param GM gravitational parameter of body exerting acceleration
@geoffreygarrett
geoffreygarrett / console_print.txt
Created July 16, 2020 16:42
output_dbcache_example
Downloading codes_300ast_20100725.bsp to ./index_resource/spk/asteroids
61864960
[████████████████████████████████████████████████████████████ 100%] 60415/60415
Finished
./index_resource/spk/asteroids/codes_300ast_20100725.bsp
Downloading de430.bsp to ./index_resource/spk/planets
119741440
[████████████████████████████████████████████████████████████ 100%] 116935/116935
Finished
./index_resource/spk/planets/de430.bsp
@geoffreygarrett
geoffreygarrett / main.py
Last active July 16, 2020 16:51
python_dbcache_example
from dbcachepy import DatabaseCache
if __name__ == "__main__":
test_db = DatabaseCache.from_json("test/test.json")
print(test_db["index_resource/spk/asteroids/codes_300ast_20100725.bsp"])
print(test_db["index_resource/spk/planets/de430.bsp"])
###############################################################################
# IMPORT STATEMENTS ###########################################################
###############################################################################
import numpy as np
from tudatpy import constants
from tudatpy import elements
from tudatpy import io
from tudatpy import ephemerides
from tudatpy import interpolators
from tudatpy import numerical_integrators
@geoffreygarrett
geoffreygarrett / coe2rv.m
Created December 5, 2019 15:43
MATLAB Conversion from classical orbital elements into RV.
function [r,v] = coe2rv(a, e, inc, raan, argp, theta, mu)
cos_raan = cos(raan);
sin_raan = sin(raan);
cos_argp = cos(argp);
sin_argp = sin(argp);
cos_inc = cos(inc);
sin_inc = sin(inc);
r = a * (1 - e ^ 2) / (1.0 + e * cos(theta));
l1 = (+cos_raan * cos_argp - sin_raan * sin_argp * cos_inc);
@geoffreygarrett
geoffreygarrett / class_init_1.py
Last active December 2, 2019 16:17
Conditionally created default arguments in Python class instantiation using "or".
class Test:
def __init__(self, arg=None):
self.test_arg = arg or "Default arg"
test1 = Test()
test2 = Test("Not Default arg")
print(test1.test_arg)
# Default arg
@geoffreygarrett
geoffreygarrett / dictionary_enumeration.py
Created June 21, 2019 21:27
Enumerate list of dictionaries based on key value.
class ClassContainer:
def __init__(self):
# The guessed data structure of the OP's class, as code was not provided. (Needed for reproduction)
self.meta = {"A": []}
# This would be required in the class for proposed solution.
# It is however not needed if set_data is only used once in an instantiated classes lifetime.
self.type_counter = dict() # or {}
@geoffreygarrett
geoffreygarrett / example.cpp
Created June 10, 2019 12:24 — forked from marcinwol/example.cpp
Boost python vector to py list and py list to vector
#include <iostream>
#include <vector>
#include <memory>
#include "boost/shared_ptr.hpp"
#include "boost/python.hpp"
#include "boost/python/stl_iterator.hpp"
using namespace std;