Skip to content

Instantly share code, notes, and snippets.

View lwoodson's full-sized avatar

Lance Woodson lwoodson

View GitHub Profile
@lwoodson
lwoodson / install-json2yaml.bash
Last active August 10, 2022 15:57
Convert JSON to YAML via stdin (Ruby)
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o xtrace
sudo cat > /usr/local/bin/json2yaml <<EOT
#!/usr/bin/env ruby
require 'json'
require 'yaml'
@lwoodson
lwoodson / 1_cloudformation-vim-snippets.md
Last active June 1, 2020 18:32
Supporting a new file extension in Vim based on existing file extension

I use this for identifying *.cfn.json and *.cfn.yml files as JSON and YAML format cloudformation templates. Their filetypes are set to cfn_json and cfn_yaml respectively. I can then have custom highlighting of key attributes and/or custom snippets set up that are not polluting my editor when I am working with straight javascript/yaml intended for other purposes. This in on mac os x after installing vim 7.3 along with vim-snipmate and vim-snippets plugins. Someone feel free to improve on this.

1. in ~/.vimrc:

au BufRead,BufNewFile *.cfn.json set ft=cfn_json
au BufRead,BufNewFile *.cfn.yml set ft=cfn_yaml
au BufRead,BufNewFile *.cfn.yaml set ft=cfn_yaml
sql = <<SQL
select
  count(*),
  date_trunc('day', o.created_at) as day
from
  orders o,
  stores s
where
 o.store_id = s.id
require 'benchmark'
require 'ostruct'
module Platappus
##
# Class capable of carrying out multi-threaded map/reduce
# operations. Dev specifies 1-N map blocks to produce
# interim values, and a reduce block to aggregate results.
# For example:
#
package com.mycompany.app;
import com.amazonaws.auth.InstanceProfileCredentialsProvider;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.DescribeTagsRequest;
import com.amazonaws.services.ec2.model.DescribeTagsResult;
import com.amazonaws.services.ec2.model.Filter;
import com.amazonaws.services.ec2.model.TagDescription;
import com.amazonaws.util.EC2MetadataUtils;

We are (somewhat) settled and ready to accept visitors! There are a lot of wonderful things to do nearby.

Our Home

TBW

Winter

skiing

In winter, prime attractions are skiing and snowboarding, with Breckenridge Resort and Keystone Resort nearby. Copper Mountain and Arapahoe Basin are slightly further away. If this is your thing, you can rent skis/snowboards here for pickup at any of these resorts. If you are new to skiing or snowboarding, I would look into booking private (expensive) or group (economical) lessons at Breck or Keystone. The ski season is generally from Thanksgiving through mid April, with good

Park County Emergency Services

  • Emergency: 911
  • Animal Control: 719-836-4380
  • Sherriff: 719-836-2494
  • NWFPD Fire Station #2: 719-836-3150

For quickly iterating on ec2 instance bootstrapping without having to go through a cloudformation deployment cycle:

  1. Install sshfs or its mac port
  2. Deploy via cloudformation with minimal userdata script
  3. Mount the ec2-users home directory in your project (we will use a remote directory)
  4. Copy the ops code into the remote directory
  5. Edit files in the remote directory with your editor of choice set up as you have in your local env
  6. Test your changes by executing them as root from an ssh session on the remote host
  7. When things work to your liking, copy the ops code from the remote directory back to its location in your project
  8. Test bootstrapping via cloudformation stack deployment
@lwoodson
lwoodson / sshfs.md
Last active September 15, 2017 15:22

For quickly iterating on ec2 instance bootstrapping without having to go through the CFN deployment cycle:

  1. Install sshfs or its mac port
  2. Deploy via CFN with minimal userdata script
  3. Mount the ec2-users home directory in your project (we will use a remote directory)
  4. Copy the ops code into the remote directory
  5. Edit files in the remote directory with your editor of choice set up as you have in your local env
  6. Test your changes by executing them as root from an ssh session on the remote host
  7. When things work to your liking, copy the ops code from the remote directory back to its location in your project
  8. Test bootstrapping via cloudformation stack deployment

Problem

Need to download object from S3 bucket in bv-nexus-qa (us-east-1) onto ec2 instance in bv-nexus (us-east-1):

List objects in bucket...

[root@ip-10-100-27-9 ~]# aws s3 ls s3://bv-service-zkbrowser/

An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied