Skip to content

Instantly share code, notes, and snippets.

View ivirshup's full-sized avatar
💭
🫠

Isaac Virshup ivirshup

💭
🫠
View GitHub Profile
@ivirshup
ivirshup / scrolling-sidebar_rtd.css
Created April 6, 2016 16:08
Lets the sidebar scroll separately from the content. Pretty useful for docs.julialang.org
.wy-nav-side {
float: left;
overflow: scroll;
max-height: 100%;
}
@ivirshup
ivirshup / pmap_do_error.jl
Last active April 27, 2016 19:45
Error using `pmap(_) do x`
julia> addprocs(1)
1-element Array{Int64,1}:
2
julia> pmap([rand(2) for i in 1:2]) do x
map(typeof, x)
end
2-element Array{Any,1}:
[Float64,Float64]
[Float64,Float64]
@ivirshup
ivirshup / auto_unbox-error.jl
Created May 2, 2016 14:39
auto_unbox error weirdness
julia> using Combinatorics
julia> function foo()
ts = filter(x->isa(x, DataType), map(eval, names(Base)))
for x in ts
end
permutations(ts, 2)
end
foo (generic function with 1 method)
@ivirshup
ivirshup / auto_unbox-error2.jl
Created May 2, 2016 14:54
`bus error` and `StackOverflowError` examples
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0-dev+3825 (2016-05-01 18:02 UTC)
_/ |\__'_|_|_|\__'_| | Commit 89775a5 (0 days old master)
|__/ | x86_64-apple-darwin15.4.0
julia> function foo()
@ivirshup
ivirshup / lightgraphs-gadfly_error
Last active May 4, 2016 16:49
Error that occurs with `using LightGraphs; using Gadfly`
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0-dev+3875 (2016-05-04 06:47 UTC)
_/ |\__'_|_|_|\__'_| | Commit 90de028 (0 days old master)
|__/ | x86_64-apple-darwin15.4.0
julia> using LightGraphs # Requires throws error, but running it again after seems to work fine
@ivirshup
ivirshup / counter_wo_parameters.jl
Created May 11, 2016 22:27
`counter` function slowdown using parameterized methods
julia> import Base.push!
julia> import Base.getindex
julia> type Accumulator{T, V<:Number}
map::Dict{T,V}
end
julia> Accumulator{T,V<:Number}(::Type{T}, ::Type{V}) = Accumulator{T,V}(Dict{T,V}())
@ivirshup
ivirshup / counter_w_parameters.jl
Last active May 11, 2016 22:53
`counter` function slowdown using parameterized methods
julia> import Base.push!
julia> import Base.getindex
julia> type Accumulator{T, V<:Number}
map::Dict{T,V}
end
julia> Accumulator{T,V<:Number}(::Type{T}, ::Type{V}) = Accumulator{T,V}(Dict{T,V}())
Accumulator{T,V<:Number}
@ivirshup
ivirshup / flattenall.jl
Created May 19, 2016 20:46
Function to completely flatten nested arrays in julia. Surprisingly efficient.
function flattenall(a::AbstractArray)
while any(x->typeof(x)<:AbstractArray, a)
a = collect(Base.flatten(a))
end
return a
end
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Untitled</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
@ivirshup
ivirshup / index.html
Last active May 24, 2016 01:03
Error requiring Plots after LightGraphs.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Untitled</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>