Skip to content

Instantly share code, notes, and snippets.

@samkeen
samkeen / vpc-lean.template.json
Last active March 20, 2016 04:23
Lean version of 3 subnet VPC Template
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "VPC Across 3 AZs",
"Parameters": {
"EnvName": {
"Type": "String",
"Default": "Dev",
"AllowedValues": [
"Dev", "Test", "Prod"
],
@samkeen
samkeen / cw-monitor-memusage.py
Last active November 6, 2015 16:35 — forked from shevron/LICENSE
Send EC2 instance memory usage stats to CloudWatch using boto and IAM Roles
#!/usr/bin/env python
'''
Send memory usage metrics to Amazon CloudWatch
This is intended to run on an Amazon EC2 instance and requires an IAM
role allowing to write CloudWatch metrics. Alternatively, you can create
a boto credentials file and rely on it instead.
Original idea based on https://github.com/colinbjohnson/aws-missing-tools

Random Notes I'll organize later

Troubleshooting

YUM timeout

Could not retrieve mirrorlist http://repo.us-west-2.amazonaws.com/latest/main/mirror.list error was
    amazon-ebs: 12: Timeout on http://repo.us-west-2.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 10001 milliseconds')
@samkeen
samkeen / ec2-instance-subnet-id.md
Last active January 23, 2024 17:07
Get the subnet and VPC id of a running EC2 instance

First get the Interface mac address, then use that to run the full command

INTERFACE=$(curl --silent http://169.254.169.254/latest/meta-data/network/interfaces/macs/)
SUBNET_ID=$(curl --silent http://169.254.169.254/latest/meta-data/network/interfaces/macs/${INTERFACE}/subnet-id)
VPC_ID=$(curl --silent http://169.254.169.254/latest/meta-data/network/interfaces/macs/${INTERFACE}/vpc-id)

echo SUBNET_ID
@samkeen
samkeen / IsCoffeeGoodForYou.md
Last active November 26, 2015 19:44
Hobby project web page

Python Hobby Project

inspired by isitsnowinginpdx

Summary

  • run google search: health effects of coffee
  • collect result title and summaries of n results
  • perform sentiment analysis and based on score, render NO, YES, Maybe?
    • determine if better to do just summary or summary and title
  • get score for each result individually, the combine and average
@samkeen
samkeen / python-setup.md
Last active October 1, 2015 15:22
My OSX Python env setup

Python Dev machine setup

WORK IN PROGRESS

Documenting my specific tweaks here. I feel this doc does a great job of covering the basics of virtualenv and virtualenvwrapper.

brew update
brew install python

To install Kivy, you must:

  • Download the latest version from http://kivy.org/#download
  • Double-click to open it
  • Drag the Kivy.app into your Applications folder
  • Double click the makesymlinks script.
vi hello.py
@samkeen
samkeen / simple-web-server.js
Created May 5, 2014 15:21
Simple Web Server with directory listing
var express = require('express')
var directory = require('serve-index')
var logger = require('morgan')
var app = express()
app
.use(logger())
// enable direcotry listing
.use(directory('public', {'icons': true}))
// serve files
# this script started the remote rails app ready to attach a rubymine remote debugging session
# see: http://www.jetbrains.com/ruby/webhelp/remote-debugging.html
PATH_TO_RAILS="/path/to/rails/web/root"
echo "removing existing debug gems and intalling rubymine debug gems"
echo
sudo gem uninstall ruby-debug-base -aIx
sudo gem install ruby-debug-base --pre --no-rdoc --no-ri
sudo gem uninstall ruby-debug-ide -aIx
#!/bin/bash
#
# (1) copy to: ~/bin/ssh-host-color
# (2) set: alias ssh=~/bin/ssh-host-color
#
# Inspired from http://talkfast.org/2011/01/10/ssh-host-color
# Fork from https://gist.github.com/773849
#
set_term_bgcolor(){