Skip to content

Instantly share code, notes, and snippets.

@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 / 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>
#!/usr/bin/env python
import argparse
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
import json
#!/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
%
@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, [], []).
% 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
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);
-on_load(init/0).
-module(merger).
-on_load(init/0).
-export([
new/0, new/1, new/2,
out/1,
in/3,
size/1,
@abhi-bit
abhi-bit / regis_server.erl
Created December 14, 2015 09:19
ets simulation
-module(regis_server).
-behaviour(gen_server).
-include_lib("stdlib/include/ms_transform.hrl").
-export([start_link/0, stop/0, register/2, unregister/1, whereis/1,
get_names/0, lookup/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
code_change/3, terminate/2]).
start_link() ->
@abhi-bit
abhi-bit / cb_set.py
Created September 24, 2015 08:24
set to cb using file from disk
import sys
import json
import random
import string
from couchbase import Couchbase
from couchbase import FMT_JSON
host = sys.argv[1]
bucket = sys.argv[2]