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 class Tree<T> { | |
| private _root: TreeNode; | |
| constructor(data: T) { | |
| this._root = new TreeNode<T>(data, null); | |
| } | |
| getRoot(): TreeNode { | |
| return this._root; |
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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "Stmt1584448617588", | |
| "Action": [ | |
| "cloudwatch:PutMetricData" | |
| ], | |
| "Effect": "Deny", | |
| "Resource": "*" |
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
| @Test | |
| void testLogEvent() { | |
| CustomMetric metric = new CustomMetric(); | |
| metric.metricDimensionName = "ServerId"; | |
| metric.metricDimensionValue = "server-01"; | |
| metric.metricName = "billingExecutionTime"; | |
| metric.metricValue = 112; | |
| String res = cloudWatchLogger.logMetric(metric); |
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
| public String logMetric(CustomMetric metric) { | |
| PutMetricDataRequest request = new PutMetricDataRequest(); | |
| Dimension dimension = new Dimension() | |
| .withName(metric.metricDimensionName) | |
| .withValue(metric.metricDimensionValue); | |
| MetricDatum data = new MetricDatum(); | |
| data.withMetricName(metric.metricName) | |
| .withValue(metric.metricValue) |
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
| import boto3 | |
| import requests | |
| class S3Manager: | |
| def __init__(self): | |
| self.__s3_client = boto3.client("s3") | |
| self.__bucket_name = "YOUR_BUCKET_NAME" | |
| def generate_presigned_url_for_download(self, object_name, expiration=3600): |
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
| import datetime | |
| from cryptography.hazmat.backends import default_backend | |
| from cryptography.hazmat.primitives import hashes | |
| from cryptography.hazmat.primitives import serialization | |
| from cryptography.hazmat.primitives.asymmetric import padding | |
| from botocore.signers import CloudFrontSigner | |
| KEY_ID = '*****************' | |
| FILE_URL = 'http://**********.cloudfront.net/s3.png' |
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
| import boto3 | |
| import base64 | |
| import hashlib | |
| import os | |
| s3 = boto3.resource("s3") | |
| BUCKET_NAME="secure-cc" | |
| def upload_file_with_encryption_key(file_path, key_path): |
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 class AppComponent { | |
| name = 'Angular'; | |
| constructor(private _dataService: DataService){ | |
| this._dataService.getControllableDataStream().subscribe(val => { | |
| console.log("received value: " + val); | |
| }) | |
| } | |
| toggleStream(toggle: number) { |
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
| getControllableDataStream(): Observable<number> { | |
| return this._toggleObservable.pipe( | |
| filter(t => t == true), | |
| startWith(true), | |
| concatMap(() => this._dataObservable.pipe(takeUntil(this._toggleObservable))) | |
| ) | |
| } |
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
| const sourceA = from([2, 12, 35]); | |
| sourceA.subscribe(console.log); |