Skip to content

Instantly share code, notes, and snippets.

View lfalmeida's full-sized avatar

Luis Fernando de Almeida lfalmeida

View GitHub Profile
@lfalmeida
lfalmeida / status-server.conf
Created November 20, 2018 15:21
Nginx Host configuration - status server
server {
listen 80;
server_name status.ptotall.app;
index index.php index.html;
root /src/ServerStatus/public;
# return 301 https://$host$request_uri;
location /nginx {
stub_status on;
@lfalmeida
lfalmeida / modify-ec2-instance-type.js
Created November 13, 2018 13:17 — forked from eddmann/modify-ec2-instance-type.js
Scheduled EC2 Instance Type Modification using Lambda and CloudWatch Events
// Demonstration video can be found at: https://youtu.be/_gJyK1-NGq8
// ModifyEC2InstanceType
const AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
const { instanceId, instanceRegion, instanceType } = event;
const ec2 = new AWS.EC2({ region: instanceRegion });
#!/bin/bash
FORMAT='- %s '
SUFFIX='homolog';
echo "## CHANGELOG"
echo ----------------------
git for-each-ref --sort='*authordate' --format='%(tag)' refs/tags | tac | grep -v '^$' | grep "${SUFFIX}" | while read TAG ;
do
git for-each-ref --sort=taggerdate --format '%(tag)_,,,_%(taggerdate:raw)_,,,_%(taggername)_,,,_%(subject)' refs/tags \
| awk 'BEGIN { FS = "_,,,_" } ; { t=strftime("%Y-%m-%d %H:%M",$2); printf "%-20s %-18s %-25s %s\n", t, $1, $4, $3 }'
@lfalmeida
lfalmeida / post-receive.sh
Last active October 21, 2023 17:33
Hook post receive com push options
#!/bin/sh
# ---- Config
ENV_NAME="Homologação"
TAG_SUFFIX="homolog"
PROJECT_NAME="Scania Journey Event"
PROJECT_PATH_HOST="/home/lfalmeida/Projects/GitHooks/prod/"
PROJECT_PATH_DOCKER="/src/projeto"
SLACK_WEBHOOK=""
ENABLE_SLACK_POST=0
FROM php:5.6-fpm
RUN echo America/Sao_Paulo | tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
RUN apt-get update -y && apt-get install -y libpng-dev
RUN buildDeps="libpq-dev libzip-dev libicu-dev wget git python-pip python-psycopg2 gnupg" && \
apt-get update && \
apt-get install -y $buildDeps --no-install-recommends && \
#apt-get install -y postgresql-client && \
docker-php-ext-install \
pdo \
pdo_pgsql \
<?php
/**
* Definimos uma interface para o cálculo do frete
*/
interface ShippingCalculatorInterface
{
// Deve receber a instância do pedido que o frete será calculado
public function calculate(Order $order);
}
<?php
$var = "yes";
var_dump(filter_var($var, FILTER_VALIDATE_BOOLEAN));
# A saída do código acima seria:
# bool(true)
?>
@lfalmeida
lfalmeida / pre-receive
Created August 7, 2016 13:01
Script para hook pre-receive que executa os testes unitários e rejeita em caso de falha
#!/bin/bash
printMessage () {
if [ $# -eq 0 ]; then
echo "Usage: printMessage MESSAGE [printMessage_CHARACTER]"
return 1
fi
echo ""
echo ""
printf -v _hr "%*s" 80 && echo -en ${_hr// /${2--}} && echo -e "\r\033[2C$1"
@lfalmeida
lfalmeida / git hook post-receive [TAGS]
Last active August 19, 2016 20:28
Hook para deploy utilizando tags
#!/bin/bash
## Print horizontal printMessager with message
printMessage () {
if [ $# -eq 0 ]; then
echo "Usage: printMessage MESSAGE [printMessage_CHARACTER]"
return 1
fi
echo ""
printf -v _hr "%*s" $(tput cols) && echo -en ${_hr// /${2--}} && echo -e "\r\033[2C$1"