Skip to content

Instantly share code, notes, and snippets.

View Gnimuc's full-sized avatar
🍤

Yupei Qi Gnimuc

🍤
  • Tokyo
  • 02:13 (UTC +09:00)
  • X @Gnimuc
View GitHub Profile
@Gnimuc
Gnimuc / test.jl
Created November 17, 2015 04:23
[SO] Multiple selection from Julia array
function foo(genconv, I, J)
genconv[sub2ind(size(genconv),I,J)]
end
function bar(genconv, I, J)
diag(sub(genconv, I, J))
end
function baz(genconv, I, J)
[genconv[i,j] for (i,j) in zip(I, J)]
end
# load dependency packages
using GLFW, ModernGL
# set up OpenGL context version
@osx_only const VERSION_MAJOR = 4 # it seems OSX will stuck on OpenGL 4.1.
@osx_only const VERSION_MINOR = 1
# initialize GLFW library, error check is already wrapped.
GLFW.Init()
@Gnimuc
Gnimuc / test.jl
Created October 4, 2015 09:26
[SO] Assign the object reference not the object
type Chain
value :: Int
right :: Chain
left :: Chain
#Make the last link in the chain point to itself
#so as to spare us from the julia workaround for nulls
Chain(value::Int) = (chain = new(); chain.value = value; chain.right = chain; chain.left = chain; chain)
end