Skip to content

Instantly share code, notes, and snippets.

View njofce's full-sized avatar

Nasi njofce

  • Skopje
View GitHub Profile
@njofce
njofce / async
Created February 16, 2020 11:11
const successPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('success');
}, 2000);
});
const aSourceB = from(successPromise);
aSourceB.subscribe(console.log);
console.log('wait for success promise');
let eventSource = fromEvent(document, 'mousemove', {passive: true});
eventSource.subscribe(val => console.log(val as MouseEvent));
const sourceB = from('a');
sourceB.subscribe(console.log);
const sourceA = from([2, 12, 35]);
sourceA.subscribe(console.log);
getControllableDataStream(): Observable<number> {
return this._toggleObservable.pipe(
filter(t => t == true),
startWith(true),
concatMap(() => this._dataObservable.pipe(takeUntil(this._toggleObservable)))
)
}
@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) {
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):
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 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):
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)