This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void setAdvertiseData() { | |
AdvertiseData.Builder mBuilder = new AdvertiseData.Builder() | |
ByteBuffer mManufacturerData = ByteBuffer.allocate(24); | |
byte[] uuid = getIdAsByte(UUID.fromString("0CF052C297CA407C84F8B62AAC4E9020")); | |
mManufacturerData.put(0, (byte)0xBE); // Beacon Identifier | |
mManufacturerData.put(1, (byte)0xAC); // Beacon Identifier | |
for (int i=2; i<=17; i++) { | |
mManufacturerData.put(i, uuid[i-2]); // adding the UUID | |
} | |
mManufacturerData.put(18, (byte)0x00); // first byte of Major |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.subscribe({ | |
channels: [channel], | |
state: { | |
skill: 2 | |
} | |
}); | |
pubnub.addListener({ | |
status: function(statusEvent) { | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Include the PubNub Library --> | |
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.17.0.js"></script> | |
<!-- Instantiate PubNub --> | |
<script type="text/javascript"> | |
var pubnub = new PubNub({ | |
subscribeKey: 'Unique Subscribe Key Here', | |
publishKey: 'Unique Publish Key Here', | |
ssl: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
topic = "user/path/topic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
// Initialize the PubNub API connection. | |
pubnub = new PubNub({ | |
publishKey : 'PUBNUB PUBLISH KEY HERE', | |
subscribeKey : 'PUBNUB SUBSCRIBE KEY HERE' | |
}) | |
// Grab references for all of our elements. | |
var messageContent = $('#messageContent'), | |
sendMessageButton = $('#sendMessageButton'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"time": "2:07:04pm", | |
"price": "510.83", | |
"delta": "69.02", | |
"perc": "13.51", | |
"vol": 2930 | |
} | |
{ | |
"time": "2:07:06pm", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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().channel(pubnub_responsechannel).message(postive_response).async(publish_callback) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public JSONObject handleHand(Hand hand){ | |
boolean isLeft = hand.isLeft(); | |
String handName = (isLeft) ? "left" : "right"; | |
Vector direction = hand.direction(); | |
int yaw = (int) Math.toDegrees(direction.yaw()); | |
int pitch = (int) Math.toDegrees(direction.pitch()); | |
// Normalize Yaw and Pitch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void cleanup(){ | |
try { | |
JSONObject payload = new JSONObject(); | |
JSONObject left = new JSONObject(); | |
JSONObject right = new JSONObject(); | |
left.put("left_yaw", 400); | |
left.put("left_pitch",400); | |
right.put("right_yaw", 400); | |
right.put("right_pitch",400); | |
payload.put("left_hand", left); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LeapToServo implements Runnable{ | |
//Define Channel name | |
public static final String CHANNEL = "my_channel"; | |
//Create PubNub instance | |
private Pubnub pubnub; | |
//Create Leap Controller instance | |
private Controller controller; | |
//is Runnable running? | |
private boolean running; |