Skip to content

Instantly share code, notes, and snippets.

View ToeJamson's full-sized avatar

Joe Hanson ToeJamson

  • @observe.ai
  • San Francisco, CA
View GitHub Profile
@ToeJamson
ToeJamson / 1
Created July 15, 2013 21:43
PubShare
pubnub.subscribe({
channel: protocol.CHANNEL,
callback: this.handleSignal.bind(this),
presence: this.handlePresence.bind(this)
});
handlePresence: function (msg) {
var conn = this.connections[msg.uuid];
if (conn) {
// Pass the message to specific contact/connection
(void)pubnubClient:(PubNub *)client didReceiveMessage:(PNMessage *)message {
NSMutableDictionary *groupMessages = [[NSMutableDictionary alloc] init];
[groupMessages setDictionary: [[Globals sharedInstance] groupMess]];
NSMutableDictionary *nameDict = [[NSMutableDictionary alloc] init];
[nameDict setDictionary: [[Globals sharedInstance] nameDict]];
NSMutableString *groupName = [[NSMutableString alloc] init];
@ToeJamson
ToeJamson / Javascript
Created July 17, 2013 18:15
PHP Push API Walkthrough
PUBNUB.subscribe( { channel : 'my_test_channel' },
function(message) {
if ('some_text' in message) {
alert(message.some_text);
}
} );
@ToeJamson
ToeJamson / 1
Last active December 20, 2015 05:58
HTML5 Mass Broadcasting Desktop Notifications
<div
channel-name=notifications-channel
segregate-notifications-by-page=false
id=desktop-notifications-config
></div>
<div id=pubnub pub-key=demo sub-key=demo></div>
<script src=http://cdn.pubnub.com/pubnub-3.1.min.js></script>
<script src=http://www.pubnub.com/static/html5-desktop-notification-broadcasting.js></script>
@ToeJamson
ToeJamson / 1.js
Last active December 20, 2015 21:09
Building Real-Time Geolocation Apps With JavaScript and PubNub
navigator.geolocation.getCurrentPosition(function (position) {
console.log(“I am located at: “ + position.coords.latitude + “, “ + position.coords.longitude);
});
navigator.geolocation.watchPosition(function (position) {
console.log(“I am now located at: “ + position.coords.latitude + “, “ + position.coords.longitude);
});
@ToeJamson
ToeJamson / ClientServer.cs
Last active December 21, 2015 02:18
Creating a C# Game Server
private void HandleMessage(string json) {
Dictionary<string, string> message = ParseJson(json);
Dictionary<string, string> response = new Dictionary<string, string>90;
response["type"] = message["type"];
switch (message["type"]) {
case "login":
if (authorized(message["user"])) {
response["sucess"] = true;
}
break;
@ToeJamson
ToeJamson / HomeAutomation.h
Created August 21, 2013 00:20
Home Automation
void setup() {
Serial.begin(9600);
Ethernet.begin(mac);
PubNub.begin(pubkey, subkey);
}
void loop() {
/* Maintain DHCP lease. */
Ethernet.maintain();
@ToeJamson
ToeJamson / mysql.sql
Created August 29, 2013 16:15
Why Business Intelligence Tools Need a Real-time Service Provider
DELIMITER $$
CREATE PROCEDURE push_message
(p1 DOUBLE,
p2 DOUBLE,
p3 BIGINT)
BEGIN
DECLARE cmd CHAR(255);
DECLARE result CHAR(255);
SET cmd = CONCAT('curl https://pubsub.pubnub.com/publish/demo/demo/0/mysql_triggers/0/%22',p1, ',' ,p2, ',' ,p3,'%22');
SET result = sys_eval(cmd);
@ToeJamson
ToeJamson / 1.js
Created September 5, 2013 21:46
Extend RabbitMQ into the Web using PubNub
{"Depositor":"Randy","Amount":123.00}
@ToeJamson
ToeJamson / 1.h
Created September 16, 2013 18:07
Adding Key-Value Observing to PubNub
[sender addObserver: self
forKeyPath:key
options:NSKeyValueObservingOptionNew
context:NULL];