Skip to content

Instantly share code, notes, and snippets.

View georstoy's full-sized avatar

Stoyan Georgiev georstoy

View GitHub Profile
@georstoy
georstoy / getDynamoObjectByPk
Created November 2, 2020 14:34
Get an object from dynamoDb Table using AWS SDK DocumentClient
import {DocumentClient} from "aws-sdk/clients/dynamodb";
(async () => {
const TableName = "";
const pk = ""
const response = await new DocumentClient().get({
TableName: TableName,
Key: {pk}
}).promise();
@georstoy
georstoy / getS3ObjectSize
Created October 28, 2020 13:26
Get S3 object size using AWS SDK for typescript
import {S3} from "aws-sdk";
/**
* Get size in bytes of S3 object.
* @param bucketName
* @param path
* @returns objectSize in bytes
*/
const getS3ObjectSize = async (bucketName: string, path: string): Promise<number> => {
const s3 = new S3();
@georstoy
georstoy / copyObject.ts
Created May 31, 2020 07:29
typescript - copy Object from one S3 to another
import {S3} from "aws-sdk";
/**
* copy an Object from source S3 bucket to destination S3 bucket
* return metadata of the new Object on success and undefined on failure
* @param sourceBucket Source Bucket Name
* @param sourcePath relative path of the Source Object
* @param destinationBucket Destination Bucket Name
* @param destinationPath relative path of the new Object
*/
@georstoy
georstoy / getS3ObjectSize.ts
Created May 30, 2020 13:51
typescript - get the size (in bytes) of AWS S3 Object
import {S3} from "aws-sdk";
/**
* return the size of an object in s3 bucket or undefined on failure,
* without downloading the object (just read the object's metadata)
*/
const getS3ObjectSize = async (bucketName: string, path: string): Promise<number | undefined> => {
const s3 = new S3()
let objectData: S3.HeadObjectOutput
@georstoy
georstoy / tslint.json
Created February 3, 2020 13:32
my basic ts-lint config
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"object-literal-sort-keys": false
},
"rulesDirectory": []
@georstoy
georstoy / tsconfig.json
Created January 29, 2020 12:49
This is a general purpose tsconfig.json. It's mission is to be include in new Typescript Node.js projects, as a strategy to reduce setup time.
{
"compilerOptions": {
"target":"ES2018",
"module": "commonjs",
"lib": ["es2018"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
@georstoy
georstoy / trim_whitespace.php
Created October 6, 2019 11:30
trim html content's leading, trailing, and non-breaking space
<?php
function trim_content($html)
{
$dom = new DOMDocument();
$dom->loadHTML($html);
$div = $dom->getElementById('whitespace');
$content = $div->textContent;
# Goal: trim leading, trailing, and non-breaking space
$content = htmlentities($content, null, 'utf-8');
@georstoy
georstoy / History|-185add55|entries.json
Last active September 8, 2022 11:53
My VS code config for Web Dev
{"version":1,"resource":"file:///home/ubuntu/Projects/2022.may.02/docebo-content/app/frontend/projects/docebo-content/src/app/users/pages/users-list/vendor-create-user/vendor-create-user.component.html","entries":[{"id":"yizd.html","source":"Workspace Edit","timestamp":1654151934027},{"id":"gw9f.html","timestamp":1654151936435},{"id":"NhoV.html","source":"Workspace Edit","timestamp":1654151938364},{"id":"PZy3.html","timestamp":1654151955639},{"id":"eISd.html","source":"Workspace Edit","timestamp":1654151988436},{"id":"74Nn.html","timestamp":1654152025144},{"id":"vyY3.html","timestamp":1654152036836},{"id":"thTU.html","timestamp":1654152069810},{"id":"eHSr.html","timestamp":1654152127076},{"id":"I79S.html","timestamp":1654152316138},{"id":"NsxO.html","timestamp":1654152348789},{"id":"aWS6.html","timestamp":1654152382672},{"id":"8wQs.html","timestamp":1654152399217},{"id":"UANc.html","timestamp":1654152498331},{"id":"bma9.html","timestamp":1654152518888},{"id":"uUE1.html","timestamp":1654152594947},{"id":"Nnr1.
@georstoy
georstoy / cloudSettings
Last active September 24, 2019 00:21
VS Code config for PHP Laravel Web dev
{"lastUpload":"2019-09-24T00:21:23.471Z","extensionVersion":"v3.4.3"}