Skip to content

Instantly share code, notes, and snippets.

@clstokes
clstokes / assume-role-policy.json
Last active September 1, 2022 20:15
Example: Terraform IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@Integralist
Integralist / 1. Simpler (no web-server) variation.py
Last active November 11, 2019 13:06
[Python Tornado Yield Multiple Async Requests] #python #tornado #yield #splat #async #asynchttpclient #locals #vars #variables
"""
this uses tornado's own IOLoop (i.e. not asyncio's) and it also uses tornado's own
concurrency functions such as `tornado.gen.coroutine` instead of `async/await` as
those are native Python3 functions and not compatible with tornado.
"""
from tornado.gen import coroutine
from tornado.httpclient import AsyncHTTPClient
from tornado.ioloop import IOLoop
@deviantony
deviantony / install-latest-compose.sh
Last active May 3, 2025 01:54
Install latest version of Docker Compose
#!/bin/bash
## THIS IS THE OLD WAY
## Nowadays, simply follow the Compose installation instructions in the official documentation:
## https://docs.docker.com/compose/install/
# get latest docker compose released tag
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
@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)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
@ddikman
ddikman / logstash-example.conf
Last active June 19, 2018 16:47
Example of a filebeat to logstash to elasticsearch config
input {
beats {
port => 9300
type => beats
}
}
filter {
grok {
match => { "message" => "%{TOMCAT_DATESTAMP:DATETIME} \[%{WORD:level}\]%{SPACE}%{GREEDYDATA:message}" }
overwrite => [ "message" ]
@elleryq
elleryq / changepassword.sh.j2
Last active June 13, 2023 13:24
Create Django super user in ansible
#!/usr/bin/expect
set timeout -1;
spawn {{django_dir}}/venv/bin/python manage.py changepassword {{admin_user}};
expect {
"Password:" { exp_send "{{admin_pass}}\r" ; exp_continue }
"Password (again):" { exp_send "{{admin_pass}}\r" ; exp_continue }
eof
}
@pcn
pcn / example.md
Last active September 14, 2023 19:40
Using jq to get+filter aws data

I've been playing with jq, and I've been having a hard time finding examples of how it works with output from a service like AWS (which I use a lot).

Here is one I use a lot with vagrant-ec2.

When we're launching and killing a lot of instances, the AWS API is the only way to track down which instances are live, ready, dead, etc.

To find instances that are tagged with e.g. {"Key" = "Name", "Value" = "Web-00'} in the middle of a vagrant dev cycle, or a prod launch/replace cycle, you can do something like this:

@harlow
harlow / golang_job_queue.md
Last active March 29, 2025 04:55
Job queues in Golang
@imkarthikk
imkarthikk / nginx.conf
Last active March 11, 2018 07:06 — forked from oroce/nginx.conf
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
sendfile on;