Downloading a Bucket from Amazon S3 using Ruby

This little script was written using Ruby 2.5.1 and uses the aws-sdk-s3 gem.

Folder structure:

    download_s3/
    - download_s3.rb
    - s3.yml
    - Gemfile

download_s3.rb:

    #!/usr/bin/env ruby
    require 'yaml'
    require 'aws-sdk-s3'

    s3_file = File.join(__dir__, 's3.yml')
    config = YAML.load(File.read(s3_file))

    backup_folder = config['backup_folder']
    region = config['region']
    bucket = config['bucket']
    access_key_id = config['access_key_id']
    secret_access_key = config['secret_access_key']

    Aws.config.update({
      credentials: Aws::Credentials.new(access_key_id, secret_access_key),
      region: region
    })

    s3 = Aws::S3::Resource.new
    s3_bucket = s3.bucket(bucket)
    s3_bucket.objects.each do |item|
      puts "Name:  #{item.key}"
      backup_file = File.join(backup_folder, bucket, item.key)
      parent = File.dirname(backup_file)
      if not File.directory?(parent)
        FileUtils.mkpath(parent)
      end
      item.get(response_target: backup_file)
    end

s3.yml:

    backup_folder: <your_backup_folder>
    region: <your_region>
    bucket: <your_bucket>
    access_key_id: <your_access_key_id>
    secret_access_key: <your_secret_access_key>

Gemfile:

    source 'https://rubygems.org'
    gem 'aws-sdk-s3', '1.17.0'
QTip and FullCalendar positioning issue

I was recently making an events calendar for a client using FullCalendar 2.4.0 and QTip 2.2.0. While testing it out I came across an issue while switching events.

So I click on an event and the qtip pop up displays. The issue comes up when you use qtips close button on the event details.

Now when I click on another event the qtip pop up shows where I last clicked to close the event details.

Here's the gist of my javascript:

    <script type="text/javascript">
      $(document).ready(function() {
          var tooltip = $('<div/>').qtip({
              id: 'calendar_tip',
              prerender: true,
              content: {
                  text: 'Content Here',
                  title: { 
                    text: 'Title Here',
                    button: true 
                  }
              },
              position: {
                  my: 'bottom center',
                  at: 'top center',
                  target: 'mouse',
                  viewport: $('#calendar'),
                  adjust: {
                      mouse: false,
                      scroll: false
                  }
              },
              show: false,
              hide: false,
              style: 'qtip-bootstrap'
          }).qtip('api');

          $('#calendar').fullCalendar({
              header: {
                  left: 'prev,next today',
                  center: 'title'
              },
              defaultDate: '2016-01-11',
              editable: false,
              eventLimit: true,
              selectable: true,
              selectHelper: true,
              eventClick: function(data, event, view) {
                  tooltip.reposition(event);
                  tooltip.show();
              },
              dayClick: function() { tooltip.hide(); },
              eventResizeStart: function() { tooltip.hide(); },
              eventDragStart: function() { tooltip.hide(); },
              viewDisplay: function() { tooltip.hide(); },
              events: [
                  {
                      title: 'Available',
                      start: '2016-01-04',
                      end: '2016-01-08'
                  },
                  {
                      title: 'Available',
                      start: '2016-01-20',
                      end: '2016-01-22'
                  },
              ]
          }); 
      });
    </script>

Here's where the problem is:

eventClick: function(data, event, view) {
  tooltip.reposition(event);
  tooltip.show();
}

The reposition call isn't correct. I've double checked the event coordinates and they work just fine. So here's how I got around this issue.

eventClick: function(data, event, view) {
  tooltip.set({'position.target': [event.pageX, event.pageY]});
  tooltip.reposition(null, false);
  tooltip.show();
}

I set the position coordinates manually and then call the reposition function again. I call reposition because I want the qtip event to display again without any fancy motions.

My New Masi CX

I got a new bike! I had a crappy bike when I first moved to Austin. I was cruising around a corner when it popped gears and I ended up eating it hard. That's when I decided to get a new one and I chose this bad boy. I looooove steel.