Skip to content

Instantly share code, notes, and snippets.

View rafaelmonteiro's full-sized avatar

Rafael Feitosa Monteiro rafaelmonteiro

View GitHub Profile
@rafaelmonteiro
rafaelmonteiro / paratest.sh
Created January 28, 2019 06:21
Basic ParaTest usage
./vendor/bin/paratest --runner=WrapperRunner -p7
@rafaelmonteiro
rafaelmonteiro / sqs.tf
Created December 1, 2018 02:39
A SQS configuration via Terraform
resource "aws_sqs_queue" "test-queue-dlq" {
name = "${var.app_name}-${var.cicd_namespace}-message-DLQ"
tags {
Application = "${var.app_name}",
Cluster = "${var.cicd_cluster}",
}
}
resource "aws_sqs_queue" "test-queue" {
@rafaelmonteiro
rafaelmonteiro / Fetch.spec.ts
Created December 1, 2018 02:29
A Jest test to check if a Fetch Factory was successfully instantiated
// Fetch factory
import nodeFetch from 'node-fetch';
export class Fetch {
public make(): Function {
return nodeFetch;
}
}
// Fetch test
@rafaelmonteiro
rafaelmonteiro / serverless.yml
Last active December 2, 2018 22:43
A Serverless Framework configuration file example
service: test
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: ap-southeast-2
environment:
API_URL: ${env:TEST_API_URL}
iamRoleStatements:
@rafaelmonteiro
rafaelmonteiro / handler.ts
Created December 1, 2018 01:38
A Lambda handler example
'use strict';
import 'reflect-metadata';
import { Callback, Context } from 'aws-lambda';
import { Container } from 'aurelia-dependency-injection';
import { MessageController } from '../controller/Message';
class Message {
public invoke: any = async (event: any, context: Context, callback: Callback) => {
try {
const container = new Container();
@rafaelmonteiro
rafaelmonteiro / lambci.docker
Created November 29, 2018 07:24
Locally testing a Lambda function
docker run --rm -v \"$PWD\":/var/task lambci/lambda:nodejs8.10 your_lambda_function_name
@rafaelmonteiro
rafaelmonteiro / docker.sh
Last active April 15, 2018 18:40
Docker commands
# A single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):
docker system prune
# Or just the volumes
docker volume rm $(docker volume ls -qf dangling=true)
# Or just the images
docker rmi $(docker images -q -f dangling=true)
# Run any command in a running container
@rafaelmonteiro
rafaelmonteiro / docker-compose.yml
Created April 15, 2018 18:11
Laravel+composer docker configuration
version: '2'
services:
app:
depends_on:
- composer
image: php:7.2-fpm
command: php -S 0.0.0.0:8000 /app/public/index.php
ports:
- "8000:8000"
volumes:
@rafaelmonteiro
rafaelmonteiro / stdin.php
Last active April 11, 2018 22:01
Reading from STDIN
<?php
$_fp = fopen("php://stdin", "r");
while (($buffer = fgets($_fp)) !== false) {
echo $buffer;
}
@rafaelmonteiro
rafaelmonteiro / simple_operation_benchmark.php
Created April 5, 2018 19:08
A simple benchmark to measure processing time and memory usage.
<?php
$time = microtime(true);
// Here goes your time consuming operation
echo "Time/RAM: ";
echo microtime(true) - $time . "\n" . memory_get_peak_usage(true) . "\n";