Skip to content

Instantly share code, notes, and snippets.

@anj1
anj1 / sarkar_reduc.jl
Last active November 17, 2018 08:29
Reduced, mechanistic model
# This code implements the model outlined in:
# "Design of conditions for emergence of self-replicators"
# by Sarkar, Wang, and England (2018)
# Reduced, one-atom model,
# using 'mechanistic' transition-state modeling
using ChemicalReactionNetworks
using PyPlot
#using ODE
@anj1
anj1 / gist:f9874cef572030535c34cd7a0b2d52fa
Created September 3, 2016 03:04
inception_heatmap.py
from scipy import misc
from scipy.ndimage import filters
import numpy as np
import tensorflow as tf
#from inception import image_processing
from inception import inception_model as inception
#from PIL import Image
#from PIL import ImageFile
@anj1
anj1 / subexpr.py
Last active January 20, 2020 22:41
import types
import tensorflow as tf
import numpy as np
# Expressions are represented as lists of lists,
# in lisp style -- the symbol name is the head (first element)
# of the list, and the arguments follow.
# add an expression to an expression list, recursively if necessary.
def add_expr_to_list(exprlist, expr):
# T: type of underlying data
# N: dimensionality of filter
type ConvolveFilter{T,N}
fk::Array{Complex{T},N}
end
# apply a filter to data.
# If the dimensionality of the data (M) is larger than the filter (N),
# then apply the filter to the first N dimensions of the data.
*{T,N,M}(f::ConvolveFilter{T,N},x::Array{T,M}) = real(ifft(conj(f.fk) .* fft(x,1:N), 1:N))
@anj1
anj1 / lazysort.jl
Last active November 19, 2015 09:06
# Lazy quicksort.
# Can be used to take only the first k elements of the sorted array,
# And will do this 'efficiently'
lazysort{T}(lst::Vector{T}) =
@task begin
if length(lst) == 0 # is sorting trivial?
elseif length(lst) == 1
produce(lst[1])
else
# take pivot element
function forkjulia()
r = ccall((:fork, "libc"), Int32, ())
if r != 0
# parent
returnstatus=0
ccall((:waitpid, "libc"), Int32, (Int32, Ptr{Int32}, Int32), r, &returnstatus, 0)
println("forkjulia: return status: $returnstatus")
end
end