Skip to content

Instantly share code, notes, and snippets.

View shyampurk's full-sized avatar

Shyam Purkayastha shyampurk

View GitHub Profile
@shyampurk
shyampurk / EventCustFeedback-Subscribe
Created February 19, 2018 04:58
Event Customer Feedback Subscribe
function pub_subscribe(){
pubnub.subscribe({
channel : channel_output,
message : function(m){
console.log(m);
message_listing(m);
},
error : function (error) {
console.log(JSON.stringify(error));
}
@shyampurk
shyampurk / EventCustFeedback-FormSubmit
Created February 19, 2018 04:52
Event Customer Feedback Form Submit
function pub_publish(pub_msg){
pubnub.publish({
channel : channel_input,
message : pub_msg,
callback : function(m){
console.log(m);
}
});
};
@shyampurk
shyampurk / eventCustFeecback-PubNubInit
Created February 19, 2018 04:45
Event Customer Feedback PubNub Init
var pubnub = PUBNUB({
publish_key : /* YOUR PUBLISH KEY*/,
subscribe_key : /* YOUR SUBSCRIBE KEY*/
})
@shyampurk
shyampurk / fetch-customer-feedback
Last active February 18, 2018 11:47
Watson-NLC-EventFeedback
db.get(request.message.userMessage).then((database_value)=>{
console.log("FETCHED DATABASE VALUE",database_value);
var feedback = request.message.userMessage; // Extract the feedback from the incoming Message.
fetchUserFeedback(feedback);
console.log(request.message);
});
@shyampurk
shyampurk / rpi-rt-audio-bdcast
Created June 24, 2015 13:47
RPi Realtime Audio Broadcast
def _callback(message,channel):
if message["type"]=="request" :
print" Received message = ", message["play"]
status=subprocess.call(["espeak","-s 120 -v en ",message["play"]], stdout=FNULL, stderr=subprocess.STDOUT)
if status==0 :
pubnub.publish(pubnub_responsechannel, postive_response)
elif status!=0 :
pubnub.publish(pubnub_responsechannel,negative_response)
@shyampurk
shyampurk / pubnubheartrateios-captureframe
Last active October 18, 2017 21:59
PubNub Heart Rate App for iOS
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
// if we're paused don't do anything
if(self.currentState==STATE_PAUSED) {
// reset our frame counter
self.validFrameCounter=0;
return;
}
@shyampurk
shyampurk / pubnubheartrate-algo
Last active October 18, 2017 21:19
Heartrate monitoring using PubNub
private static PreviewCallback previewCallback = new PreviewCallback() {
/**
* {@inheritDoc}
*/
@Override
public void onPreviewFrame(byte[] data, Camera cam) {
if (data == null) throw new NullPointerException();
Camera.Size size = cam.getParameters().getPreviewSize();
if (size == null) throw new NullPointerException();
@shyampurk
shyampurk / pubnub-js-publish
Last active October 18, 2017 19:33
pubnub_iot_tech_uc_1
$('#toggle').click(function(e){
pubmsg = { "req" : "toggle" };
pubnub.publish(
{
channel : 'gpio-raspberry-control' ,
message : pubmsg
import os
import sys
import glob
import dlib
from skimage import io
from skimage.draw import polygon_perimeter
import traceback
# Function to close the dashdb connection
def dbclose(self):
try:
retrn = ibm_db.close(self.connection)
return retrn
except Exception as dbcloseerror:
logging.error("dbclose Exception %s"%(dbcloseerror))
return False