Skip to content

Instantly share code, notes, and snippets.

View tanmaykm's full-sized avatar

Tanmay Mohapatra tanmaykm

  • Bangalore, India
View GitHub Profile
@tanmaykm
tanmaykm / stacktrace.md
Created March 31, 2017 02:03
AMQPClient.jl issue
signal (15): Terminated
while loading /home/tan/.julia/v0.6/AMQPClient/test/test_throughput.jl, in expression starting on line 13
subtype at /data/Work/julia/sources/julia/src/subtype.c:687
exists_subtype at /data/Work/julia/sources/julia/src/subtype.c:867 [inlined]
forall_exists_subtype at /data/Work/julia/sources/julia/src/subtype.c:895
jl_subtype_env at /data/Work/julia/sources/julia/src/subtype.c:948
simple_join at /data/Work/julia/sources/julia/src/subtype.c:261
simple_join at /data/Work/julia/sources/julia/src/subtype.c:247 [inlined]
var_gt at /data/Work/julia/sources/julia/src/subtype.c:396
@tanmaykm
tanmaykm / JuliaRunPackageBundles.md
Created March 7, 2017 09:20
JuliaRun Doc Snippets

Julia packages go through a process called compilation on their first use, where the Julia code is compiled to llvm bytecode. The bytecode is cached, and re-used thus making subsequent use faster. Package bundles are special disk volumes that hold Julia packages. They help prepare packages once and use them uniformly across many many containers. They are pre-compiled by a special PkgBuilder job and are mounted as read only volumes to containers that use them. That ensures that when your code starts to use them they are alerady compiled. They are mounted read-only to ensure that they are not modified inadvertendly by some user code.

Preparing a package bundle involves the exact same steps as installaing and loading a package in the Julia REPL, essentially - Pkg.add(...), Pkg.build(...), and using .... Let's say you wish to build a package bundle with these packages: JSON and Distributions. And you wish to call your package bundle mypkg.

  • Create a volume for it: `~/.julia/v0.5/JuliaRun/scripts/loc
# context: http://stackoverflow.com/questions/39448808/julia-tcp-server-and-connection
# Use fn to process messages from sock.
# Loop till sock is open and fn returns true.
function processor(fn, sock)
proc = true
try
while proc && ((nb_available(sock) > 0) || isopen(sock))
proc = fn(sock)
end
@tanmaykm
tanmaykm / hea.jl
Created May 19, 2016 13:07
WFDB parser
using Base.Dates
const DEFREQ = 250.
const DEFGAIN = 200.
immutable Record
name::AbstractString
nsegments::Int
nsignals::Int
sampfreq::Float64
@tanmaykm
tanmaykm / zmqtest.jl
Created February 15, 2016 09:59
zmq leak test
#const ENDPOINT = "tcp://localhost:9875"
const ENDPOINT = "ipc:///tmp/testZMQ";
const pid = getpid();
const MSG = "abcdefghijklmnopqrstuvwxyz";
vsz() = parse(Int, split(open(readstring,`ps -p $pid -o vsz`),"\n")[2]);
vsz(s) = println(s, vsz())
vsz("Initial VSZ=");
using ZMQ
@tanmaykm
tanmaykm / compare.md
Last active January 3, 2016 02:13
kmeans & als parallel mode comparisons
@tanmaykm
tanmaykm / perfbreeze.scala
Created October 18, 2015 09:25
scala perf for Julia micro benchmarks
import scala.util._
import java.io._
import breeze.linalg._
import breeze.numerics._
import breeze.stats._
import breeze.math._
object PerfBreeze {
final val NITER = 5
@tanmaykm
tanmaykm / small_demo.jl
Last active October 6, 2015 14:01
Twitter link graph
using Elly
using HadoopBlocks
@everywhere begin
#const INP = "hdfs://root@" * string(getipaddr()) * ":9000/twitter_rv.net"
#const COLSEP = '\t'
const INP = "hdfs://root@" * string(getipaddr()) * ":9000/twitter_small.csv"
# const YARNHOST = string(getipaddr()
#const INP = "hdfs://tan@localhost:9000/twitter_small.csv"
const COLSEP = ','
@tanmaykm
tanmaykm / wshed.jl
Last active August 29, 2015 14:19
simple watershed
using Images, Color, FixedPointNumbers, ImageView
impath = joinpath(Pkg.dir("TestImages"), "images/lena_gray_512.tif")
img = imread(impath);
mask = copy(img);
mask.data[1:end] = 1;
marks = falses(size(img.data));
#view(img)
#view(mask)
@tanmaykm
tanmaykm / buffon.jl
Created April 9, 2015 15:55
Monte Carlo Pi
function buffon_one()
mp = rand()
phi = (rand() * pi) - pi / 2
xrechts = mp + cos(phi)/2
xlinks = mp - cos(phi)/2
xrechts >= 1 || xlinks <= 0
end
function buffon(m)
hit = 0