Skip to content

Instantly share code, notes, and snippets.

View azakordonets's full-sized avatar

Andrew Zakordonets azakordonets

View GitHub Profile
@azakordonets
azakordonets / catalog-info.yaml
Created February 24, 2023 12:39
ChatGPT3 generated catalog-info.yaml example for Backstage.io
# Example entities.yaml file for Backstage.io
# Systems
- kind: System
metadata:
name: Trello
description: Web-based project management tool
namespace: my-namespace
spec:
owner: myteam
@azakordonets
azakordonets / .gitlab-ci.yml
Created November 10, 2022 19:24
This setup helps to run Jest tests on Gitlab in parallel
stages:
- prepare
- build
- test
- post_test
unit tests:
timeout: 20 minutes
stage: test
variables:
def convertFromSnakeToCamel(string):
return string[0].lower() + ''.join(x.capitalize() or '_' for x in string.split('_'))[1:]
@azakordonets
azakordonets / cloudwatch_client_mock.go
Last active August 26, 2020 21:08
Testing part of cloudwatch client for blog post
package aws
import (
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/cloudwatchlogsiface"
)
// CloudWatchLogsClientMock is a mock for cloudwatch logs client
type CloudWatchLogsClientMock struct {
cloudwatchlogsiface.CloudWatchLogsAPI
Psfr func(input *cloudwatchlogs.PutSubscriptionFilterInput) cloudwatchlogs.PutSubscriptionFilterRequest
@azakordonets
azakordonets / aws_error.go
Created August 26, 2020 21:04
Cloudwatch client with retry for a blog post
package aws
// Error implements AWS Error interface
type Error struct {
error
ErrorCode string
ErrorMessage string
OriginalError error
}
@azakordonets
azakordonets / aws_error.go
Created August 26, 2020 20:55
This is how you can work with cloudwatch sdk and handle ThrottlingException
package aws
// Error implements AWS Error interface
type Error struct {
error
ErrorCode string
ErrorMessage string
OriginalError error
}
const split = (str, nmb) => {
return str.split('')
.reduce((arr, rec) => {
console.log(`Arr: ${arr} Rec : ${rec}`)
if (arr[arr.length - 1].length < nmb) {
arr[arr.length - 1] = [...arr[arr.length - 1], rec]
return arr
}
return [...arr, [rec]]
}, [[]])
@azakordonets
azakordonets / generate_rsa_ssh_keys.go
Last active August 17, 2020 23:46 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"
# private token or personal token authentication
import gitlab
gl = gitlab.Gitlab('https://gitlab.com', private_token='{your_token}')
# make an API request to create the gl.user object. This is mandatory if you
# use the username/password authentication.
result = []
gl.auth()
# if you gonna have more then 500 api gateways, then you gonna need to wrap this into the loop and after first 500 you gonna need to pass position parameter to get_rest_apis method
import boto3
client = boto3.client('apigateway')
response = client.get_rest_apis(
limit=500
)
print(f"We have {len(response['items'])} api gateways to process")
for apigateway in response['items']:
print(f"Enabling {apigateway['name']} api gateway tracing")