Skip to content

Instantly share code, notes, and snippets.

@tankist
tankist / bash_aws_jq_cheatsheet.sh
Created June 8, 2021 11:25 — forked from lukeplausin/bash_aws_jq_cheatsheet.sh
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Create a Lambda function that will take a comma seperated list of key=value pairs and return an array of key value pairs that can then be used in cloudformation tags resource parameter"
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Create a Lambda function that will take a comma seperated list of key=value pairs and return an array of key value pairs that can then be used in cloudformation tags resource parameter"
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Create a Lambda function that will take a comma seperated list of key=value pairs and return an array of key value pairs that can then be used in cloudformation tags resource parameter"
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
@tankist
tankist / vm-resize-hard-disk.md
Created October 2, 2015 13:54 — forked from christopher-hopper/vm-resize-hard-disk.md
Resize a Hard Disk for a Virtual Machine provisioned using Vagrant from a Linux base box to run using VirutalBox.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

The following steps assume you've got a set-up like mine, where:

<?php
$basePrices = [
"6,00 € /l" => ['price' => '6,00', 'volume' => '1', 'unit' => 'l'],
"1.88 € / 100 g" => ['price' => '1.88', 'volume' => '100', 'unit' => 'g'],
"1.15 € / 100 gr" => ['price' => '1.15', 'volume' => '100', 'unit' => 'gr'],
"2.33 € / 1 kg" => ['price' => '2.33', 'volume' => '1', 'unit' => 'kg'],
"2.33 € / kg" => ['price' => '2.33', 'volume' => '1', 'unit' => 'kg'],
"0,70 € / 10St" => ['price' => '0,70', 'volume' => '10', 'unit' => 'St'],
"2.49 € / Stück" => ['price' => '2.49', 'volume' => '1', 'unit' => 'Stück'],
dispatch:beforeDispatchLoop
dispatch:beforeDispatch
dispatch:beforeNotFoundAction
dispatch:beforeExecuteRoute
dispatch:afterInitialize
dispatch:afterExecuteRoute
dispatch:afterDispatch
dispatch:afterDispatchLoop
dispatch:beforeException
@tankist
tankist / functions.php
Last active December 20, 2015 04:49 — forked from technopagan/default
# How to use the cachebuster function when registering styles in your theme's functions.php
wp_register_style('style',get_bloginfo('stylesheet_directory').autoVer('style.css'),false,NULL,'all');
/**
* Automated cache-buster function via filemtime
**/
function autoVer($url){
$name = explode('.',$url);
$lastext = array_pop($name);