Skip to content

Instantly share code, notes, and snippets.

View stephenlb's full-sized avatar
😀
Coding with Rust

Stephen Blum stephenlb

😀
Coding with Rust
View GitHub Profile
@stephenlb
stephenlb / 1.java
Created November 15, 2017 21:06 — forked from domadev812/1.java
How to Build an Android Beacon (iBeacon) Emitter [3/3]
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
@stephenlb
stephenlb / 1.js
Created November 15, 2017 21:06 — forked from domadev812/1.js
Random Matchmaking (MemeWarz 5)
pubnub.subscribe({
channels: [channel],
state: {
skill: 2
}
});
pubnub.addListener({
status: function(statusEvent) {
},
@stephenlb
stephenlb / PubNubKeys.html
Created November 15, 2017 21:06 — forked from domadev812/PubNubKeys.html
Sample PubNub Keys
<!-- 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
@stephenlb
stephenlb / 1.py
Created November 15, 2017 21:06 — forked from domadev812/1.py
topic = "user/path/topic"
@stephenlb
stephenlb / messenger.js
Created November 15, 2017 21:06 — forked from domadev812/messenger.js
pubnub messenger v2
$(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'),
@stephenlb
stephenlb / 1.json
Created November 15, 2017 21:06 — forked from domadev812/1.json
Data Streams over WebSockets and HTTP Long Polling Protocols
{
"time": "2:07:04pm",
"price": "510.83",
"delta": "69.02",
"perc": "13.51",
"vol": 2930
}
{
"time": "2:07:06pm",
@stephenlb
stephenlb / rpi-rt-audio-bdcast
Created November 15, 2017 21:06 — forked from domadev812/rpi-rt-audio-bdcast
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().channel(pubnub_responsechannel).message(postive_response).async(publish_callback)
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
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);
@stephenlb
stephenlb / Main.java
Created November 15, 2017 21:06 — forked from domadev812/Main.java
Leap Motion - R Pi Remote Control Hands Edits
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;