Skip to content

Instantly share code, notes, and snippets.

@ihnorton
ihnorton / tractography-display-widget-svnpatch.diff
Created May 17, 2011 13:27
tractography display widget patch
Index: Libs/MRML/vtkMRMLFiberBundleNode.cxx
===================================================================
--- Libs/MRML/vtkMRMLFiberBundleNode.cxx (revision )
+++ Libs/MRML/vtkMRMLFiberBundleNode.cxx (working copy)
@@ -52,7 +52,7 @@ vtkMRMLNode* vtkMRMLFiberBundleNode::CreateNodeInstance()
//----------------------------------------------------------------------------
void vtkMRMLFiberBundleNode::PrintSelf(ostream& os, vtkIndent indent)
{
-
+
@ihnorton
ihnorton / thermo_convert.py
Created September 7, 2011 17:03
Example script to convert Thermo RAW file using msfilereader accessed via python ctypes.
#!/home/inorton/bin/pywin
import comtypes, comtypes.client
from ctypes import *
from comtypes.automation import *
import sys
import numpy
# GetMassListFromScanNum(long FAR* pnScanNumber, LPCTSTR szFilter,
# long nIntensityCutoffType, long nIntensityCutoffValue,
# long nMaxNumberOfPeaks, BOOL bCentroidResult,
@ihnorton
ihnorton / gist1
Last active December 11, 2015 20:09
julia> using cindex; tu = tu_init("Index.h")
Ptr{Void} @0x00000000034586c0
julia> cu = ccall( (:test_cu1, "../lib/libwrapcindex"), CXCursor, (Ptr{Void},), tu)
hash out: b540fa27 kind out: 300
CXCursor(300,0,Ptr{Void} @0x0000000002c12b40,Ptr{Void} @0x0000000000000001,Ptr{Void} @0x00000000034586c0)
julia> ccall( (:test_cu2, "../lib/libwrapcindex"), Void, (CXCursor,), cu)
hash in: c8e83387 kind in: 6
@ihnorton
ihnorton / example output
Last active December 13, 2015 22:09
Julia callback upon Python object finalization
julia> require("test.jl")
Julia code
lfile PyPtr address: Ptr{Void} @0x000000000361d390
Julia code
weakref address: Ptr{Void} @0x0000000003622f70
Julia code: calling decref
C code: cb_wrapper
self: 0
arg: 3622f70
Julia code:
@ihnorton
ihnorton / ccall_macro.jl
Last active December 14, 2015 10:49
Julia snippets
macro c(ret_type, func, arg_types, lib)
args_in = Any[ symbol(string("a",x)) for x in 1:length(arg_types.args) ]
quote
$(esc(func))($(args_in...)) = ccall( ($(string(func)), $lib), $ret_type, $(arg_types), $(args_in...) )
end
end
julia> @c Ptr{Void} wci_createCursorList () "../lib/libwrapcindex"
# methods for generic function wci_createCursorList
wci_createCursorList() at none:5
@ihnorton
ihnorton / create libSodium.jl
Last active December 14, 2015 15:09
libsodium wrapper
```julia
julia> ENV["JULIAHOME"] = "/cmn/git/julia"
"/cmn/git/julia"
julia> clang_includes = map(x->joinpath(ENV["JULIAHOME"], x), [
"deps/llvm-3.2/build/Release/lib/clang/3.2/include",
"deps/llvm-3.2/include",
"deps/llvm-3.2/include",
"deps/llvm-3.2/build/include/",
"deps/llvm-3.2/include/"
@ihnorton
ihnorton / libav.jl
Last active December 14, 2015 18:09 — forked from timholy/threelibs.jl
recurs_sym_type(ex::Any) =
(ex==None || typeof(ex)==Symbol || length(ex.args)==1) ? eval(ex) : Expr(ex.head, ex.args[1], recurs_sym_type(ex.args[2]))
macro c(ret_type, func, arg_types, lib)
local _arg_types = Expr(:tuple, [recurs_sym_type(a) for a in arg_types.args]...)
local _ret_type = recurs_sym_type(ret_type)
local _args_in = Any[ symbol(string('a',x)) for x in 1:length(_arg_types.args) ]
local _lib = eval(lib)
quote
$(esc(func))($(_args_in...)) = ccall( ($(string(func)), $(Expr(:quote, _lib)) ), $_ret_type, $_arg_types, $(_args_in...) )
@ihnorton
ihnorton / test
Created March 26, 2013 05:12
test...
julia> for i=1:cl.size
cu = cl[i]
is_virt = bool(cindex.CXXMethod_isVirtual(cu))
is_stat = bool(cindex.CXXMethod_isStatic(cu))
vtidx = ""
if(is_virt) vtidx = wrap_cpp.method_vt_index(cu) end
println(rpad(i,6), rpad(is_virt,6), rpad(vtidx,6), name(cu) )
end
1 false
@ihnorton
ihnorton / bits.jl
Last active December 15, 2015 12:29
Bits of useful Julia code
# find, chomp, split, and return a list of matching files
[splitdir(splitext(chomp(x))[1])[2] for x in readlines(`sh -c "ls /usr/lib/libvtk*.so"`)]
julia> macro m1()
quote
function $(esc(:f1))(a1, a2)
ccall( fptr, thiscall, Void, (Ptr{Void},Ptr{Void}), a1, a2)
end
@ihnorton
ihnorton / ConeOutline.png
Last active December 15, 2015 14:29
tempfiles
ConeOutline.png