Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tanmaykm's full-sized avatar

Tanmay Mohapatra tanmaykm

  • Bangalore, India
View GitHub Profile
# 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 / cv_utils.cpp
Created December 14, 2012 11:44
Separating items in store shelves using OpenCV.
/*
* cv_utils.cpp
*
* Created on: Dec 7, 2012
* Author: tan
* Related blog post at:
* http://sidekick.windforwings.com/2012/12/opencv-separating-items-on-store-shelves.html
*
*/
@tanmaykm
tanmaykm / pywebsock.html
Last active July 25, 2019 09:51
Minimal WebSocket Broadcast Server in Python
<!DOCTYPE html>
<html>
<head>
<title>Websocket Demo</title>
<style>
#messages {
border: dotted 1px #444444;
font: 12px arial,sans-serif;
}
@tanmaykm
tanmaykm / tmq.c
Created May 19, 2012 12:18
Inter Thread Communication: Socketpairs vs. In-Memory Buffers
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
/**
* related blogpost at: http://sidekick.windforwings.com/2012/05/inter-thread-communication-socketpairs.html
@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
@tanmaykm
tanmaykm / sketch_sprinkler.pde
Created August 29, 2011 04:12
Arduino Sprinkler Controller
// Arduino Sprinkler
// Version: 0.4 (beta)
// Updated: 03 Oct 2011
#include <LiquidCrystal.h>
#include <EEPROM.h>
// SWITCHES
// Pin 1 (Learn/Auto)
@tanmaykm
tanmaykm / motion_detect.cpp
Created December 2, 2012 15:38
OpenCV Motion Detection Based Action Trigger
/*
* motion_detect.cpp
* To accompany instructions at:
* http://sidekick.windforwings.com/2012/12/opencv-motion-detection-based-action.html
*
* Created on: Dec 02, 2012
* Author: tan
*
*/
#include <iostream>
@tanmaykm
tanmaykm / julia_daemon.jl
Created April 15, 2014 12:00
Try creating daemon process in Julia
function daemon()
cpid = ccall(:fork, Cint, ())
if cpid != 0
exit()
else
ccall(:setsid, Cint, ())
cpid = ccall(:fork, Cint, ())
if cpid != 0
exit()
@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