Apr 12, 2016 - Single and Bulk Renaming of Objects in Amazon S3

Comments

Have you ever needed to rename a file on Amazon S3? Officially, the only way to do so is to download the file, change it's name, upload it again, then delete the original file.

Well, it turns out there is a way to do it using the AWS CLI without the need of any third party tools, and it is quite simple. Moreover, this technique can also be used to rename a bunch of files with little trouble.

EDIT: As Reddit user Neres28 pointed out, the download operation does not need to be done to your computer: it can be done from S3 to S3 directly with the PUT copy API operation. This was not clear in the first version of this post but was, actually, the point in it. Thanks again to Neres28 for the feedback

Read more...

Mar 6, 2016 - Quick Fix for wireless network issues on the Raspberry Pi 3

Comments

Today I've been setting up my brand new Raspberry Pi 3 and found out that my ssh session via the built-in wireless adapter was rahter laggy. On top of that, I've faced a few noticeable lag spikes (ranging from 5 to 10 seconds) and even total disconnects:

pi@pi3:~ $ packet_write_wait: Connection to 192.168.1.13: Broken pipe

I pinged the Pi3 from my computer and got response times so high that you would think packets from my own LAN were being routed through the Internet:

$ ping pi3
PING pi3 (192.168.1.13): 56 data bytes
64 bytes from 192.168.1.13: icmp_seq=0 ttl=64 time=262.618 ms
64 bytes from 192.168.1.13: icmp_seq=1 ttl=64 time=175.731 ms
64 bytes from 192.168.1.13: icmp_seq=2 ttl=64 time=93.862 ms
64 bytes from 192.168.1.13: icmp_seq=3 ttl=64 time=319.501 ms
64 bytes from 192.168.1.13: icmp_seq=4 ttl=64 time=240.666 ms
64 bytes from 192.168.1.13: icmp_seq=5 ttl=64 time=156.605 ms
64 bytes from 192.168.1.13: icmp_seq=6 ttl=64 time=77.802 ms

I got suspicious by the fact that disconnects were more likely the longer I left the SSH session idle. Also, it looked like I could bring the Pi back from it's own-induced disconnect just by pinging it's wireless interface:

Read more...

Feb 14, 2016 - Fixing "Certificate verify failed" error on Ruby 2.x in Mac OSX

Comments

I was setting up my environment to write a quick API wrapper in Ruby 2.2.1. On paper, that should be an easy task: install rvm, then do rvm install 2.2, create your dotfiles, gemset, write a couple lines of code and you're testing that API.

Then the API fails with some weird certificate error, but your browser does not complain. Time to discern if your HTTP gem is the problem. A quick way to tell if Ruby itself has SSL issues is using irb to request some HTTPS site like Google or Github:

MacbookPro:~ gerard$ irb
2.2.0 :001 > require 'open-uri'; open 'https://google.com'
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in `connect'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:923:in `connect'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/http.rb:852:in `start'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:318:in `open_http'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:736:in `buffer_open'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:211:in `block in open_loop'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:209:in `catch'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:209:in `open_loop'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:150:in `open_uri'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:716:in `open'
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/open-uri.rb:34:in `open'
    from (irb):1
    from /Users/gerard/.rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'
Read more...