Skip to content

Instantly share code, notes, and snippets.

View ephe-meral's full-sized avatar
🏗️
...building the future

Johanna Appel ephe-meral

🏗️
...building the future
View GitHub Profile
import numpy as np
# ...
def relu(activations):
'''Sample 'ReLU' activation function for illustration purposes'''
return np.maximum(activations, 0)
def forward(model, batch, input_size, hidden_size, activation=relu, iterations=2):
'''Push a batch of input vectors (in rows) through an adjacency matrix (the 'model').
@ephe-meral
ephe-meral / median.ex
Last active August 8, 2020 18:30
Median of sorted array in one line of Elixir
# Simple no-branching version of a list median
# Expects the list to contain at least one element, and be sorted already
fn(l) -> (Enum.at(l, floor((length(l)-1)/2)) + Enum.at(l, ceil((length(l)-1)/2)))/2 end
# or
fn(l) -> (length(l)-1)/2 |> &(&(Enum.at(l, floor(&1)) + Enum.at(l, ceil(&1)))/2).() end
# or
def median(list) do
(length(list)-1)/2
! Fork from: http://paste.factorcode.org/paste?id=808
! Copyright (C) 2009 Tim Wawrzynczak
! See http://factorcode.org/license.txt for BSD license.
USING: kernel namespaces sequences accessors
joy.ast joy.parser joy.pprint vectors
combinators math assocs math.ranges random
quotations prettyprint math.functions
calendar math.order macros generalizations fry
parser words stack-checker ;
@ephe-meral
ephe-meral / gist:cb38b77d6876c024f3c5e90bb2abee17
Created June 16, 2017 18:06
continous latex build (using entr, mupdf, tectonic)
echo 'yourfile(s).tex' | entr -s 'tectonic ueb9_1.tex && pkill -HUP mupdf'
def find_many(list, funs), do: do_find_many(list, funs |> Enum.map(&({&1, nil})))
defp do_find_many([h | t], funs, acc) do
new_funs = funs |> Enum.map(
fn {fun, nil} -> if fun.(h), do: {fun, h}, else: {fun, nil}
other -> other
end)
if Enum.any?(new_funs, fn {_, x} -> is_nil(x) end), do: t, else: []
|> do_find_many(new_funs)
end
Unchecked dependencies for environment test:
* vmq_commons (Hex package)
could not find an app file at _build/test/lib/vmq_commons/ebin/vmq_commons.app. This may happen if the dependency was not yet compiled, or you specified the wrong application name in your deps, or the dependency indeed has no app file (then you can pass app: false as option)
** (Mix) Can't continue due to errors on dependencies
@ephe-meral
ephe-meral / pickling-test.scala
Last active December 24, 2015 00:09
Pickling 0.8.0-SNAPSHOT fails with out-of-mem error when trying to compile this...
import scala.pickling._
import json._
package testclasses {
sealed trait A
case class A1(b: B) extends A
case class A2(b: B) extends A
case class A3(b: B) extends A
case class A4(ab: Array[B]) extends A