Skip to content

Instantly share code, notes, and snippets.

View Tirke's full-sized avatar

Thomas Schersach Tirke

View GitHub Profile
@Tirke
Tirke / uncaught-node-errors.js
Last active July 5, 2022 14:22
run vim in things without sudo
process
.on('unhandledRejection', (reason, p) => {
console.error(reason, 'Unhandled Rejection at Promise', p);
})
.on('uncaughtException', err => {
console.error(err, 'Uncaught Exception thrown');
process.exit(1);
});
@Tirke
Tirke / Analyser_un_repo_de_code.md
Created February 1, 2022 10:51 — forked from sroccaserra/Analyser_un_repo_de_code.md
Analyser rapidement un répo de code

Git + Bash

Les âges des branches

$ git for-each-ref --sort=authordate --format '%(authordate:relative) %(refname:short)' refs/heads

Les 100 fichiers qui changent le plus souvent

@Tirke
Tirke / mutliple-stack.ts
Created August 7, 2020 09:04
Multiple stacks
import {Construct} from 'constructs';
import {App, TerraformOutput, TerraformStack} from 'cdktf';
import {AwsProvider, LambdaFunction, IamRole} from "./.gen/providers/aws";
import {SecondStack} from "./second-stack";
class MainStack extends TerraformStack {
constructor(scope: Construct, id: string) {
super(scope, id);
new AwsProvider(this, "aws", {
@Tirke
Tirke / simple-cdk-tf.ts
Created August 5, 2020 13:20
simple-cdk-tf
import {Construct} from 'constructs';
import {App, TerraformOutput, TerraformStack} from 'cdktf';
import {AwsProvider, LambdaFunction, IamRole} from "./.gen/providers/aws";
class MyStack extends TerraformStack {
constructor(scope: Construct, id: string) {
super(scope, id);
new AwsProvider(this, "aws", {
region: "eu-west-1",
resource "aws_lambda_alias" "lambda-alias" {
name = "latest"
description = "alias pointing to the latest published version of the lambda"
function_name = aws_lambda_function.lambda.function_name
function_version = aws_lambda_function.lambda.version
}
resource "aws_lambda_provisioned_concurrency_config" "keep-lambda-warm" {
function_name = aws_lambda_alias.lambda-alias.function_name
provisioned_concurrent_executions = 1
resource "aws_lambda_alias" "lambda-alias" {
name = "latest"
description = "alias pointing to the latest published version of the lambda"
function_name = aws_lambda_function.lambda.function_name
function_version = aws_lambda_function.lambda.version
}
resource "aws_appautoscaling_target" "scale-warmer-target" {
max_capacity = 1
min_capacity = 0
@Tirke
Tirke / alias.tf
Created January 10, 2020 08:40
alias
resource "aws_lambda_function" "lambda" {
...
publish = true // Publish a new version of the lambda when the code changes
}
resource "aws_lambda_alias" "lambda-alias" {
name = "latest"
description = "alias pointing to the latest published version of the lambda"
function_name = aws_lambda_function.lambda.function_name
@Tirke
Tirke / get-failed-record.js
Created December 9, 2019 20:02
Kinesis + Lambda + Lambda Destinations on Failure (SQS Queue)
const Kinesis = require('aws-sdk/clients/kinesis')
const cli = new Kinesis({ region: 'eu-west-1' })
cli.getShardIterator({
StartingSequenceNumber: '49595535202406761165676766185764002510013872440053071874',
StreamName: 'test',
ShardId: 'shardId-000000000000',
ShardIteratorType: 'AT_SEQUENCE_NUMBER'
}).promise().then(async ({ ShardIterator }) => {
const rec = await cli.getRecords({ ShardIterator, Limit: 1 }).promise()
type Config<T> =
T extends { type: 'sftp' } ? { login: string, password: string } :
T extends { type: 'post' } ? { url: string, header: string } : {};
const union: { type: 'post' | 'sftp' } = { type: 'post' }
const simple: { type: 'post' } = { type: 'post' }
const splitUnion: { type: 'post' } | { type: 'sftp' } = { type: 'post' }
type Instance = Config<typeof union> // ==> Instance is {} and not {url: string, header: string}
type InstanceOk = Config<typeof simple> // ==> Instance is { url: string, header: string }
type InstanceOk2 = Config<typeof splitUnion> // ==> Instance is { url: string, header: string }
@Tirke
Tirke / truc.ts
Created September 19, 2019 14:09
import * as request from 'superagent';
import {
Observable,
from,
throwError
} from 'rxjs';
import {
SuperAgentStatic
} from "superagent";