Skip to content

Instantly share code, notes, and snippets.

View MariuszWisniewski's full-sized avatar

Mariusz Wisniewski MariuszWisniewski

View GitHub Profile
@MariuszWisniewski
MariuszWisniewski / custom_response.py
Created December 17, 2015 15:47
Custom responses in CodeBoxes
#HTML response CodeBox
content = "<html>\
<head>\
</head>\
<body>\
<p>Welcome from Syncano Webhook!</p>\
<p><a href=\"https://www.syncano.io/\">Visit our website</a></p>\
<p>You're inside an instance named {instance}</p>\
<p>Watch \"Stop Building the Backend\" talk by our Developer Evangelist Kelly Andrews</p>\
//
// TestQuestions.swift
// TestWarningsSwift
//
// Created by Mariusz Wisniewski on 2/2/16.
// Copyright © 2016 Mariusz Wisniewski. All rights reserved.
//
import Foundation
import syncano_ios
array = [1,2,3,4,5,6,7,8,9]
dictionary = {
"status" : "OK",
"message" : "Visit us",
"url" : "https://www.syncano.io",
"array" : array
}
content = JSON.stringify(dictionary)
class Book : SCDataObject {
var title = ""
var subtitle = ""
// add SCFile property as any other property on your class
var cover : SCFile? = nil
}
class MyClass {
func sendImage() {
content = "<html>\
<head>\
</head>\
<body>\
<p>Welcome from Syncano Webhook!</p>\
<p><a href=\"https://www.syncano.io/\">Visit our website</a></p>\
<p>You're inside an instance named {instance}</p>\
<p>Watch \"Stop Building the Backend\" talk by our Developer Evangelist Kelly Andrews</p>\
<p><iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/zKLMc4ZoQJo\" frameborder=\"0\" allowfullscreen></iframe></p>\
</body>\
content = "<html>\
<head>\
<meta http-equiv=\"Refresh\" content=\"0; url=https://www.syncano.io/\" />\
</head>\
<body>\
<p>Please follow <a href=\"https://www.syncano.io/\">this link</a>.</p>\
</body>\
</html>"
redirectResponse = HttpResponse(status_code=302, content=content, content_type='text/html');
import requests
import time
client_id = ""
client_secret = ""
limit = 10
default_what = "sushi"
what = ARGS["POST"].get("what","")
let syncano = Syncano(apiKey: "API-KEY", instanceName: "INSTANCE-NAME")
func printError(error: NSError?) {
guard let error = error else {
return
}
let userInfo = error.userInfo
let syncanoError = userInfo[kSyncanoResponseErrorKey]
let detail = syncanoError?["detail"]
class Author {
var name = ""
init(name: String) {
self.name = name
}
}
class Book {
var author : Author? = nil
import requests
import json
# I'll use direct API call, to show the logic of it - I don't want to cloud it with how certain libraries might work
# we check if the user_key was passed to the webhook
user_key = ARGS["POST"].get("user_key","")
if not user_key:
user_key = ARGS["GET"].get("user_key","")