Skip to content

Instantly share code, notes, and snippets.

View MariuszWisniewski's full-sized avatar

Mariusz Wisniewski MariuszWisniewski

View GitHub Profile
// The function below is used for notification/subscription processing of the position of the note.
// When the position of the note is moved across one device, all other devices connected to Syncano will real-time sync to the same position.
updatePosition: function (element) {
var self = this;
var position = element.position();
var xPos = Math.round(position.left);
var yPos = Math.round(position.top);
var noteId = self.findNote(element.attr('id'));
self.syncano.sendRequest({
type: 'call',
@MariuszWisniewski
MariuszWisniewski / SyncanoCommunication.m
Last active August 29, 2015 14:01
Creating New Data Object in Syncano
@interface SyncanoCommunication : NSObject
@property (strong, nonatomic) Syncano *syncano;
- (void)sendText:(NSString *)text image:(UIImage *)image;
@end
@implementation SyncanoCommunication
@interface SyncanoCommunication : NSObject
@property (strong, nonatomic) SyncanoSyncServer *syncServer;
- (void)openSyncServerConnection;
- (void)subscribeToCollectionChanges;
- (void)sendMessage:(NSString *)message;
@end
@MariuszWisniewski
MariuszWisniewski / SYNViewController.m
Last active August 29, 2015 14:05
Using Sync Server Basics
//
// SYNViewController.h
// syncserver-ios-test
//
#import <UIKit/UIKit.h>
@interface SYNViewController : UIViewController
@end
1)
var syncano = SyncanoConnector.getInstance();
syncano.connect( {instance: 'YOUR-INSTANCE-NAME', api_key: 'YOUR-API-KEY'}, function(auth) {
console.log("Connected")
});
2)
syncano.Data.new( PROJECT-ID, 'Default', {title: "My title"}, function() {
<!doctype html>
<html>
<script src="http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"></script>
<script src="http://cdn.jsdelivr.net/syncanojs/3.1.3beta/syncano.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js"></script>
<head></head>
<body>
@MariuszWisniewski
MariuszWisniewski / Syncano-v3-getOne.js
Last active August 29, 2015 14:25
Get one object from Syncano (v3)
function GetOne(DATA_ID) {
var callback = {};
callback.success = function(data) {
console.log('Get one with ID ' + DATA_ID + ' titled: ' + data.title);
};
callback.error = function(data) {
console.log('Get One Fail! - ' + data);
console.log(data);
//this function uses callback object, containing sucess and error functions inside it
function GetOne_Callback_Object(DATA_ID) {
//define callback object
var callback = {};
//add to id success function - will be called on succesful calls
callback.success = function(data) {
console.log('Get one with ID ' + DATA_ID + ' titled: ' + data.title);
};
@MariuszWisniewski
MariuszWisniewski / create-objects.m
Last active November 23, 2015 01:00
Item creation in Syncano
//following defined in SCConstants.h
typedef NS_ENUM(NSUInteger, SCDataObjectPermissionType) {
SCDataObjectPermissionTypeNone,
SCDataObjectPermissionTypeRead,
SCDataObjectPermissionTypeWrite,
SCDataObjectPermissionTypeFull,
};
// ...
@MariuszWisniewski
MariuszWisniewski / Info.plist
Created December 17, 2015 12:20
Apple Transport Security short term fix
//need to add this:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>cloudfront.net</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>