Skip to content

Instantly share code, notes, and snippets.

View neeraj9's full-sized avatar
🎯
Focusing

Neeraj neeraj9

🎯
Focusing
  • Microsoft
View GitHub Profile
@neeraj9
neeraj9 / nlp_microsoft_luis-response.json
Created March 29, 2018 09:42
BeamParticle Intent Analysis via Microsoft Luis Sample Result
{
"entities": [
{
"endIndex": 25,
"entity": "europe",
"score": 0.986519933,
"startIndex": 20,
"type": "builtin.geography.continent"
}
],
@neeraj9
neeraj9 / nlp_microsoft_luis-1.json
Created March 29, 2018 09:39
BeamParticle Intent Analysis via Microsoft Luis Configuration
{
"endpoint": "00000000-0000-0000-0000-000000000000",
"key": "00000000000000000000000000000000"
}
@neeraj9
neeraj9 / nlp_microsoft_luis.erl.fun
Last active March 29, 2018 09:34
BeamParticle Intent Analysis via Microsoft Luis
#!erlang
%% @doc Intent Analysis via Microsoft Luis
%%
%% run nlp_microsoft_luis(<<"I want to travel to Europe. Can you give me possible locations?">>)
%%
fun(Msg) ->
%% The json configuration must be set for this function (TBD)
Config = beamparticle_dynamic:get_config(),
Endpoint = erlang:binary_to_list(maps:get(<<"endpoint">>, Config)),
Key = erlang:binary_to_list(maps:get(<<"key">>, Config)),
@neeraj9
neeraj9 / py_10_min_to_pandas.py.fun
Created March 28, 2018 06:39
BeamPartile - 10 minutes to pandas, so lets have some fun
#!python
# @doc 10 minutes to pandas, so lets have some fun
#
# py_10_min_to_pandas
#
# see https://pandas.pydata.org/pandas-docs/stable/10min.html
# see https://gist.github.com/neeraj9/970e73412a893ddaed7be31e84199c29
#
# Dependencies:
#
@neeraj9
neeraj9 / py_test_stdout_stderr_with_exceptiuon.java.fun
Created March 21, 2018 07:52
BeamParticle Java Dynamic function for /post/ HTTP POST JSON handler with sample logs and exception
#!java
// Sample Java 8 function to return what was passed in as the first argument.
// Notice that this template works for the /post/<thisfun> interface, where
// json input is passed in the first argument postBody, while the response
// is a binary or a string, which must be json as well.
// Additionally, this function can be used to test stdout and stderr logs.
import java.nio.charset.StandardCharsets;
import com.ericsson.otp.erlang.OtpErlangAtom;
@neeraj9
neeraj9 / py_test_stdout_stderr_with_exceptiuon.py.fun
Created March 21, 2018 03:33
BeamParticle Python Dynamic function for /post/ HTTP POST JSON handler with sample logs and exception
#!python
#
# py_test_stdout_stderr_with_exceptiuon
#
# Author: Neeraj Sharma
"""
Demonstrate logging via stdout and stderr. Take special note of
usage of traceback, which gives very nicely formatted call
traceback in case of errors.
@neeraj9
neeraj9 / beamparticle_test_http_post.sh
Created February 6, 2018 05:11
BeamParticle script for testing HTTP POST interface
#!/bin/sh
#
# The dynamic function (in this case with name function_name) can be tested
# via the https interface (standard interface where websocket is also exposed).
curl --insecure -X POST -H ‘content-type: application/json’ -d ‘{“msg”: “hello”}’ \
-u ‘root:root’ https://localhost:8282/post/function_name
# Alternatively, there is a fast interface which supports a minimal HTTP/1.1
# server. This is very useful for high performance although implements
@neeraj9
neeraj9 / beamparticle_http_post_json.efe
Created February 6, 2018 02:46
BeamParticle Efene Dynamic function for /post/ HTTP POST JSON handler
#!efene
#_ "A sample efene code to return what was passed in as the first argument."
#_ "Notice that this template works for the /post/<thisfun> interface, where"
#_ "json input is passed in the first argument postBody, while the response"
#_ "is a binary or a string, which must be json as well."
#_ ""
#_ "Read about Efene at efene.org"
#_ "see http://efene.org/language-introduction.html"
#_ ""
#_ "Author: Neeraj Sharma <neeraj.sharma@alumni.iitg.ernet.in>"
@neeraj9
neeraj9 / beamparticle_http_post_json.erl
Last active February 9, 2019 22:28
BeamParticle Erlang Dynamic function for /post/ HTTP POST JSON handler
#!erlang
%% Sample Erlang (OTP-20) function to return what was passed in as the first argument.
%% Notice that this template works for the /post/<thisfun> interface, where
%% json input is passed in the first argument postBody, while the response
%% is a binary or a string, which must be json as well.
fun (Body, Context) ->
DecodedMap = jiffy:decode(Body, [return_maps]),
%% TODO process decoded_map
Result = DecodedMap,
@neeraj9
neeraj9 / beamparticle_http_post_json.ex
Last active February 9, 2019 22:27
BeamParticle Elixir Dynamic function for /post/ HTTP POST JSON handler
#!elixir
# Sample Python 3 function to return what was passed in as the first argument.
# Notice that this template works for the /post/<thisfun> interface, where
# json input is passed in the first argument postBody, while the response
# is a binary or a string, which must be json as well.
fn (body, context) ->
decoded_map = :jiffy.decode(body, [:return_maps])
# TODO process decoded_map
result = decoded_map