This file contains 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
version: '3' | |
services: | |
opensearch-node1: | |
image: opensearchproject/opensearch:1.0.0-rc1 | |
container_name: opensearch-node1 | |
environment: | |
- cluster.name=opensearch-cluster | |
- node.name=opensearch-node1 | |
- discovery.seed_hosts=opensearch-node1 | |
- cluster.initial_master_nodes=opensearch-node1 |
This file contains 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
def mod10(number): | |
digits = [] | |
even = False | |
for digit in reversed(number): | |
digit = ord(digit) - ord('0') | |
if even: | |
digit = digit * 2 | |
if digit >= 10: | |
digit = digit % 10 + digit / 10 | |
digits.append(digit) |
This file contains 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
# This simple example illustrates how Nuage recommends you should build | |
# a Dynamic Provider in Pulumi | |
# | |
# The example is based on the official documentation: | |
# https://www.pulumi.com/docs/intro/concepts/programming-model/#example-github-labels-rest-api | |
# | |
# It defines a Github Label programmatically via Pulumi. | |
# | |
# The recommended directory structure is the following: | |
# |
This file contains 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
import base64 | |
import hashlib | |
def sha256sum(filename): | |
""" | |
Helper function that calculates the hash of a file | |
using the SHA256 algorithm | |
Inspiration: | |
https://stackoverflow.com/a/44873382 |
This file contains 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
#python3 | |
def hook(t): | |
def inner(bytes_amount): | |
t.update(bytes_amount) | |
return inner | |
BUCKET_NAME = 'your_s3_bucket_name' | |
FILE_NAME = 'your_s3_file_name' | |
s3 = boto3.resource('s3') |
This file contains 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
import subprocess | |
import logging | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
def lambda_handler(event, context): | |
""" | |
Runs a shell command and returns the output code | |
STDOUT & STDERR are logged into Cloudwatch |
This file contains 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
import json | |
import gzip | |
def compress_data(data): | |
# Convert to JSON | |
json_data = json.dumps(data, indent=2) | |
# Convert to bytes | |
encoded = json_data.encode('utf-8') | |
# Compress | |
compressed = gzip.compress(encoded) |
This file contains 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
def trigo(): | |
product = 1.0 | |
for counter in range(1, 1000, 1): | |
for dex in list(range(1, 360, 1)): | |
angle = radians(dex) | |
product *= sin(angle)**2 + cos(angle)**2 | |
return product | |
def sha(): | |
h = hashlib.sha1('secret') |
This file contains 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
# System dependencies | |
yum update -y | |
yum install -y \ | |
binutils \ | |
findutils \ | |
python36 | |
# Create directory for our lambda | |
mkdir build | |
pip install -t build numpy pandas scipy | |
# Check uncompressed file size |
This file contains 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
'use strict'; | |
const aws = require('aws-sdk'); | |
const lambda = new aws.Lambda({region: 'eu-west-1'}); | |
const async = require('async'); | |
exports.handler = (event, context, callback) => { | |
/* | |
Invokes a given Lambda function `event.function` in parallel for each given | |
argument `event.events` |
NewerOlder