Skip to content

Instantly share code, notes, and snippets.

View shyampurk's full-sized avatar

Shyam Purkayastha shyampurk

View GitHub Profile
@shyampurk
shyampurk / pubnub_parse_container
Last active August 29, 2015 14:14
Parse Authentication Dialog
<div class='overlay' id='auth-overlay'>
<div class="container" id="auth-super">
<div class="row">
<div class="col-sm-6" style="background: #afa6a6;border-radius: 10px;">
<div id="auth-dialog">
<div id="title-section">
<div class="row">
<div class="col-sm-8 col-sm-offset-3"><span><h4>PubNub WebRTC App with Parse</h4></span></div>
@shyampurk
shyampurk / callback-function
Last active August 29, 2015 14:17
pubnub-todoapp-android-1
public void successCallback(String channel, Object message) {
// TODO Auto-generated method stub
super.successCallback(channel, message);
Log.i("Subscribe","SUCCESS"+message.getClass()+" "+message.toString());
try {
Globalvars.isSubscribed = true;
Log.i("Subscribe","SUCCESS sending message"+message.toString());
Intent intent = new Intent(MY_ACTION);
intent.putExtra("message", message.toString());
@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
@shyampurk
shyampurk / backbone-pubnub-1
Last active August 29, 2015 14:20
Backbone integration with PubNub
// Define Backbone Stats model
app.Stat = Backbone.Model.extend({
defaults: {
stats: [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
},
localStorage: new Backbone.LocalStorage("pcm-stat")
});
@shyampurk
shyampurk / famous-basic-addtask
Last active August 29, 2015 14:21
Famo.us basic ToDo app
TaskPanel.prototype.addTask = function addTask(taskObj) {
var that = this;
var pos = this.taskSurfaces.length;
var tempTrans = new TransitionableTransform();
var sizeTrans = new Transitionable([5, 5]);
var opacTrans = new Transitionable(0);
@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 / 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 / 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 / smart-parking
Last active July 22, 2017 00:42
Smart Parking App
/***************************************************************************/
/*PubNub C-Core Initialization*/
pubnub_t *l_receive = pubnub_alloc();
if (NULL == l_receive)
{
printf("Failed to allocate Pubnub context!\n");
return (void *)-1;
}
@shyampurk
shyampurk / weather-infographic
Last active March 11, 2016 20:45
Weather Infographic Gist
function fetch (place, coordinates, i, aggregate) {
async.parallel([
function(callback) {
request
.get('https://maps.googleapis.com/maps/api/timezone/json')
.query('location='+coordinates[1]+','+coordinates[0])
.query({timestamp: Math.floor(new Date().getTime()/1000)})
.query({key: gApiToken})
.end(function(err, res){
if(err) { console.log(err); callback(true); return; }