Skip to content

Instantly share code, notes, and snippets.

View gravcat's full-sized avatar

poppoppop gravcat

View GitHub Profile
@a-h
a-h / setup.tf
Last active December 8, 2023 14:56
Terraform - Creating an Instance with an S3 Bucket Policy
# Create an IAM role for the Web Servers.
resource "aws_iam_role" "web_iam_role" {
name = "web_iam_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@luhn
luhn / cleanup.py
Last active March 12, 2023 11:54
An AWS Lambda function to delete old AMIs.
"""
Code adapted from and inspired by http://blog.ranman.org/cleaning-up-aws-with-boto3/.
"""
import os
import re
from datetime import datetime, timedelta
import boto3
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active February 21, 2024 06:00
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
- name: copy updated files to ghost directory
synchronize: src={{ item.src }} dest={{ item.dest }} checksum=yes times=no
with_fileglob:
- { src: '{{ ghost_dir_new }}/*.js', dest: '{{ ghost_dir_current }}' }
- { src: '{{ ghost_dir_new }}/*.json', dest: '{{ ghost_dir_current }}' }
- { src: '{{ ghost_dir_new }}/*.md', dest: '{{ ghost_dir_current }}' }
- { src: '{{ ghost_dir_new }}/core', dest: '{{ ghost_dir_current }}' }
- { src: '"{{ ghost_dir_new }}/{{ theme_dir }}"', dest: '"{{ ghost_dir_current }}/{{ theme_dir }}"' }
delegate_to: "{{ inventory_hostname }}"
@ssmythe
ssmythe / devops_training.txt
Last active March 9, 2024 20:23
Training materials for DevOps
======
Videos
======
DevOps
What is DevOps? by Rackspace - Really great introduction to DevOps
https://www.youtube.com/watch?v=_I94-tJlovg
Sanjeev Sharma series on DevOps (great repetition to really get the DevOps concept)
@rgaidot
rgaidot / docker-resources.md
Last active October 22, 2023 13:02
Docker Resources All In One - A collection of docker online resources