Skip to content

Instantly share code, notes, and snippets.

@quinnj
quinnj / Manifest.toml
Created September 28, 2018 05:58
Compiler hang
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[BinaryProvider]]
deps = ["Libdl", "Pkg", "SHA", "Test"]
git-tree-sha1 = "48c147e63431adbcee69bc40b04c3f0fec0a4982"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.0"
[[CSV]]
@quinnj
quinnj / Dockerfile.base
Created July 5, 2018 13:46
Base Julia Dockerfile
FROM debian:stretch-slim
# Create the home directory for the new user.
RUN mkdir -p /home/default
# Create an default user so our program doesn't run as root.
RUN groupadd -r default &&\
useradd -r -g default -d /home/default -s /sbin/nologin -c "Docker image user" default
# Set the home directory to our default user's home.
ENV HOME=/home/default
call plug#begin('~/.config/nvim/plugged')
Plug 'morhetz/gruvbox'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'JuliaEditorSupport/julia-vim'
Plug 'cespare/vim-toml'
Plug 'tpope/vim-fugitive'
Plug 'ararslan/license-to-vim'
call plug#end()
const BYTES = fill(false, 128)
BYTES[Int(',')] = true
BYTES[Int('\n')] = true
BYTES[Int('\r')] = true
const COMMA = UInt8(',')
const NEWLINE = UInt8('\n')
const RETURN = UInt8('\r')
@quinnj
quinnj / gist:3ab5f31305d5f76056e2e7b79b2b58c3
Created October 10, 2017 03:16
Pure julia float parsing
const EXPONENTS = [
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,
1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39,
1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49,
1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59,
1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69,
1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79,
1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88, 1e89,
"""
Base.selectorbytes(A::Array{T, N}) -> Array{UInt8, N}
For an Array with `isbits` Union elements, return the "selector bytes" that indicate the
index of the type for each array element, i.e. the type of `A[1]` is
`Base.uniontypes(eltype(A))[Base.selectorbytes(A)[1] + 1]`.
**NOTE**: The actual array selector bytes are returned, meaning if individual elements
are modified, the original array will reflect those changes. Setting selector bytes to
invalid or out-of-bounds type indexes may corrupt the original array.
"""
@quinnj
quinnj / iuab.jl
Last active July 21, 2017 03:24
isbits Union array benchmark
julia> function f(v::Vector{Int8}, n)
s = Int8(0)
@inbounds for i = 1:n
s += v[i]
end
return s
end
f (generic function with 2 methods)
julia> function f(v::Vector{Union{Void, Int8}}, n)
@quinnj
quinnj / gist:38ec81c770bed6291391
Created October 15, 2015 22:09
Potential Julia tabular data structure
type Table{T} <: Source
schema::Schema
index::Vector{Int}
ints::Vector{NullableVector{Int}}
floats::Vector{NullableVector{Float64}}
ptrstrings::Vector{NullableVector{PointerString}}
strings::Vector{NullableVector{UTF8String}}
dates::Vector{NullableVector{Date}}
datetimes::Vector{NullableVector{DateTime}}
any::Vector{NullableVector{Any}}
@quinnj
quinnj / gist:bb1b5d8170301801c012
Last active August 29, 2015 14:24
Base String Performance Benchmarks
### Micro performance benchmarks
# Results Data
## String Type | Benchmark | DateTime Run |
## Julia Version | Strings.jl Version |
## Time Elapsed | Bytes Allocated | GC Time
# reload("Strings")
results = Dict("String Type"=>ASCIIString[],
"String Length"=>Int[],
@quinnj
quinnj / juliacon2015.jl
Last active August 29, 2015 14:23
Managing Data in Julia: Old Tricks, New Tricks Code
Pkg.clone("https://github.com/quinnj/Mmap.jl")
Pkg.clone("https://github.com/quinnj/CSV.jl")
Pkg.add("ODBC")
Pkg.checkout("SQLite","jq/remodel")
Pkg.add("SQLite")
Pkg.checkout("SQLite","jq/updates")
reload("Mmap")
reload("CSV")