Skip to content

Instantly share code, notes, and snippets.

@dristic
dristic / webrtc.js
Last active October 24, 2023 21:52
Full code from my WebRTC Data Channel post.
// Fix Vendor Prefixes
var IS_CHROME = !!window.webkitRTCPeerConnection,
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription;
if (IS_CHROME) {
RTCPeerConnection = webkitRTCPeerConnection;
RTCIceCandidate = window.RTCIceCandidate;
RTCSessionDescription = window.RTCSessionDescription;
@dristic
dristic / 1.js
Last active January 20, 2022 18:46 — forked from ToeJamson/1.js
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);
});
@dristic
dristic / index.html
Last active August 3, 2020 11:49
Initial chat page for PubNub Messenger Tutorial.
<!-- Chat Page -->
<div data-role="page" id="chatPage" data-theme="c" class="type-interior">
<div data-role="content">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>Pub Messenger</h1>
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview" id="messageList">
@dristic
dristic / index.html
Created May 29, 2013 00:10
Adding presence to PubNub Messenger.
<div data-role="page" id="chatPage" data-theme="c" class="type-interior">
<div data-role="content">
<div class="content-primary">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>Pub Messenger</h1>
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview" id="messageList">
@dristic
dristic / index.html
Created May 20, 2013 23:12
Header section for PubNub Messenger.
<head>
<title>PubNub Messenger</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon href=icon.png">
<link rel="apple-touch-startup-image href=startup.png">
@dristic
dristic / controllers.application.js
Created September 16, 2016 20:08
Ember Render Test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
foo: [],
init: function () {
let arr = [];
for (let i = 0; i < 1000; i++) {
arr.push('Test' + Math.random());
@dristic
dristic / main.js
Created August 28, 2013 22:04
PubNub basic publish
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
pubnub.subscribe({
channel: "myChannel",
callback: function (message) {
console.log("I got the message: " + message);
},
@dristic
dristic / collection.js
Last active December 21, 2015 18:29
Code snippets for integrating Backbone with PubNub via http://github.com/pubnub/backbone
var MyCollection = Backbone.PubNub.Collection.extend({
name: 'MyCollection',
pubnub: pubnub
});
@dristic
dristic / pubnub-based.js
Created July 31, 2013 18:21
WebRTC Data Channel Examples.
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
// Here is where you can use PubNub Presence to get the UUID of the other user
// var uuid = 'ABC123'
pubnub.subscribe({
user: uuid, // This tells PubNub to use WebRTC Data Channel
@dristic
dristic / messenger.appcache
Created June 3, 2013 20:30
PubNub Messenger appcache.
CACHE MANIFEST
# 2013-05-13:v1.3.2
# Explicitly cached master entries.
CACHE:
index.html
css/screen.css
img/pw_pattern.png
js/messenger.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css