Skip to content

Instantly share code, notes, and snippets.

View thiagomgo's full-sized avatar
💜

Thiago Gomes thiagomgo

💜
  • Brazil
View GitHub Profile
@mlconnor
mlconnor / s3cors.txt
Last active November 15, 2016 03:31
CORS policy on S3/CloudFront
Here is how you can test
Create bucket, add this policy.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": {
@gwillem
gwillem / magento-nginx.conf
Last active July 29, 2023 10:13
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
@mlapida
mlapida / EC2-Snapshot-Lambda.py
Last active April 29, 2022 08:10
A lambda function for taking a snapshot of all EC2 instances in a region and cleaning the snapshots up after a set number of days. This ones now works best in conjunction with Asset Tagging https://gist.github.com/mlapida/931c03cce1e9e43f147b A full write up can be found on my site https://empty.coffee/tagging-and-snapshotting-with-lambda/
import boto3
import logging
import datetime
import re
import time
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
@mlapida
mlapida / EC2-Stopped-Tagged-Lambda.py
Last active May 29, 2024 06:00
Using a lambda function, stop all instances that are tagged appropriately.
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
#define the connection
ec2 = boto3.resource('ec2')
@mlapida
mlapida / EBS-Orphaned-Report-Lambda.py
Last active April 29, 2022 08:10
Generate a report of orphaned EBS volumes and send an SNS. A full writeup can be found on my site http://mlapida.com/thoughts/lambda-tracking-orphaned-ebs-volumes
import boto3
import logging
from datetime import *
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.WARNING)
#define the connection
ec2 = boto3.resource('ec2', region_name="us-west-2")
@brock
brock / psql-with-gzip-cheatsheet.sh
Last active March 6, 2025 00:21
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@mlapida
mlapida / EC2-Tag-Assets-Lambda.py
Last active January 17, 2024 08:10
A lambda function that will copy EC2 tags to all related Volumes and Network Interfaces. A full writeup can be found on my site https://empty.coffee/tagging-and-snapshotting-with-lambda/ - Thank you to the community for keeping this updated!
from __future__ import print_function
import json
import boto3
import logging
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
@dobryakov
dobryakov / puma-dev.ini
Created February 26, 2016 13:51
supervisord puma config example
[program:puma-dev]
command=/usr/local/rvm/gems/ruby-2.2.0/bin/puma -b unix:///tmp/meetplay-dev.sock -e development -t 2:8
process_name=%(program_name)s
numprocs=1
directory=/home/dg/projects/meetplay
umask=022
priority=999
autostart=true
autorestart=unexpected
startsecs=10
@AysadKozanoglu
AysadKozanoglu / sysctl.conf
Created April 10, 2016 22:42
high secure & perfornce debian sysctl.conf setting - debian sysctl yüksek güven ve performans ayarlari
# Kernel sysctl configuration file for Linux
# Version 1.11 - 2015-07-07
# Aysad Kozanoglu Aysad K.
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
#
# Tested with: Ubuntu 14.04 LTS kernel version 3.13
@supermasita
supermasita / gist:decd55c44719005c5adc7ab27d844884
Created May 3, 2016 21:46
NGINX - Determine if user agent is mobile and add set a different proxy_cache_key
location ~ / {
# mobile users
if ($http_user_agent ~* '(iPhone|iPod|mobile|Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile)') {
set $ismobile '1';
}
proxy_cache_key $proxy_host$uri$ismobile;
add_header X-Is-Mobile $ismobile;