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
{ | |
"name": "my-api", | |
"description": "API Lambda Functions", | |
"role": "arn:aws:iam::123456789023:role/lambda-api", | |
"runtime": "nodejs", | |
"handler": "main.handler", | |
"hooks": { | |
"build": "npm install && ../../node_modules/.bin/browserify --node -s default --exclude aws-sdk -o main.js index.js", | |
"clean": "rm -f main.js" | |
} |
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
{ | |
"name": "my-api", | |
"version": "1.0.0", | |
"dependencies": { | |
"assert": "1.3.0" | |
}, | |
"devDependencies": { | |
"browserify": "13.0.0" | |
} | |
} |
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 assert = require('assert'); | |
exports.handler = function(event, context) { | |
// Log the context, it contains details about the function's execution | |
console.log("Context: %j", context); | |
// Log the event, it contains data and parameters passed to the function | |
console.log("Event: %j",event); | |
try { | |
// Simple example to show that the assert library was successfully included |
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
// create task to download image from url | |
let task = session.dataTask(with: imageURL) {(imageData, response, error) in | |
// check for image data | |
if let data = imageData { | |
// update UI on main thread | |
DispatchQueue.main.async { | |
self.imageView.image = UIImage(data: data) | |
// animate image alpha | |
UIView.animateWithDuration(0.3) { | |
self.imageView.alpha = 1 |
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
URLSession.shared.rx | |
.response(imageURL) | |
// subscribe on main thread | |
.subscribeOn(MainScheduler.sharedInstance) | |
.subscribe(onNext: { [weak self] data in | |
// Update Image | |
self?.imageView.image = UIImage(data: data) | |
}, onError: { | |
// Log error | |
}, onCompleted: { |
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
func filterSearchLocation(completer: MKLocalSearchCompleter) | |
throws -> Observable<[MKLocalSearchCompletion]> { | |
// Filter results by titles that contain "United States" keywors | |
let filteredResults = completer | |
.results | |
.filter { $0.title.contains("United States") } | |
// Throw Location not found error | |
guard filteredResults.isEmpty else { throw "Location not found"} | |
// convert an filtered results into an Observable |
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
// Initialize MKLocalSearchCompleter | |
let requestCompleter = MKLocalSearchCompleter() | |
// OnDidCompleteRequestProxy | |
requestCompleter.rx_completerDidUpdateResults | |
.flatMap(filterSearchLocation) // filter search locations | |
.subscribe(onNext: { [weak self] (results) in | |
// Method to handle search completer success | |
self?.updateLocations(results) | |
}, onError: { [weak self] error in |
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
[creds] | |
user = consumer-account | |
passwd = auth_token_password | |
[endpoints] | |
prod_domain = https://prod.endpoint-mgmt.tld/web/api/v1.6 | |
dev_domain = https://dev.endpoint-mgmt.tld/web/api/v1.6 | |
[slack_dev] | |
webhook = https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXX |
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
#!/usr/bin/env python | |
""" Example Lambda function for Security ChatOPs""" | |
__author__ = 'Jacolon Walker' | |
__email__ = '[email protected]' | |
from urlparse import parse_qs | |
from ConfigParser import SafeConfigParser | |
import logging | |
from sentinel_core import AUTH, count_agents, fetch_agent_logs, login, threats_summary, blacklist_hash | |
import requests |
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
{ | |
u 'body': u 'token=SLASH_CMD_TOKEN&team_id=T1PASUPJL&team_domain=my_slack_domain&channel_id=C3GQWN08L&channel_name=integration_dev&user_id=U3GMSMREW&user_name=jdev&command=%2Fs1&text=health&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FXXXXXXXXX%2FXXXXXXXXXXXX%2FXXXXXXXXXXXXXXX', u 'resource': u '/slack/cmds/s1', u 'requestContext': { | |
u 'resourceId': u '7y5pmu', | |
u 'apiId': u 'REDACTED', | |
u 'resourcePath': u '/slack/cmds/s1', | |
u 'httpMethod': u 'POST', | |
u 'requestId': u '08b60825-d7ad-11e6-8e0c-2d47855f377e', | |
u 'accountId': u 'REDACTED', | |
u 'identity': { | |
u 'apiKey': REDACTED, |