Skip to content

Instantly share code, notes, and snippets.

View wsphillips's full-sized avatar
🧠

Wiktor Phillips wsphillips

🧠
  • Cambridge, MA, USA
  • 11:59 (UTC -04:00)
View GitHub Profile
@wsphillips
wsphillips / pyto.jl
Created December 12, 2019 22:44
Pytographic ordering algorithm
using Test
# Reference pattern for N = 13; should be able to generalize pattern to any int N
index1=[
1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,4,5,6,7,8,9,10,11,12,13,13,13,13,13,13,13,13,13,
13,13,13,13,12,11,10,9,8,7,6,5,4,3,2,2,2,2,2,2,2,2,2,2,2,2,3,4,5,6,7,8,9,10,11,
12,12,12,12,12,12,12,12,12,12,12,11,10,9,8,7,6,5,4,3,3,3,3,3,3,3,3,3,3,4,5,6,7,
8,9,10,11,11,11,11,11,11,11,11,11,10,9,8,7,6,5,4,4,4,4,4,4,4,4,5,6,7,8,9,10,10,
10,10,10,10,10,9,8,7,6,5,5,5,5,5,5,6,7,8,9,9,9,9,9,8,7,6,6,6,6,7,8,8,8,7,7]
# This caused the first breaking change. Precompilation fails after commit 99d2406c98a720e9f9e555109297b577232a01a4
# Result is identical to that reported in CUDAnative.jl at https://github.com/JuliaLang/julia/issues/32074
signal (11): Segmentation fault
in expression starting at none:0
jl_is_submodule at /home/wikphi/julia-src/src/module.c:706
module_in_worklist at /home/wikphi/julia-src/src/dump.c:227 [inlined]
type_in_worklist at /home/wikphi/julia-src/src/dump.c:238 [inlined]
jl_serialize_value_ at /home/wikphi/julia-src/src/dump.c:982
@wsphillips
wsphillips / implot_demo.jl
Last active May 22, 2020 14:54
Demo of CImPlot working with CImGui.jl
using CImGui
using CImGui.CSyntax
using CImGui.CSyntax.CStatic
using CImGui.GLFWBackend
using CImGui.OpenGLBackend
using CImGui.GLFWBackend.GLFW
using CImGui.OpenGLBackend.ModernGL
using Printf
using CEnum
using CImPlot_jll
@wsphillips
wsphillips / imgui_imagedisplay.jl
Last active July 7, 2020 21:54
CImGui.jl : Attempt to load and display a random array of numbers as an image
using CImGui
using CImGui.CSyntax
using CImGui.CSyntax.CStatic
using CImGui.GLFWBackend
using CImGui.OpenGLBackend
using CImGui.GLFWBackend.GLFW
using CImGui.OpenGLBackend.ModernGL
using Printf
import CImGui.OpenGLBackend.ModernGL: glGenTextures
@wsphillips
wsphillips / hh_mtk.jl
Last active October 22, 2020 23:33
Hodgkin-Huxley single compartment with ModelingToolkit.jl
using DifferentialEquations, ModelingToolkit, Plots
# Channel gating functions
αn(V) = (0.01*(V + 55))/(1 - exp(-(V + 55)/10))
βn(V) = 0.125 * exp(-(V + 65)/80)
αm(V) = (0.1*(V + 40))/(1 - exp(-(V + 40)/10))
βm(V) = 4*exp(-(V + 65)/18)
αh(V) = 0.07*exp(-(V+65)/20)
βh(V) = 1/(1 + exp(-(V + 35)/10))
@wsphillips
wsphillips / twoneurons.jl
Last active October 24, 2020 19:11
HH two neurons coupled using MTK
using DifferentialEquations, ModelingToolkit, Plots, OrdinaryDiffEq
# Channel gating functions
αn(V) = (0.01*(V + 55))/(1 - exp(-(V + 55)/10))
βn(V) = 0.125 * exp(-(V + 65)/80)
αm(V) = (0.1*(V + 40))/(1 - exp(-(V + 40)/10))
βm(V) = 4*exp(-(V + 65)/18)
αh(V) = 0.07*exp(-(V+65)/20)
βh(V) = 1/(1 + exp(-(V + 35)/10))
@wsphillips
wsphillips / implotstyle.jl
Last active March 24, 2021 19:07
Rough method to modify C struct fields
# in libcimplot_api.jl
function GetStyle()
ccall((:ImPlot_GetStyle, libcimplot), Ptr{ImPlotStyle}, ())
end
# elsewhere...
# This could have mistakes, and will need tweaking but gets the idea across
@wsphillips
wsphillips / liflayer.jl
Last active November 17, 2022 20:42
Flux LIF neuron
using Flux, Distributions
# Layer for LIF neurons:
struct LIFNeurons
dt
W_inputs # size(in) array input weights
W_rex_inputs # length(in)xlength(in) array recurrent excitation weights
tau_mem
tau_syn
end
@wsphillips
wsphillips / hand_stgneuron.jl
Created February 13, 2023 23:16
Naive Turing setup
_softmax(x,y) = log(exp(x) + exp(y))
# Steady-state functions
# Input vectors
V0 = -50.0
u0 = zeros(Float64, 13)
p = zeros(Float64, 8)
# Initial state