Skip to content

Instantly share code, notes, and snippets.

View StefanKarpinski's full-sized avatar

Stefan Karpinski StefanKarpinski

View GitHub Profile
@StefanKarpinski
StefanKarpinski / threadzmq.c
Created April 8, 2014 02:26
thread communication with ZMQ
// gcc -shared -fPIC -I$JULIAHOME/usr/include -L$JULIAHOME/usr/lib -lzmq -luv -o libthreadzmq.so threadzmq.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <math.h>
#include <zmq.h>
#include <uv.h>
julia> s = sprint() do io
println(io, "hello")
println(io, "world"
end
"hello\nworld\n"
JULIA test/all
From worker 2: * core
From worker 3: * numbers
From worker 2: * strings
exception on 1: ERROR: read: end of file
in read at iobuffer.jl:54
in read at stream.jl:373
in anonymous at task.jl:804
From worker 2: exception on 2: ERROR: read: end of file
From worker 2: in read at iobuffer.jl:54
Eight miles deep the well forgotten by mortals
Oh, I drank it empty in one single sip
Eight miles wide the valley beyond all hope
Oh, I filled the whole with one single fist
Five million christians on a ride towards us
Oh, I slaughtered the bunch with one single hit with my spear
Five million women so alone in the night
Oh, I had them all satisfied profusely every night by myself
julia> (+) = 1
1
julia> +
1
@unix_only begin
const path_separator = "/"
const path_separator_regex = r"/+"
const path_absolute_regex = r"^/"
const path_parse_regex = r"^(.*?/|)([^/]+?)(\.[^\.]+|)$"
splitdrive(path::String) = ("",path)
end
@windows_only begin
const path_separator = "\\"
splitpath => path to array of parts
joinpath => array of parts to path
parsepath(path) => (dir,base,ext)
parsepath(path,ext) => (dir,base,ext)
parsepath(path,regex) => (dir,base,ext)
stdpath(path) => standardize path, removing extraneous dots
abspath(path) => make absolute, relative to current dir
realpath(path) => resolve all symlinks
abstract Path
@unix_only begin
const separator = "/"
const separator_regex = r"/+"
end
@windows_only begin
const separator = "\\"
const separator_regex = r"[/\\]"
end
type DataVec{T} <: AbstractDataVec{T}
data::Vector{T}
na::BitVector
# Sanity check that new data values and missingness metadata match
function DataVec(data::Vector{T}, na::BitVector)
if length(data) != length(na)
error("data and NA vectors not the same length!")
end
new(data,na)
julia> quote
for i in 1:n
x[i] ~ Bernoulli(p)
end
p ~ Beta(alpha, beta)
alpha = 1.0
beta = 1.0
end
quote # line 2: