Skip to content

Instantly share code, notes, and snippets.

@tiagotex
tiagotex / add_env_variables_to_ebs_console.js
Last active February 27, 2023 12:41
Mass insert/update environment variables in AWS Elastic Beanstalk configuration
// I could not find a easy way to mass insert environment variables when migrating a project to EBS,
// this variables were in a config file so I decided to transform them into a array and write this script
// to allow easy insertion and update.
// To use this script fill the variables_array with your variables and then go to AWS Console,
// open your EBS environment, go to Configuration tab and then Software Configuration,
// you should see a table of Environment Properties. Open the browser console and use the scripts below.
// NOTICE: The combined size of all environment variables defined for an environment is limited to 4096 bytes.
// NOTICE: This script was done in January 2016, it might not work if AWS console is updated.
@tiagotex
tiagotex / Conf.class.php.template
Created January 8, 2016 12:19
Use docker to generate config file replacing env variables in template
<?php
class Conf {
public static $SERVER_NAME;
public static $SERVER_DB;
public static function init_values() {
self::$SERVER_NAME = "$NAME";
self::$SERVER_DB = "$DB";
}
@tiagotex
tiagotex / attach_running_docker_container.sh
Created May 26, 2016 10:27
Access docker container running in EBS
# Using nsenter you will be able to attach to a running docker container
# SSH into the EBS instance
# See what containers are running
docker ps
# Install nsenter
docker run -v /usr/local/bin:/target jpetazzo/nsenter
@tiagotex
tiagotex / choicesjs.rb
Last active August 5, 2020 12:24
Select item and get selected item from choises.js select with Capybara and Selenium
module ChoicesHelpers
def select_from_choices(item_text, options)
field = find_field(options[:from], visible: false)
within(find("##{field[:id]}", visible: false).ancestor(".choices")) do
find(".choices__inner").click
find("input").send_keys(item_text, :return)
end
end
# frozen_string_literal: true
require "stackprof"
require "optparse"
require "yaml"
require "json"
# To use run the script with: ruby cleanup_io_wait_and_gc_stacks.rb -s source_file.json -d destination_file.json
# To avoid interrupting the root frames when IO wait or garbage collection happens we modify the raw data to merge