This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /**** | |
| * Export the events from the sheet to a MongoDB Database via Stitch | |
| ****/ | |
| function exportEventsToMongoDB() { | |
| var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
| var sheet = spreadsheet.getSheetByName("Events"); | |
| var headerRows = 1; // Number of rows of header info (to skip) | |
| var range = sheet.getDataRange(); // determine the range of populated data | |
| var numRows = range.getNumRows(); // get the number of rows in the range | |
| var data = range.getValues(); // get the actual data in an array data[row][column] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports = async function(payload) { | |
| const mongodb = context.services.get("mongodb-atlas"); | |
| const eventsdb = mongodb.db("events"); | |
| const eventscoll = eventsdb.collection("events"); | |
| const delresult = await eventscoll.deleteOne({name:payload.query.name, location: payload.query.location}); | |
| return { text: `Deleted ${delresult.deletedCount} items` }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var countOuter = 0; | |
| var countInner = 0; | |
| var countSwap = 0; | |
| array = [3,9,4,5,1,200,2,88] | |
| dump(array); | |
| var swapped; | |
| do { | |
| countOuter++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports = async function (payload) { | |
| const mongodb = context.services.get("mongodb-atlas"); | |
| const exampledb = mongodb.db("exampledb"); | |
| const examplecoll = exampledb.collection("examplecoll"); | |
| const args = payload.query.text.split(" "); | |
| switch (args[0]) { | |
| case "stash": | |
| const result = await examplecoll.insertOne({ | |
| user_id: payload.query.user_id, | |
| when: Date.now(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Base Stitch Browser SDK --> | |
| <script src="https://s3.amazonaws.com/stitch-sdks/js/bundles/4.0.14/stitch.js"></script> | |
| <div class="results-bar"> | |
| <p>Count of Results:</p> | |
| <span id="num-results" class="results-bar__count"></span> | |
| </div> | |
| <table class="table table-striped"> | |
| <thead class="thead"> | |
| <tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports = function(message) { | |
| const mongodb = context.services.get("mongodb-atlas"); | |
| const coll = mongodb.db("db").collection("users"); | |
| const twilio = context.services.get("my-twilio-service"); | |
| const yourTwilioNumber = context.values.get("twilioNumber"); | |
| coll.find().toArray().then(users => { | |
| users.forEach(user => twilio.send({ | |
| to: user.phone, | |
| from: yourTwilioNumber, | |
| body: message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Enter the connection details of your existing MongoDB cluster. | |
| # NOTE: In order for to process the migration request, our servers need to be able to access your source cluster. Make sure to whitelist the following ip address ranges in your firewall. | |
| # 4.35.16.128/25 | |
| # 35.170.231.208/32 | |
| # 4.71.186.128/25 | |
| # 54.84.208.96/32 | |
| MYIP=`dig +short myip.opendns.com @resolver1.opendns.com` | |
| export SG=MySecurityGroup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports = function(event){ | |
| const db = context.services.get("mongodb-atlas").db("streamdata"); | |
| const clickdata = db.collection("clickdata"); | |
| const awsService = context.services.get('aws'); | |
| const geoAPI = "http://ip-api.com/json/"; | |
| const eventFullDocument = event.fullDocument; | |
| const eventDoc = event; | |
| const eventIP = eventFullDocument.ipaddress; | |
| const url = geoAPI + eventIP; | |
| const locationService = context.services.get("locationService"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports = function(event){ | |
| const awsService = context.services.get('aws'); | |
| console.log(JSON.stringify(event.fulldocument)); | |
| try{ | |
| awsService.kinesis().PutRecord({ | |
| Data: JSON.stringify(event.fullDocument), | |
| StreamName: "stitchStream", | |
| PartitionKey: "1" | |
| }).then(function(response) { | |
| return response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Generates a cURL command to add IPs to an MongoDB Atlas Group IP whitelist. | |
| # | |
| import sys | |
| atlas_user = sys.argv[1] | |
| atlas_api_key = sys.argv[2] | |
| atlas_group_id = sys.argv[3] | |
| whitelist_file = sys.argv[4] # Each IP or CIDR block should be separated by a newline |