Skip to content

Instantly share code, notes, and snippets.

@jolexa
jolexa / gist:2c385a814a427969e4e7
Created June 21, 2014 23:23
chef-rewind usage issue
How to unwind this template using chef-rewind?
https://github.com/opscode-cookbooks/tomcat/blob/master/providers/instance.rb#L157-L158
template "#{new_resource.config_dir}/server.xml" do
source 'server.xml.erb'
The chef-client run expands that to :
template[/etc/tomcat6/server.xml] action create
Following the chef-rewind docs, I assumed that this would work in my recipe:
chef_gem 'chef-rewind'
#!/usr/bin/env ruby
require 'rubygems'
require 'rotp'
require 'time'
user = ARGV[0]
secret = ARGV[1]
abort unless user and secret
trap("INT") do
@jolexa
jolexa / keybase.md
Created January 31, 2015 19:31
keybase.md

Keybase proof

I hereby claim:

  • I am jolexa on github.
  • I am jolexa (https://keybase.io/jolexa) on keybase.
  • I have a public key whose fingerprint is 2079 B699 DF01 7280 9817 095E 9B5D 52B1 ACED 22A6

To claim this, I am signing this object:

@jolexa
jolexa / gist:1a80e26a4b017846d083
Created October 4, 2015 08:28
mesos-slave process reconnecting
I1004 01:46:03.190534 31039 group.cpp:418] Lost connection to ZooKeeper, attempting to reconnect ...
I1004 01:46:03.227970 31041 group.cpp:472] ZooKeeper session expired
I1004 01:46:03.228416 31037 detector.cpp:138] Detected a new leader: None
I1004 01:46:03.228693 31037 slave.cpp:677] Lost leading master
I1004 01:46:03.228724 31037 slave.cpp:720] Detecting new master
I1004 01:46:03.228721 31042 status_update_manager.cpp:176] Pausing sending status updates
I1004 01:46:03.299782 31037 group.cpp:313] Group process (group(1)@10.0.1.1:5051) connected to ZooKeeper
I1004 01:46:03.299904 31037 group.cpp:787] Syncing group operations: queue size (joins, cancels, datas) = (0, 0, 0)
I1004 01:46:03.299933 31037 group.cpp:385] Trying to create path '/mesos' in ZooKeeper
I1004 01:46:03.358932 31037 detector.cpp:138] Detected a new leader: (id='8')
@jolexa
jolexa / gist:ee9e152aa7045c558e02
Created November 10, 2015 02:45
mesos socket keepalive
$ git diff
diff --git a/3rdparty/libprocess/include/process/network.hpp b/3rdparty/libprocess/include/process/network.hpp
index 61bfa82..32c14e3 100644
--- a/3rdparty/libprocess/include/process/network.hpp
+++ b/3rdparty/libprocess/include/process/network.hpp
@@ -44,6 +44,10 @@ inline Try<int> socket(int family, int type, int protocol)
return ErrnoError();
}
#endif // __APPLE__
+ const int enable = 1;
@jolexa
jolexa / 2015-lifting-totals.rb
Last active December 28, 2015 02:00
Simple, hacky ruby script to parse csv and provide a number for 2015
#!/usr/bin/ruby
# Tested with ruby-2.0
# 1) Download CSV file with workout data
# 2) run this script as './2015-lifting-totals.rb <path to csv file>
require 'csv'
# Ugly HACK!
@jolexa
jolexa / gist:3bfae81b950a24e93e025e8a4632c059
Created September 12, 2016 20:02 — forked from eduardocardoso/gist:82a629882ddb02ab3677
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
@jolexa
jolexa / unicreds_example.py
Created January 27, 2017 18:15
Using unicreds in AWS Lambda (python)
from subprocess import Popen, PIPE, STDOUT
import os
region = os.environ['region'] # Pass region in as a Lambda env variable
# Of course this assumes that your lambda has IAM permission to the KMS Key and DDB Table
def getSecret(key):
# unicreds is written in go, it is self-contained so, in your zip file include the package. One implementation of that is:
# curl -sL https://github.com/Versent/unicreds/releases/download/1.5.1/unicreds_1.5.1_linux_amd64.tar.gz | tar zx
cmd = "./unicreds -r {0} get -n {1}".format(region, key)
@jolexa
jolexa / open_aws_iam_url.py
Created March 23, 2017 15:31
Python script to open IAM documentation in new tab
#!/usr/bin/env python
import sys
import webbrowser
service = sys.argv[1]
url = "https://docs.aws.amazon.com/IAM/latest/UserGuide/list_{}.html".format(service)
webbrowser.open(url, new=2)
@jolexa
jolexa / cloudformation.yml
Last active May 18, 2018 15:07
AWS IAM Role that both services *and* Humans-with-2fa can assume
AWSTemplateFormatVersion: '2010-09-09'
Resources:
ExampleRole:
Type: AWS::IAM::Role
Properties:
Path: "/cfn/"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
Policies:
- PolicyName: DynamoDBGetter