Skip to content

Instantly share code, notes, and snippets.

@gmartinerro
gmartinerro / aws_list.sh
Created October 6, 2018 10:17
Shell script to get the list of EC2 instances
#!/bin/bash
aws --region eu-west-1 ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId,State.Name,InstanceType,PrivateIpAddress,PublicIpAddress,Tags[?Key==`Name`].Value[]]'\
--output json | tr -d '\n[] "' | perl -pe 's/i-/\ni-/g' | tr ',' '\t' | sed -e 's/null/None/g' | grep '^i-' | column -t
@gmartinerro
gmartinerro / update-aws-hosts.py
Last active October 25, 2022 13:21
Python script to update /etc/hosts and iTerm dynamic profiles with the list of aws instances
#!/usr/local/bin/python
# coding: UTF-8
import boto3
import json
# Main function that runs the whole thing
def updateAll():
instances,groups = getEC2Instances()
updateHosts(instances,groups)
@gmartinerro
gmartinerro / css-var-polyfill.js
Created June 20, 2018 14:34 — forked from stramel/css-var-polyfill.js
CSS Variable Polyfill
/*
TODO:
X Maybe account for defaults: color: var(--header-color, blue);
- Verify cross domain working or not (it is working from dropbox)
- Option to wait to apply anything until all <link>s are parsed or inject what we have and update as each <link> returns
- Need to test on a more complex CSS file
- Option to save parsed file in local/session storage so there isn't a delay on additional page loads. Could only do it for links (with URLs to use as keys) and style blocks with IDs of some sort
- Need to test more complex values like rgba(255,0,0,0.5); and something with !important
- Try multiple links
- Local links