Skip to content

Instantly share code, notes, and snippets.

João Parreira jparreira

View GitHub Profile
jparreira / iot_to_realtime.js
Last active Dec 14, 2015
AWS Lambda function that send a message through the Realtime Messaging Platform
View iot_to_realtime.js
var https = require('https');
exports.handler = function(event, context) {
var appkey = 'YOUR_REALTIME_APPKEY';
var privatekey = 'YOUR_REALTIME_PRIVATEKEY';
var channel = 'aws-iot';
var message = JSON.stringify(event);
var postBody = "AK=" + appkey + "&PK=" + privatekey + "&C=" + channel + "&M=" + message;
var headers = {
jparreira / migration.js
Created Sep 14, 2015
Creates and copies table items from one Realtime Cloud Storage app key to another
View migration.js
var Realtime = require("realtime-storage");
var fromSR;
var toSRCreate;
var toSRCopy;
// Creates destination table and copies items from origin table
function migrate(fromAppKey, fromPrivateKey, toAppKey, toPrivateKey, table)
jparreira / index.html
Created Apr 14, 2015
Copying items from a Realtime Cloud Storage table to another table (with the same key schema)
View index.html
<!DOCTYPE html>
<script src=""></script>
<script src="migration.js"></script>
<h1>Realtime Cloud Storage: Copy items
jparreira / app.js
Created Apr 8, 2015
Retrieving todo items from Realtime Cloud Storage using the REST API from Appcelerator Titanium. This sample can be used with
View app.js
var win1 = Titanium.UI.createWindow({
var label1 = Titanium.UI.createLabel({
text:'Connecting to Realtime Storage...',
jparreira / HEADtrelloComment.js
Last active Aug 29, 2015
Realtime Code Hosting function to signal Trello that trelloComment is a valid webhook callback url
View HEADtrelloComment.js
function trelloComment(res){
jparreira / POSTtrelloComment.js
Last active Aug 29, 2015
Realtime Code Hosting function to send SMS using Twilio when a new comment is added to a Trello card
View POSTtrelloComment.js
function trelloComment(res,req,modules){
// send a log to the remote console
modules.storageMule.log("trelloComment: ", JSON.stringify(req));
// find out the trello action triggered
var trelloAction = req.body.action.type;
// it's a comment
if(trelloAction == "commentCard") {
jparreira / incrementPlayerScore.m
Created May 19, 2014
Increment Player Score for Flying Brands
View incrementPlayerScore.m
- (void) incrementPlayerScore:(NSDictionary *) playerScore WhitScore:(NSNumber *) score OnCompletion:(void (^)(BOOL finished)) completion {
NSNumber *totalScore = [NSNumber numberWithInt:([[playerScore objectForKey:SK_SCORES] intValue] + [score intValue])];
ItemRef *itemRef = [[_storageRef table:TAB_SCORES] item:[playerScore objectForKey:PK_SCORES] secondaryKey:[playerScore objectForKey:SK_SCORES]];
[itemRef del:^(ItemSnapshot *success) {
NSDictionary *newScore = [NSDictionary dictionaryWithObjectsAndKeys:
[playerScore objectForKey:PK_SCORES], PK_SCORES,
totalScore, SK_SCORES,
jparreira / index.htm
Last active Aug 29, 2015
Multi-user real-time chat using Realtime Cloud Storage, AngularJS and Pure CSS Speech Bubbles (get your free Storage developers license at
View index.htm
<html ng-app>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<link rel="stylesheet" type="text/css" href="pure-speech.css">
<script type="text/javascript">
function ChatCtrl($scope) {
jparreira / client.htm
Created Nov 25, 2013
Realtime Cloud Messaging (ORTC) announcement channels test
View client.htm
<title>Announcement channels test</title>
<script type="text/javascript" src=""></script>
loadOrtcFactory(IbtRealTimeSJType, function (factory, error) {
if (error != null) {
jparreira / index.html
Created Nov 21, 2013
Listing last n chat messages and retrieve the previous messages on demand. Messages will be written at the browser console in groups of 3 (last ones first). Click on the "previous messages" link to retrieve the previous messages until there's no more messages in the table.
View index.html
<!DOCTYPE html>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src=""></script>
<a href="javascript:void;" title="previous messages" id="aPreviousMessages">previous messages</a>
<script type="text/javascript" src="list.js"></script>
You can’t perform that action at this time.