Skip to content

Instantly share code, notes, and snippets.

View jessesanford's full-sized avatar

Jesse Sanford jessesanford

View GitHub Profile
@ryansch
ryansch / README.md
Created July 23, 2016 22:24
neovim + yadr
@mlimotte
mlimotte / vault-aws.sh
Created June 29, 2016 13:49
A bash function to get Vault (Hashicorp) credentials using AWS backend and set them in environment variables for use by the AWS cli.
#!/bin/bash
function vault-aws () {
VAULT_PATH=$1
if [ -z "$VAULT_PATH" ]; then
echo "Missing VAULT_PATH argument.\nExample: `vault-aws documents-store`"
exit 1
fi
if [ -z "$VAULT_ADDR" ]; then
echo "Missing VAULT_ADDR env variable"
-- 1. Create a new generic password entry in Keychain Access called "WHATEVER_AnyConnect_VPN" (the name in Keychain access must match that in line 39 below) with your password for the Cisco AnyConnect VPN server.
-- 2. Open this script in Script Editor (both this and the above are in the Applications->Utilities folder) and "Save as.." an Application (.app) with desired name.
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility.
-- 4. Enable the above .app so it can access Accessibility
-- 5. Copy and paste a nice icon on the generic Applescript icon (I used a copy of the default AnyConnect one)
-- 6. Add the new .app to /Users/[yourshortname]/Applications with a shortcut to your Dock
-- 7. Enjoy the fast connection with no need to enter password and increased security of not having a sensitive password stored as plain text
-- 8. Run script again to close connection
-- AnyConnect now refered to as targetApp
@bobveznat
bobveznat / flow_to_sumo.py
Last active September 8, 2016 17:23
Send VPC Flow Logs to Sumo Logic via AWS' lambda
"""An AWS lambda function for pushing VPC flow logs to Sumo Logic.
To use this you need to do a few things:
- In the Sumo Logic console create a new Hosted / HTTP collector (https://service.sumologic.com/help/Configuring_an_HTTP_Source.htm)
- Save the secret URL that is generated, you'll need it below
- Enable flow logs (http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/flow-logs.html)
- Create a new Lambda function. If you're doing this in the console:
- Skip picking a blueprint
- Function name: FlowLogsToSumo
@jvonschaumburg
jvonschaumburg / force-mfa-and-deny-cloudtrail-policy
Created December 15, 2015 14:40
A JSON Amazon Web Services IAM policy, which denies users all permissions until MFA is configured.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:ListUsers"
],
@jessesanford
jessesanford / 0001_privileged_containers.config
Last active December 21, 2015 20:35
ebextensions hack to allow for privileged containers on amazon beanstalk. .config goes in .ebextensions/ directory of your eb project root. .sh files go in .ebextensions/files/ NOTE! You cannot use privileged: true and essential: true in your Dockerrun.aws.json at the same time with this hack. They are mutually exclusive!
container_commands:
01-move-restart-hook:
command: cp -f .ebextensions/files/00_restart_containers_with_privileges.sh /opt/elasticbeanstalk/hooks/appdeploy/post/00_restart_containers_with_privileges.sh && chmod 755 /opt/elasticbeanstalk/hooks/appdeploy/post/00_restart_containers_with_privileges.sh
02-move-stop-hook:
command: cp -f .ebextensions/files/02stop_privileged_containers.sh /opt/elasticbeanstalk/hooks/appdeploy/pre/02stop_privileged_containers.sh && chmod 755 /opt/elasticbeanstalk/hooks/appdeploy/pre/02stop_privileged_containers.sh
ubuntu@ip-192-168-0-246:~$ cat supervisord.conf
[supervisord]
nodaemon=true
[program:tracelyzer]
command=/etc/init.d/tracelyzer start -D
[program:apache2]
command=/usr/sbin/apache2 -DFOREGROUND
@jessesanford
jessesanford / Gemfile
Created October 29, 2015 05:10 — forked from shineyear/Gemfile
newrelic cloudwatch docker all in one monitor
source 'https://rubygems.org'
gem 'dashing'
## Remove this if you don't need a twitter widget.
gem 'twitter', '>= 5.9.0'
gem 'activeresource'
gem 'newrelic_api'
@metaskills
metaskills / passenger.rb
Created September 18, 2015 14:16
Rails Multi-Database Best Practices Roundup - config/initializers/passenger.rb - http://technology.customink.com/blog/2015/06/22/rails-multi-database-best-practices-roundup/
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
if forked
ActiveRecord::Base.clear_all_connections!
MysqlBase.establish_connection MysqlBase.configurations['mysql'][Rails.env]
end
end
end
@kimh
kimh / docker-migrate.sh
Last active June 17, 2022 15:20
Shell script to demonstrate docker migration with CRIU
#!/bin/bash -e
function run-vg-cmd() {
pushd $1
eval $2
popd
}
function usage() {
echo "Usage: $0 container from-vagrant-dir to-vagrant-dir"