Skip to content

Instantly share code, notes, and snippets.

ERL_NIF_TERM
merger_nif_heap_put(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
merger_nif_heap_t* mh = NULL;
ErlNifBinary keyBin, valBin;
int ret;
merger_item_t* item = (merger_item_t *) enif_alloc(sizeof(merger_item_t));
if (!item)
return merger_make_error(env, MERGER_ATOM_INTERNAL_ERROR);
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
@abhi-bit
abhi-bit / gen_server_msg.erl
Last active January 19, 2016 11:13 — forked from vmx/gen_server_msg.erl
Receiving messages in gen_server
-module(gen_server_msg).
-behaviour(gen_server).
-export([start/0, msg/1, msg_recv/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
#!/usr/bin/env escript
%% -*- Mode: Erlang; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
%%! -smp enable
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
#!/usr/bin/env python
import argparse
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
import json
@abhi-bit
abhi-bit / v8_nested_map.cc
Created July 28, 2016 12:05
Trying to expose nested map from C++ to JS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <include/v8.h>
@abhi-bit
abhi-bit / sample.out
Last active September 8, 2016 09:47
V8 based JS Debugger
debug_testing.ccmain312STARTING UP Process thread
debug_testing.ccProcessRequest190
2016-09-08.15:05:39ProcessDebugUserRequest{"type": "json", "client": "Chrome Canary", "counter":0}
"Logged from JS world" "Chrome Canary" 0
debug_testing.ccProcessRequest190
2016-09-08.15:05:39ProcessDebugUserRequest{"type": "json", "client": "Chrome Canary", "counter":1}
"Logged from JS world" "Chrome Canary" 1
debug_testing.ccProcessRequest190
2016-09-08.15:05:39ProcessDebugUserRequest{"type": "json", "client": "Chrome Canary", "counter":2}
"Logged from JS world" "Chrome Canary" 2
@abhi-bit
abhi-bit / heap_oom.cc
Created September 23, 2016 10:40
Allocation failed - Javascript heap out of memory
#include <cassert>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <include/v8.h>
@abhi-bit
abhi-bit / client.c
Created November 7, 2016 05:32
Go to C communication
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uv.h>
uv_loop_t *loop;
void on_connect(uv_connect_t *req, int status);
void on_write_end(uv_write_t *req, int status);
void echo_read(uv_stream_t *server, ssize_t nread, const uv_buf_t *buf);
@abhi-bit
abhi-bit / a.go
Last active January 29, 2017 15:37
package a
import (
"log"
"time"
"github.com/abhi-bit/tools/eventing/circular_dependency/b"
"github.com/abhi-bit/tools/eventing/circular_dependency/c"
)