Skip to content

Instantly share code, notes, and snippets.

View powers.h
long double powers[] = {1.0e0L, 1.0e1L, 1.0e2L, 1.0e3L, 1.0e4L, 1.0e5L, 1.0e6L, 1.0e7L,
1.0e8L, 1.0e9L, 1.0e10L, 1.0e11L, 1.0e12L, 1.0e13L, 1.0e14L, 1.0e15L,
1.0e16L, 1.0e17L, 1.0e18L, 1.0e19L, 1.0e20L, 1.0e21L, 1.0e22L, 1.0e23L,
1.0e24L, 1.0e25L, 1.0e26L, 1.0e27L, 1.0e28L, 1.0e29L, 1.0e30L, 1.0e31L,
1.0e32L, 1.0e33L, 1.0e34L, 1.0e35L, 1.0e36L, 1.0e37L, 1.0e38L, 1.0e39L,
1.0e40L, 1.0e41L, 1.0e42L, 1.0e43L, 1.0e44L, 1.0e45L, 1.0e46L, 1.0e47L,
1.0e48L, 1.0e49L, 1.0e50L, 1.0e51L, 1.0e52L, 1.0e53L, 1.0e54L, 1.0e55L,
1.0e56L, 1.0e57L, 1.0e58L, 1.0e59L, 1.0e60L, 1.0e61L, 1.0e62L, 1.0e63L,
1.0e64L, 1.0e65L, 1.0e66L, 1.0e67L, 1.0e68L, 1.0e69L, 1.0e70L, 1.0e71L,
1.0e72L, 1.0e73L, 1.0e74L, 1.0e75L, 1.0e76L, 1.0e77L, 1.0e78L, 1.0e79L,
@quinnj
quinnj / gist:eb25a3f7493aab6cb450707c83f0b170
Created Jun 23, 2020
CSV.jl inference issue w/ generated function
View gist:eb25a3f7493aab6cb450707c83f0b170
] add CSV#jq/lazystrings
using CSV
source = joinpath(dirname(pathof(CSV)), "../randoms.csv")
header = 1
normalizenames = false
datarow = -1
skipto = nothing
footerskip = 0
limit = typemax(Int64)
transpose = false
View ScopedEnums.jl
module ScopedEnums
using StructTypes
export @scopedenum
macro scopedenum(T, args...)
blk = esc(:(
module $(Symbol("$(T)Module"))
using StructTypes
@quinnj
quinnj / gist:40e989a28e3ee0138ff61d00b6d75313
Created Mar 25, 2020
Example of background thread workers for spawned tasks
View gist:40e989a28e3ee0138ff61d00b6d75313
module Workers
const WORK_QUEUE = Channel{Task}(0)
macro async(thunk)
esc(quote
tsk = @task $thunk
# the next line passes along task-local storage to the spawned task
# may not be desirable in all use-cases
tsk.storage = current_task().storage
View BinaryTrees.jl
module BinaryTrees
mutable struct Node{K, T}
value::K
data::T
left::Union{Node, Nothing}
right::Union{Node, Nothing}
end
Node(x) = Node(typemax(UInt) >> 1, x, nothing, nothing)
Node(x, data) = Node(x, data, nothing, nothing)
View gist:0b2bc3f1ac0965a56d8afd3468c244d5
rowitr = Tables.Map(x->(id=x.id, y=x.salary*2), df);
rowitr = Tables.Map(fff, df);
T = typeof(rowitr)
state = iterate(rowitr)
row, st = state
nms = Tuple(propertynames(row))
len = Base.haslength(T) ? length(rowitr) : 0
sch = Tables.Schema(nms, nothing)
columns = Tuple(Tables.EmptyVector(len) for _ = 1:length(nms))
updated = Ref{Any}(columns)
View gist:712821c3718ac434af466d5775a238c6
module Foo
delimlen(delim::UInt8) = 1
delimlen(delim::Tuple{Ptr{UInt8}, Int}) = delim[2]
checkdelim(delim::UInt8, b, buf, pos, eof) = delim == b
@inline function checkdelim(delim::Tuple{Ptr{UInt8}, Int}, b, buf, pos, eof)
startptr = pointer(buf, pos)
if pos + delim[2] <= eof
match = memcmp(startptr, delim[1], delim[2])
if match
View output.jl
julia> code_typed(DataFrame, (typeof(m),); debuginfo=:source)
1-element Array{Any,1}:
CodeInfo(
1 ─── goto #3 if not false
2 ─── nothing::Nothing
3 ┄── %3 = π (false, Const(false, false))
└──── goto #5 if not %3
4 ─── nothing::Nothing
5 ┄── %6 = (DataFrames.applicable)(DataFrames.iterate, x)::Bool
└──── goto #61 if not %6
View Manifest.toml
[[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 Jul 5, 2018
Base Julia Dockerfile
View Dockerfile.base
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
You can’t perform that action at this time.