Skip to content

Instantly share code, notes, and snippets.

Eric Davies iamed2

  • Invenia Technical Computing
  • Winnipeg, MB, Canada
View GitHub Profile
@iamed2
iamed2 / make-project-toml.jl
Created Apr 3, 2019
Generate an almost-right Project.toml file from a REQUIRE file in Julia 1.0 <= VERSION < 1.1-
View make-project-toml.jl
using Pkg
function imports(pkg_dir::AbstractString)
imported = Set{String}()
for (root, dirs, files) in walkdir(pkg_dir)
for file in files
if endswith(file, ".jl")
union!(imported, open(imports, joinpath(root, file)))
end
end
@iamed2
iamed2 / Benchmarking
Last active May 30, 2018
How to write a GroupBy iterator: bad and good (requires IterTools at branch ed/iterate)
View Benchmarking
julia> @benchmark collect(groupby2(first, ["face", "foo", "bar", "book", "baz"]))
BenchmarkTools.Trial:
memory estimate: 1.98 KiB
allocs estimate: 60
--------------
minimum time: 14.258 μs (0.00% GC)
median time: 15.473 μs (0.00% GC)
mean time: 16.915 μs (0.00% GC)
maximum time: 207.366 μs (0.00% GC)
--------------
@iamed2
iamed2 / eltype-overhaul (b4eb5c6)
Created Sep 23, 2016
Iterators.jl performance comparison on Julia 0.4
View eltype-overhaul (b4eb5c6)
Benchmarking Take1 ...
Take1 with cfg = 4096: nruns = 28955, elapsed = 1.516598519 secs
Take1 with cfg = 16384: nruns = 6217, elapsed = 1.307575089 secs
Take1 with cfg = 65536: nruns = 1252, elapsed = 1.152236431 secs
Take1 with cfg = 262144: nruns = 266, elapsed = 0.905467819 secs
Take1 with cfg = 1048576: nruns = 91, elapsed = 1.172819189 secs
Benchmarking Take2 ...
Take2 with cfg = 4096: nruns = 24779, elapsed = 1.368126555 secs
Take2 with cfg = 16384: nruns = 6403, elapsed = 1.47713414 secs
Take2 with cfg = 65536: nruns = 926, elapsed = 0.909415618 secs
@iamed2
iamed2 / Sudoku.jl
Created May 17, 2015
Sudoku solver written at !!con!
View Sudoku.jl
module Sukano
using JuMP
function sudoku_setup()
m = Model()
@defVar(m, 0 <= board[1:9,1:9,1:9] <=1, Int)
# each square can only have one value
@addConstraint(m, squareconst[i=1:9,j=1:9], sum(board[i,j,:]) == 1)
@iamed2
iamed2 / partition.jl
Created Aug 18, 2014
Partition a collection into two collections using a predicate
View partition.jl
function partition(f::Function, collection)
u = similar(collection)
v = similar(collection)
for el in collection
if f(el)
push!(u, el)
else
push!(v, el)
end
View mlss14 stan model
data {
int<lower=1> N_ages;
vector[N_ages] ages;
int K[N_ages];
int N[N_ages];
}
transformed data {
vector[N_ages] mu;
mu <- rep_vector(0, N_ages);
@iamed2
iamed2 / juliabuild
Created Dec 18, 2013
Complete build log from `emerge -av julia`.
View juliabuild
 * Package: dev-lang/julia-9999
 * Repository: science
 * Maintainer: sci
 * USE: amd64 doc elibc_glibc kernel_linux userland_GNU
 * FEATURES: preserve-libs sandbox
>>> Unpacking source...
Cloning into '/usr/portage/distfiles/egit-src/julia.git'...
remote: Counting objects: 80880, done.
remote: Compressing objects: 0% (1/26694) 
remote: Compressing objects: 1% (267/26694) 
@iamed2
iamed2 / segfault_bt_sysimg.txt
Last active Dec 21, 2015
Segfaults during bootstrap (sysimg.jl). Built with `make debug`. The error was not fixed with clean or cleanall.
View segfault_bt_sysimg.txt
Revision d3117e2cd4fc85db6019fff875c84591fc20cd77
/bin/sh: line 1: 29933 Segmentation fault: 11 /usr/local/julia/usr/bin/julia-release-readline -bf sysimg.jl
*** This error is usually fixed by running 'make clean'. If the error persists, try 'make cleanall'. ***
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff53e3f9d in ?? ()
(gdb) bt
#0 0x00007ffff53e3f9d in ?? ()
#1 0x000000000236f160 in ?? ()
You can’t perform that action at this time.