Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaac Virshup ivirshup

View GitHub Profile
@ivirshup
ivirshup / scrolling-sidebar_rtd.css
Created Apr 6, 2016
Lets the sidebar scroll separately from the content. Pretty useful for docs.julialang.org
View scrolling-sidebar_rtd.css
.wy-nav-side {
float: left;
overflow: scroll;
max-height: 100%;
}
@ivirshup
ivirshup / pmap_do_error.jl
Last active Apr 27, 2016
Error using `pmap(_) do x`
View pmap_do_error.jl
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
auto_unbox error weirdness
View auto_unbox-error.jl
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
`bus error` and `StackOverflowError` examples
View auto_unbox-error2.jl
_
_ _ _(_)_ | 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
Error that occurs with `using LightGraphs; using Gadfly`
View lightgraphs-gadfly_error
_
_ _ _(_)_ | 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
`counter` function slowdown using parameterized methods
View counter_wo_parameters.jl
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
`counter` function slowdown using parameterized methods
View counter_w_parameters.jl
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
Function to completely flatten nested arrays in julia. Surprisingly efficient.
View flattenall.jl
function flattenall(a::AbstractArray)
while any(x->typeof(x)<:AbstractArray, a)
a = collect(Base.flatten(a))
end
return a
end
View Untitled-2.html
<!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
Error requiring Plots after LightGraphs.
View index.html
<!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>