Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0
j3tm0t0 / coffee2cfn.md
Last active August 29, 2015 13:58
CoffeeScript to generate CFN template

CoffeeScript to generate CFN template

preparation

  • install coffee script
    npm install coffee-script
  • install AWS CLI (optional)
    pip install awscli

sample

bucket.coffee

@j3tm0t0
j3tm0t0 / customization.md
Last active December 22, 2017 00:34
VyOS EC2 customization

VyOS AMI Customization

rl-system.init

comment-out followings

  • update_interface_config
    to prevent new interface is added when stop/start instance in EC2 classic or create imaage with existing interface

  • add_new_serial_if || log_failure_msg "can't add serial interfaces"
    no serial interface in EC2

vyatta-postconfig-bootup.script

@j3tm0t0
j3tm0t0 / init_with_eip.sh
Created February 14, 2014 18:38
same as https://gist.github.com/j3tm0t0/8980236 but with EIP for each AZ
#!/bin/sh -x
# function to get meta-data info
function m ()
{
curl --retry 3 --retry-delay 0 --silent --fail http://169.254.169.254/latest/meta-data/$1
}
# EIP for each AZ
declare -A EIP
EIP['ap-northeast-1a']='eipalloc-5887903a'
#!/bin/sh
# This script will monitor another NAT instance and take over its routes
# if communication with the other instance fails
# NAT instance variables
# Other instance's IP to ping and route to grab if other node goes down
NAT_ID=
NAT_RT_ID=
# My route to grab when I come back up
@j3tm0t0
j3tm0t0 / init.sh
Last active August 29, 2015 13:56
init script for NAT instance
#!/bin/sh -x
# function to get meta-data info
function m ()
{
curl --retry 3 --retry-delay 0 --silent --fail http://169.254.169.254/latest/meta-data/$1
}
# get REGION and setenv
export AWS_DEFAULT_REGION=`m placement/availability-zone | sed 's/.$//'`
@j3tm0t0
j3tm0t0 / healthcheck
Created February 13, 2014 17:31
healthcheck by ping
#!/bin/sh
count=3
timeout=2
success=0
for ip in `echo $PATH_INFO | perl -pe 's#[^\d\./]##g;s#/#\ #g'`
do
ping $ip -c $count -W $timeout > /dev/null && success=1
done
@j3tm0t0
j3tm0t0 / gist:8438629
Created January 15, 2014 15:49
diff of amzn-pv and amzn-pv-minimal
> acl-2.2.49-6.9.amzn1.x86_64
> acpid-1.0.10-2.1.6.amzn1.x86_64
> alsa-lib-1.0.22-3.9.amzn1.x86_64
> at-3.1.10-43.8.amzn1.x86_64
> attr-2.4.44-7.9.amzn1.x86_64
> aws-amitools-ec2-1.4.0.9-2.0.amzn1.noarch
> aws-apitools-as-1.0.61.3-1.0.amzn1.noarch
> aws-apitools-common-1.1.0-1.8.amzn1.noarch
> aws-apitools-ec2-1.6.12.0-1.0.amzn1.noarch
> aws-apitools-elb-1.0.23.0-1.0.amzn1.noarch
@j3tm0t0
j3tm0t0 / O-souji.rb
Created December 27, 2013 07:50
Misc clean-up script for unused AWS resources. It will delete unused VPN connections (both tunnels are down), unused EIPs (not associated), unused ELBs (has no healthy backend instances). USE AT YOUR OWN RISK PLEASE!
#!/usr/bin/env ruby
require 'aws-sdk'
ec2 = AWS::EC2.new
# delete vpn connections w/ both tunnels down
puts "checking unused VPN connections"
ec2.vpn_connections.filter('state','available').each{|vpn|
if vpn.vgw_telemetry[0].status == :down && vpn.vgw_telemetry[1].status == :down
puts " deleting #{vpn.id}"
@j3tm0t0
j3tm0t0 / boot.sh
Created November 30, 2013 15:41
bootstrap for bitcoin GPU miner on EC2
#!/bin/sh
USERNAME=hoge@example.com
PASSWORD=somepassword
cd /var/tmp
yum -y groupinstall "Development Tools"
yum -y install libcurl-devel python-devel yasm
easy_install pip
pip install numpy pyserial Mako
@j3tm0t0
j3tm0t0 / youtube_hide_appbar.user.js
Created November 21, 2013 22:23
userscript to disable annoying youtube appbar
// ==UserScript==
// @name Youtube hide appbar
// @namespace j3tm0t0.gmail.com
// @version 0.1
// @description disabling annoying appbar
// @include https://*youtube.com
// @include https://*youtube.com/*
// ==/UserScript==
document.querySelector('div#appbar-guide-menu').style.display='none';