Skip to content

Instantly share code, notes, and snippets.

@porjo
porjo / ec2-instance-dumper.sh
Last active December 10, 2018 04:44
Dump AWS EC2 instances to tab delimited output
#!/bin/bash
echo -e "Name\tInstanceID\tInstanceType\tState\tLaunchTime\tAvailabilityZone\tPrivateIP\tPublicIP"
#aws ec2 describe-instances --output text --query 'Reservations[*].Instances[*].[[Tags[?Key==`Name`].Value] [0][0], InstanceId, InstanceType, State.Name, LaunchTime, Placement.AvailabilityZone, PrivateIpAddress, PublicIpAddress ]'
aws ec2 describe-instances > instances.json
cat instances.json | jq -r '.Reservations[].Instances[]| [(.Tags[] | select(.Key == "Name") | .Value), .InstanceId, .InstanceType, .State.Name, .LaunchTime, .Placement.AvailabilityZone, .PrivateIpAddress, .PublicIpAddress, .VpcId ] | @tsv'
@porjo
porjo / nmap_parse.go
Last active November 7, 2016 10:08
Take XML file from nmap and dump resulting structs
package main
import (
"fmt"
"io/ioutil"
"os"
nmap "github.com/lair-framework/go-nmap"
)
@porjo
porjo / Dockerfile
Last active July 17, 2016 22:47
Tilemill Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y install nodejs-legacy npm git libgtk2.0-dev libwebkitgtk-dev protobuf-compiler libprotobuf-dev libprotobuf-lite9v5
RUN git clone https://github.com/mapbox/tilemill.git
WORKDIR /tilemill
RUN npm install
RUN echo '{"server":true,"listenHost": "0.0.0.0"}' > /etc/tilemillconfig.json
@porjo
porjo / ec2_list.sh
Created April 7, 2016 05:19
One liner to generate a list of EC2 instance names + instance type. Uses AWS CLI tools + jq
aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | [(.Tags[] | select(.Key=="Name") | .Value), .InstanceType] | @csv'
#!/usr/bin/perl
# Credit to Ryan Barnett at Spiderlabs.com for original idea
#
# Usage: modgrep.pl -a <logfile>
# -s <search keyword> (optional)
#
use strict;
use warnings;
use Getopt::Std;
@porjo
porjo / tc.sh
Created November 5, 2015 11:18
Traffic control script for OpenWRT. Works on 15.05
#!/bin/sh
# Source: https://github.com/klacke/tc-shaper/blob/master/tc-shaper.sh
set -x
TC=$(which tc)
DEV=pppoe-wan
RATEUP=700
# Clear
@porjo
porjo / rds.json
Last active January 10, 2018 13:42
Cloudformation RDS
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Test Stack - RDS",
"Parameters" : {
"VPCId": {
"Description" : "Id of an existing VPC to use for RDS server",
"Type": "AWS::EC2::VPC::Id",
@porjo
porjo / docker_ipv6.md
Last active August 29, 2015 14:22
Docker IPv6

Docker IPv6

The scenario is where the ISP assigns a /104 IPv6 network 'on link' (i.e. not routed): xxxx:yyyy:1::9c3:0:0/104

Configure Linux host

Add the following to /etc/sysctl.conf:

# Accept Router Advertisements even if forwarding is enabled.
net.ipv6.conf.eth0.accept_ra = 2
@porjo
porjo / timelapse.md
Last active May 25, 2023 16:14
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

Simple glob:

ffmpeg -r 24 -i '*.JPG' -s hd1080 -vcodec libx264 timelapse.mp4

Start from DSC_0079.JPG

ffmpeg -r 24 -f image2 -start_number 79 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse2.mp4
@porjo
porjo / pdnscontrol_Dockerfile
Last active August 29, 2015 14:12
pdnscontrol Dockerfile
FROM centos:centos7
RUN yum makecache
RUN yum update -y
RUN yum install -y git gcc postgresql-devel python-devel python-virtualenv openssl-devel
# We need newer mariadb-devel package due to this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1166603
RUN yum install -y http://mirror.aarnet.edu.au/pub/MariaDB/mariadb-5.5.41/yum/centos7-amd64/rpms/MariaDB-5.5.41-centos7_0-x86_64-devel.rpm http://mirror.aarnet.edu.au/pub/MariaDB/mariadb-5.5.41/yum/centos7-amd64/rpms/MariaDB-5.5.41-centos7_0-x86_64-common.rpm