Skip to content

Instantly share code, notes, and snippets.

View vtjnash's full-sized avatar

Jameson Nash vtjnash

View GitHub Profile
@vtjnash
vtjnash / actor_centrality.jl
Created August 15, 2012 02:35 — forked from SirVer/actor_centrality.jl
Actor centrality in Julia
type Node
name::UTF8String
sn::Set{Node}
n::Vector{Node} #this is assigned later, as an efficiently iterable copy of sn
Node(name) = new(name, Set{Node}())
end
typealias Graph Dict{UTF8String, Node}
@vtjnash
vtjnash / macro_local_demo.jl
Created October 24, 2012 05:30
julia macro local variable expression
macro foo(ex)
quote
$(esc(ex))
end
end
function f(x,y)
@foo x+y
end
@vtjnash
vtjnash / streams
Created December 8, 2012 04:21 — forked from Keno/streams
Howto and overview of new I/O system:
Using spawn and run
-------------------
Commands are specified with backticks as before:
julia> `echo test`
`echo test`
@vtjnash
vtjnash / gist:4993365
Last active December 13, 2015 23:39
mac-gtk build for distribution for julia
#/bin/sh
# This script will attempt to download and build GTK+-2,
# including dependencies (cairo, pango, etc), in ~/gtk
# (it also puts stuff in ~/.local, ~/Source, ~/.jhbuildrc*)
# While this should work, it may be preferable to execute
# each line separately in the terminal to catch errors
# MAKE SURE YOU DO NOT HAVE BREW OR MACPORTS IN YOUR PATH
# BEFORE RUNNING THIS SCRIPT. e.g.:
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$
PortSystem 1.0
PortGroup github 1.0
github.setup JuliaLang julia 0
name julia
version 0
categories lang
@vtjnash
vtjnash / gist:5542706
Created May 8, 2013 18:53
windows 32-bit openblas test failures
These test failures are seen on the current release and develop version of openblas. The make command used is shown below.
```
$ make CC="i686-w64-mingw32-gcc" FC="i686-w64-mingw32-gfortran" RANLIB="i686-w64-mingw32-ranlib" FFLAGS=" -O2 " USE_THREAD=1 DYNAMIC_ARCH=1 NUM_THREADS=30 OSNAME=WINNT CROSS=1 BINARY=32 FLDFLAGS="-Wl,--stack,0x1000000"
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat1
Real BLAS Test Program Results
Test of subprogram number 1 SDOT
FAIL

Debugging Build and Running Errors

This is a collection of things to try and steps to debugging on Windows.

Have you checked the build errata?

Have you searched the Julia issues for similar issues?

The message Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks. is generated whenever Julia is about to crash. Most commonly, it will appear when the program is segfaulting due to a NULL / invalid pointer. It can be the fault of anything, so without instructions on how to reproduce, it is difficult to impossible to fix.

@vtjnash
vtjnash / blaswrap2.c
Created June 25, 2013 03:11
clang -fPIC blaswrap.c -o blaswrap.o -DUSE_BLASWRAP -c
/*
Copyright (C) 2011 Jarno Rajahalme
Copyright (C) 2013 Jameson Nash
This is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
@vtjnash
vtjnash / ccall cfunction.md
Last active December 27, 2015 08:29
cfunction/ccall proposal

This Julip is intendend to standardize and simplify the ccall/cfunction calling convention specifications, with minimal breakage from the current situation.

The intention is to supply a more descriptive ccall/cfunction interface that is faster to parse for humans, and can accurately reflect all c-callable functions with less ambiguity/confusion.
As a special requirement, all elements of this should be valid syntax outside of the ccall function. The purpose of this is to simplify code-generation macros and reduce the learning curve.
There are several, fairly independent parts to this proposal. I will try to enumerate them in order of their dependencies.

.1. Move the Julia value pointer (jl_value_t*) to point to the first element of the Julia struct, instead of the type tag. This has been discussed previously (and demonstrated in prototype) and is not controversial. ref JuliaLang/julia#2818

.2. Introduce a function Box(x) that creates a mutable jl_value_t* containing a single pointer (to X). re

julia> code_typed(Ito.Time.yearfraction,(Ito.Time.ISMAActualActual,Calendar.CalndarTime,CalendarTime,CalendarTime,CalendarTime))
1-element Array{Any,1}:
:($(Expr(:lambda, {:c,:d_start,:d_end,:ref_start,:ref_end}, {{:newRefEnd,:newRefStart,:#s1133,:ref_period_start,:ref_period_end,:mnths,:period,:previousRef,:i,:sum},{{:c,ISMAActualActual,0},{:d_start,CalendarTime,0},{:d_end,CalendarTime,0},{:ref_start,CalendarTime,0},{:ref_end,CalendarTime,0},{:newRefEnd,Any,18},{:newRefStart,Any,18},{:#s1133,Bool,2},{:ref_period_start,CalendarTime,2},{:ref_period_end,Any,2},{:mnths,Int64,2},{:period,Float64,18},{:previousRef,CalendarTime,18},{:i,Int64,2},{:sum,Any,2}},{}}, :(begin # /Users/jameson/.julia/Ito/src/time/day_count.jl, line 162:
unless top(eq_float)(top(getfield)(d_start::CalendarTime,:millis)::Float64,top(getfield)(d_end::CalendarTime,:millis)::Float64)::Bool goto 0 # line 162:
return 0.0
0: # line 164:
unless top(lt_float)(top(getfield)(d_end::CalendarTime,:millis)::Float64,to