Skip to content

Instantly share code, notes, and snippets.

View davidkelley's full-sized avatar

David Kelley davidkelley

View GitHub Profile
@davidkelley
davidkelley / README.md
Last active September 6, 2015 14:42
AWS Cloudformation integrated Task Scheduler

DynamoDB Table

| string:Hash | string | string | string | string | string | string | |------|---|---|---|---|---|---|---| | Id | StartTime | EndTime | Recurrence | Type | Name | Message |

Scheduler Cloudformation

  1. Creates DynamoDB table: scheduler_table
  2. Creates Lambda function to act as Cloudformation custom resource
@davidkelley
davidkelley / gist:741c64a3d623e9eaa3a8
Created March 27, 2015 15:43
Determine oldest instance inside AutoScalingGroup using LaunchTime
GROUP=$(ec2-describe-tags --filter "resource-type=instance" --filter "resource-id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" --filter "key=aws:autoscaling:groupName" | cut -f5)
IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $GROUP --query 'AutoScalingGroups[0].Instances[].InstanceId' --output text | sed 's/\t/ /g')
IPS=$(aws ec2 describe-instances --instance-ids $IDS --region us-east-1 --query Reservations[].Instances[].PrivateIpAddress --output text | sed 's/\t/,/g')
LAUNCH_TIME=$(date -d $(aws ec2 describe-instances --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` --query Reservations[].Instances[0].LaunchTime --output text))
LAUNCH_TIMES=$(aws ec2 describe-instances --instance-ids $IDS --region us-east-1 --query Reservations[].Instances[].LaunchTime --output text)
@davidkelley
davidkelley / gist:cc3c90123aeb640a8758
Last active August 29, 2015 14:17
Retrieve comma-delimited list of Private IP addresses for EC2 instances in the same Autoscalinggroup
1. Describe tags for the instance itself and retrieve the autoscaling group name
GROUP=$(ec2-describe-tags --filter "resource-type=instance" --filter "resource-id=$(curl http://169.254.169.254/latest/meta-data/instance-id)" --filter "key=aws:autoscaling:groupName" | cut -f5)
2. Grab all the EC2 instance IDs for that autoscaling group
IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $GROUP --query 'AutoScalingGroups[0].Instances[].InstanceId' --output text | sed 's/\t/ /g')
3. For each instance-id, grab the private IP address of the instance
@davidkelley
davidkelley / gist:45d410e9f0ec472cbae8
Created June 24, 2014 21:45
Rubinius on Ubuntu Trusty (14.04)
FROM ubuntu:trusty
# Install Ruby
RUN apt-get -y update
RUN apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
RUN apt-get -y install wget
RUN wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
RUN tar -xvzf ruby-2.1.2.tar.gz
RUN cd ruby-2.1.2 && ./configure --prefix=/usr/local
RUN cd ruby-2.1.2 && make
<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
<Header>
<To xmlns="http://www.w3.org/2005/08/addressing">https://api.rkd.reuters.com/api/TokenManagement/TokenManagement.svc/
Anonymous</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1/
CreateServiceToken_1</Action>
</Header>
<Body>
<CreateServiceToken_Request_1 xmlns:global="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1" xmlns="http://www.
reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1">
@davidkelley
davidkelley / .script.app
Last active December 2, 2024 01:28
Configures Vagrant to run Docker & Fig
# Run Application specific setup tasks here!
#!/usr/bin/env bash
cd /vagrant
fig run web foreman run rake db:create
fig run web foreman run rake db:migrate
@davidkelley
davidkelley / network.template
Created April 13, 2014 15:12
AWS Cloudformation that launches Private and Public Subnets inside a configured VPC complete with a Bastion Host
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Creates networking infrastructure.",
"Parameters" : {
"BastionKeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the bastion host",
"Type" : "String",
@davidkelley
davidkelley / gist:9002267
Last active January 27, 2020 08:43
Example showing how to connect with a USB device using Javascript. Note that this file uses the chrome.usb.* API's which are only available for "packaged app" Chrome extensions.
var port = 0;
var endpoint = 0x01;
var device = { vendorId: 0x04b8, productId: 0x0202};
var connect = function(callback) {
chrome.permissions.getAll(function(p) {
if (p.permissions.indexOf('usb') >= 0) {
//construct permission object for our device
var obj = { usbDevices: [device] };
@davidkelley
davidkelley / install-postgres
Created September 13, 2013 09:35
Commands to setup Postgresql on OS X.
#!/bin/bash
brew update
brew doctor
brew uninstall postgresql || true
brew install postgresql
initdb /usr/local/var/postgres -E utf8
gem install lunchy
@davidkelley
davidkelley / commands.sh
Last active December 22, 2015 03:49
This Gist will setup a full-screen Chromium kiosk on the Raspberry Pi without launching any GUI. It will clone a repository from the provided location and navigate to it inside Chromium.
#location of git repo
REPO=""
#install library dependencies
sudo apt-get update && apt-get upgrade -y
sudo apt-get install -y chromium-browser x11-xserver-utils unclutter xwininfo git git-core couchdb
#better font experience
sudo apt-get install -y ttf-mscorefonts-installer