This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function foo(x::Vector{Number}) = println(x) | |
| # Will only be callable with Array{Number}, | |
| # but not with any subtype of number like Array{Int} | |
| function foo{T <: Number}(x::Vector{T}) = println(x) | |
| # Will be callable with every Array | |
| function foo{T <: Vector{Z <: FloatingPoint}}(x::Vector{T}) = println(x) | |
| # Doesn't exist :( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import VideoIO | |
| using GLPlot, React, GLAbstraction | |
| device = VideoIO.DEFAULT_CAMERA_DEVICE | |
| format = VideoIO.DEFAULT_CAMERA_FORMAT | |
| camera = VideoIO.opencamera(device, format) | |
| img = VideoIO.read(camera) | |
| # Just for fun, lets apply a laplace filter: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GLPlot | |
| xx=[1 2 3 4; | |
| 1 2 3 4; | |
| 1 2 3 4]; | |
| yy=[2 2 2 2;4 4 4 4;6 6 6 6] | |
| vals=ones(3,4) | |
| colorf(m)="xyz.z>0 ? vec4(.2,.4,0.5+"string(m)"*xyz.z,0.98) : vec4(.2,.4-"*string(1.2m)"*xyz.z,0.5,0.98);" # <- forgot * | |
| function glupdatewindow(obj,window) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Test1 | |
| tic() | |
| using FixedSizeArrays | |
| elapsed_time = toq() | |
| println("loading time FixedSizeArrays: ", elapsed_time) | |
| immutable RGB{T} <: AbstractFixedVector{T, 3} | |
| r::T | |
| g::T | |
| b::T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FixedSizeArrays | |
| importall Base | |
| export AbstractFixedArray | |
| export AbstractFixedVector | |
| export AbstractFixedMatrix | |
| export cross | |
| export norm | |
| export unit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro DSL(name, text) | |
| tokens = dsltokenizer(DSLTokens{name}(), text)::DSLTokens{name} | |
| dslast = generate_ast(tokens)::AST{name} | |
| return dsl(dslast)::AST{:Julia} | |
| end | |
| #Overwrite any of these stages, to implement your own DSL | |
| dsltokenizer(::DSLTokens, text) = ... | |
| generate_ast(text::DSLTokens) = ... | |
| dsl(ast::AST) = ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Version 1, if you really need to access the counters via a name | |
| type CountersDict | |
| counters::Dict{Symbol, Array{Int64}} | |
| end | |
| function CountersDict() | |
| CountersDict([ | |
| :counter1 => zeros(Int64, 100000), | |
| :counter2 => zeros(Int64, 100000), | |
| :counter3 => zeros(Int64, 100000), | |
| :counter4 => zeros(Int64, 500), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| immutable Functor{FuncName} end | |
| #with staged functions available in 0.4: | |
| #= | |
| stagedfunction evaluate{NumArgs,FuncName}(::Functor{FuncName}, args::NTuple{NumArgs}) | |
| args_expr = map(1:NumArgs) do x | |
| :(args[$x]) | |
| end | |
| :($FuncName($(args_expr...))) | |
| end | |
| =# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Romeo, GLFW, GLAbstraction, Reactive, ModernGL, GLWindow, Color | |
| function init_romeo() | |
| sourcecode_area = lift(Romeo.ROOT_SCREEN.area) do x | |
| Rectangle(0, 0, div(x.w, 7)*3, x.h) | |
| end | |
| visualize_area = lift(Romeo.ROOT_SCREEN.area) do x | |
| Rectangle(div(x.w,7)*3, 0, div(x.w, 7)*3, x.h) | |
| end | |
| search_area = lift(visualize_area) do x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| immutable StandardChunk | |
| i32::Int32 | |
| i64::Int64 | |
| i8::Int8 | |
| end | |
| immutable ByteBuffer{Chunk} | |
| data::Vector{Chunk} | |
| ptr::Ptr{Int8} | |
| end | |
| ByteBuffer{T}(data::Vector{T}) = ByteBuffer{T}(data, convert(Ptr{Int8}, pointer(data))) |