Skip to content

Instantly share code, notes, and snippets.

View njofce's full-sized avatar

Nasi njofce

  • Skopje
View GitHub Profile
export class Tree<T> {
private _root: TreeNode;
constructor(data: T) {
this._root = new TreeNode<T>(data, null);
}
getRoot(): TreeNode {
return this._root;
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1584448617588",
"Action": [
"cloudwatch:PutMetricData"
],
"Effect": "Deny",
"Resource": "*"
@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);
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)
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):
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'
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):
@njofce
njofce / app
Created February 16, 2020 12:14
export class AppComponent {
name = 'Angular';
constructor(private _dataService: DataService){
this._dataService.getControllableDataStream().subscribe(val => {
console.log("received value: " + val);
})
}
toggleStream(toggle: number) {
getControllableDataStream(): Observable<number> {
return this._toggleObservable.pipe(
filter(t => t == true),
startWith(true),
concatMap(() => this._dataObservable.pipe(takeUntil(this._toggleObservable)))
)
}
const sourceA = from([2, 12, 35]);
sourceA.subscribe(console.log);