Skip to content

Instantly share code, notes, and snippets.

View beniroquai's full-sized avatar

Benedict Diederich beniroquai

  • IPHT Leibniz Institute of Photonic Technology's
View GitHub Profile
import os
import re
import tifffile
# adjust to dataset:
input_dir = "PATH_TO_TIFFS"
pixel_size = 0.225
maximum_shift_microns = 50
@ethanjli
ethanjli / 2023-04-18 anglerfish-matchboxscope meeting.md
Last active April 19, 2023 20:00
2023-04-18 anglerfish/matchboxscope concurrency discussion pseudocode

currently

when there's an HTTP request for the camera stream:
  serve an MJPEG-over-HTTP stream (multi-part), by:
    as long as the request is open, repeatedly do:
      get the latest frame from the camera by calling esp_camera_fb_get
      send it over HTTP as part of the multi-part response

when there's an HTTP request to upload the latest frame from the camera to Github:
  get the latest frame from the camera by calling esp_camera_fb_get
@mcbridejc
mcbridejc / generate_track_layout.py
Last active October 26, 2023 23:20
Magnetic Train Track Kicad Plugin
"""KiCad plugin to generate linear stepper track traces in KiCad"""
import pcbnew
import numpy as np
WIDTH=13.2
PITCH=1.0
WIDTH_MARGIN = 1.2
LINE_WIDTH = 0.3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matthewwardrop
matthewwardrop / notebook_runner.py
Last active April 3, 2024 21:55
In-Process Jupyter Notebook Runner
# (c) Matthew Wardrop 2019; Licensed under the MIT license
#
# This script provides the ability to run a notebook in the same Python
# process as this script, allowing it to access to variables created
# by the notebook for other purposes. In most cases, this is of limited
# utility and not a best-practice, but there are some limited cases in
# which this capability is valuable, and this script was created for
# such cases. For all other cases, you are better off using the
# `nbconvert` execution API found @:
# https://nbconvert.readthedocs.io/en/latest/execute_api.html
@rwb27
rwb27 / Readme.md
Last active February 24, 2019 15:51
A test object for "self-tapping" triangular holes in printed parts. Print the STL then fill out the Google form.

I've switched to using slightly triangular holes in my printed parts, because they "self tap" quite nicely using machine screws (the points of the triangles provide enough space that the swarf doesn't jam the thread). My hope is that this extends the tolerance on hole size, meaning I don't have to worry quite so much about getting diameters exactly right. This means the print should work first-time on a greater range of printers. If you could print the test piece below (trylinder_selftap_holes_test.stl) and then fill out the form that would be really helpful.

The easiest way to get the test piece is to right click the raw download link and choose "save link as..." to save to an STL file - gists don't give the files the correct mimetype,

@gnperdue
gnperdue / hdf5_batch_test.py
Last active November 30, 2023 15:42
TensorFlow Dataset `from_generator` reading HDF5
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import os
import h5py
import numpy as np
import tensorflow as tf
# Get path to data
from __future__ import print_function
import PIL.Image
import PIL.ExifTags
import sys
import os
def formatted_exif_data(image):
"""Retrieve an image's EXIF data and return as a dictionary with string keys"""
# with thanks to https://stackoverflow.com/questions/4764932/in-python-how-do-i-read-the-exif-data-for-an-image
exif_data = {}
@revsic
revsic / ConvLSTMCell.py
Last active April 5, 2020 17:06
Tensorflow implementation of Convolutional LSTM
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@omimo
omimo / create_hellotensor.py
Last active September 26, 2023 08:37
A simple example for saving a tensorflow model and preparing it for using on Android
# Create a simple TF Graph
# By Omid Alemi - Jan 2017
# Works with TF <r1.0
import tensorflow as tf
I = tf.placeholder(tf.float32, shape=[None,3], name='I') # input
W = tf.Variable(tf.zeros_initializer(shape=[3,2]), dtype=tf.float32, name='W') # weights
b = tf.Variable(tf.zeros_initializer(shape=[2]), dtype=tf.float32, name='b') # biases
O = tf.nn.relu(tf.matmul(I, W) + b, name='O') # activation / output