Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Solera asolera

  • Secretaria Municipal de Inovação e Tecnologia de São Paulo
  • São Paulo
View GitHub Profile
@asolera
asolera / slimscroll.js
Created May 4, 2021
jQuery SlimScroll fix for window resize
View slimscroll.js
function applySlimScroll() {
$('.slimScrollDiv .sidebar').unwrap();
$('.slimScrollBar, .slimScrollRail').remove();
$('.sidebar').slimScroll({
height: 'auto',
size: '10px',
color: #ff0000',
alwaysVisible: true,
railVisible: true,
railColor: '#222',
@asolera
asolera / README.md
Last active Apr 29, 2021
Traefik + Nginx without Docker on AWS - Amazon Linux 2 (AMI)
View README.md

Traefik + Nginx without Docker on Amazon Linux 2 (AMI)

Guide on how to configure Traefik with Nginx on Amazon Linux 2 EC2 Instance, without Docker.

  1. Create an EC2 Instance on AWS with security groups allowing incoming traffic on ports 80 and 443.

  2. Connect to your instance.

  3. Install and configure Nginx:

@asolera
asolera / fix-crlf.sh
Created Apr 23, 2021
Fix CRLF git problems
View fix-crlf.sh
#!/bin/bash
# https://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf
git config --global core.autocrlf false
git rm --cached -r .
git reset --hard
@asolera
asolera / docker-debug.sh
Created Apr 16, 2021
Docker swarm debug commands that shows errors on service deploy
View docker-debug.sh
#!/bin/bash
# Credits/thanks to: https://stackoverflow.com/questions/45372848/docker-swarm-how-to-find-out-why-service-cant-start
docker service ps --no-trunc {serviceName}
journalctl -u docker.service | tail -n 50
@asolera
asolera / cloudformation.yml
Created Apr 14, 2021
AWS CloudFormation Template for EC2 (AMI) with Docker
View cloudformation.yml
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation Template for EC2 (AMI) with Docker
Parameters:
EC2AvailabilityZoneParam:
Type: String
Default: us-east-1a
EC2ImageNameParam:
Type: String
Default: ami-0533f2ba8a1995cf9
@asolera
asolera / .env
Last active Apr 12, 2021
Vagrant with dot env without plugins
View .env
EXAMPLE_ENV_A=Hello
EXAMPLE_ENV_B=world
@asolera
asolera / git-fetch-branches.sh
Last active Apr 7, 2021
Git fetch all remote branches to local machine
View git-fetch-branches.sh
#!/bin/bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
@asolera
asolera / tag.sh
Created Mar 25, 2021
Tagging AWS Cloudwatch Alarms via AWS CLI
View tag.sh
#!/bin/bash
aws cloudwatch tag-resource --resource-arn arn:aws:cloudwatch:us-east-1:012345678901:alarm:Alarm-Name --tags Key=Example,Value=OK Key=Another,Value=Okay
@asolera
asolera / lambda_function.py
Created Mar 23, 2021
Stop AWS EC2 Instances with Lambda
View lambda_function.py
import boto3
import time
# Enter the region your instances are in, e.g. 'us-east-1'
region = 'us-east-1'
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX']
instances = ['i-03c24cxbd9x10ex51']
def lambda_handler(event, context):
ec2 = boto3.client('ec2', region_name=region)
ec2.stop_instances(InstanceIds=instances)
@asolera
asolera / lambda_function.py
Created Mar 23, 2021
Start AWS EC2 Instances with Lambda
View lambda_function.py
import boto3
import time
# Enter the region your instances are in, e.g. 'us-east-1'
region = 'us-east-1'
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX']
instances = ['i-0ab7xdx71x8xeff33']
def lambda_handler(event, context):
ec2 = boto3.client('ec2', region_name=region)
ec2.start_instances(InstanceIds=instances)