Skip to content

Instantly share code, notes, and snippets.

View llandsmeer's full-sized avatar
💡

Lennart Landsmeer llandsmeer

💡
View GitHub Profile
@llandsmeer
llandsmeer / Dockerfile
Created October 17, 2022 14:48
Arbor GUI in the browser via noVNC
# docker build -t arbor-gui . && docker run -it -p 5999:5999 arbor-gui
# then visit http://localhost:5999/vnc.html?host=localhost&port=5999&autoconnect=true
FROM ubuntu:latest
EXPOSE 5999
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
ENV TZ=Europe/Amsterdam
RUN apt-get update && apt-get install -y xvfb x11vnc wget novnc git wmctrl
# git clone --depth 1 --recursive --branch=SDE 'https://github.com/boeschf/arbor'
# cd arbor ; mkdir build ; cd build
# cmake -DCMAKE_INSTALL_PREFIX=$(realpath prefix) -DARB_USE_BUNDLED_LIBS=ON -DARB_WITH_PYTHON=ON ..
# make -j 12 && make install
import sys
import importlib.util
import os.path
#### IF INSTALLED USING PIP:
import os.path
import numpy as np
import re
import subprocess
import tempfile
import arbor
from math import sqrt
import matplotlib.pyplot as plt
ARBOR_BUILD_CATALOGUE = 'arbor-build-catalogue'
import sympy as sm
import lark
parser = lark.Lark(r'''
%import common.SIGNED_NUMBER -> NUMBER
%import common.WS
%ignore WS
%ignore /\?.*\n/
%ignore /:.*\n/
@llandsmeer
llandsmeer / ledfxmidi.py
Created September 23, 2022 22:37
Control LedFX using midi controller
import os
import time
import json
import requests
import rtmidi
# pip install python-rtmidi
midi = rtmidi.MidiIn()
ports = midi.get_ports()
import sys
import pyte
import struct
import select
import time
import fcntl
import os
import pty
import subprocess
import termios
@llandsmeer
llandsmeer / pyqt5_numpy.py
Created May 28, 2022 11:25
pyqt5 show numpy arrays in a loop
import sys
import numpy as np
from PyQt5 import QtGui, QtWidgets, QtCore
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.imshow = Grayscale()
self.setCentralWidget(self.imshow)
self.update_timer = QtCore.QTimer()
@llandsmeer
llandsmeer / iocell.py
Created April 14, 2022 16:46
interactive io in qt
import matplotlib.pyplot as plt
import numba
import numpy as np
@numba.jit(fastmath=True, cache=True, nopython=True)
def simulate(skip_initial_transient_seconds=0, sim_seconds=10, delta=0.005, record_every=20,
# Parameters
g_int = 0.13, # Cell internal conductance -- now a parameter (0.13)
p1 = 0.25, # Cell surface ratio soma/dendrite
p2 = 0.15, # Cell surface ratio axon(hillock)/soma
@llandsmeer
llandsmeer / documentation.md
Last active March 7, 2023 12:48
libfive studio examples in python
  • Shape(ptr)
  • array_polar(shape, n, center=(0, 0))

    Iterates a shape about an optional center position

  • array_polar_z(shape, n, center=(0, 0))

    Iterates a shape about an optional center position

  • array_x(shape, nx, dx)

    Iterates a part in a 1D array

  • array_xy(shape, nx, ny, delta)

    Iterates a part in a 2D array

  • array_xyz(shape, nx, ny, nz, delta)
@llandsmeer
llandsmeer / hh.py
Created April 9, 2022 16:46
Hogkin-Huxley minimal sim
# Adapted from https://hodgkin-huxley-tutorial.readthedocs.io/en/latest/_static/Hodgkin%20Huxley.html
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
C_m = 1.0
g_Na = 120.0