Skip to content

Instantly share code, notes, and snippets.

View wtrocki's full-sized avatar
🚀
Making API Backends an Better Place!

Wojciech Trocki wtrocki

🚀
Making API Backends an Better Place!
View GitHub Profile

Target

A String of Pearls 
A Time For Us (Love Theme) 
A Whole New World (Aladdin's Theme) 
All I Ask Of You 
All The Things You Are 
Always 
Bewitched 
Blue Skies 
@wtrocki
wtrocki / update-resuts.js
Created July 28, 2017 12:49
Database update script for adding assignee field
// Database update script for adding assignee field
use raincatcher;
db.getCollection('workorders').find({},
{ id: 1, assignee: 1 }).forEach(function(workorder) {
db.getCollection('result').
updateMany({ workorderId: workorder.id },
{ $set: { assignee: workorder.assignee } });
});
@wtrocki
wtrocki / samplerest.js
Created August 24, 2017 12:36 — forked from joshbirk/samplerest.js
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@wtrocki
wtrocki / workflow.js
Last active September 4, 2017 16:28
Workflow mobile data structure
{
"_id" : "59aafac97037bfbab2a8f9a1",
"id" : "SJ8b3Mr8g",
"assignee" : "rkX1fdSH",
"title" : "Accident No. 3019",
"status" : "New"
flow: ['someid',someid2','5'] - This is created when we going thru workflow.
"workflow" : {
"id" : "SyVXyMuSr",
// stepFlow : _.map(workflow.steps,'id')
var $fh = require(‘fh-mbaas-api’);
var _ = require(‘underscore’);
var async = require(‘async’);
function noop() {}
// Generic wrapper for all database callbacks
// Ensures logging occurs and a client friendly error is propogated up
function dbCb(cb) {
return function (err, res) {
@wtrocki
wtrocki / .eslintrc
Created November 28, 2017 13:11 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
@wtrocki
wtrocki / MetricsIntegrationTest.swift
Last active April 9, 2018 09:42 — forked from psturc/MetricsIntegrationTest.swift
metrics integration testing
//
// MetricsIntegrationTest.swift
// AeroGearSdkExampleTests
@testable import AGSCore
import Foundation
import XCTest

HTTP Rest API receive 'push request', this gets processed in PushNotificationSenderEndpoint.send(), which eventually calls an async EJB (NotificationRouter.submit()) which performs a grouping/mapping and fires a CDI event per Variant.

This Event is received in the MessageHolderWithVariantsProducer.queueMessageVariantForProcessing() method, which basically sticks the submitted event into a transactional JMS send, based on the variant type a different queue is selected (mainly to keep things separated). The JMS listener MessageHolderWithVariantsConsumer.onMessage() reads from these queues, and fires a different CDI event, which kicks in the TokenLoader.

The TokenLoader generally iterates over all variants (for a given type, see the grouping/mapping done in NotificationRouter), and starts to query tokens from the database, as a steam.

The tokens are in different batches, with different default sizes per Push_Network, to not overflow the push network (e.g. google (non topic case) only allows 1

@wtrocki
wtrocki / StandardCordovaPlugin.java
Last active April 29, 2018 15:02
Example how Cordova api could be extended to improve end user interface
package org.apache.cordova;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.Arrays;
import java.util.List;
/**