<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Guilherme Garnier</title>
    <description>The latest articles on DEV Community by Guilherme Garnier (@ggarnier).</description>
    <link>https://dev.to/ggarnier</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3306%2Ffoto_gui.jpg</url>
      <title>DEV Community: Guilherme Garnier</title>
      <link>https://dev.to/ggarnier</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ggarnier"/>
    <language>en</language>
    <item>
      <title>Increasing productivity in tmux with a single prefix key</title>
      <dc:creator>Guilherme Garnier</dc:creator>
      <pubDate>Tue, 05 Dec 2017 15:12:36 +0000</pubDate>
      <link>https://dev.to/ggarnier/increasing-productivity-in-tmux-with-a-single-prefix-key-cib</link>
      <guid>https://dev.to/ggarnier/increasing-productivity-in-tmux-with-a-single-prefix-key-cib</guid>
      <description>&lt;p&gt;Originally posted in &lt;a href="https://blog.guilhermegarnier.com/2017/12/increasing-productivity-in-tmux-with-a-single-prefix-key/"&gt;Guilherme Garnier blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/tmux/tmux"&gt;Tmux&lt;/a&gt; is a fantastic tool for improving productivity when working with a terminal. One of the first things people configure when start using tmux is changing the prefix key. The default value is &lt;code&gt;control+b&lt;/code&gt;, which is not very confortable to press with a single hand. And as you'll end up pressing it a lot, for every tmux command, the most common used configuration is changing it to &lt;code&gt;control+a&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is much better, but you still need to press two keys simultaneously before typing any tmux command. After using this configuration for some time, I decided to change it to a single key, to make it even easier.&lt;/p&gt;

&lt;p&gt;I though about changing the prefix to &lt;code&gt;caps lock&lt;/code&gt;. Besides being rarely used, it's very well positioned. However, you can't set &lt;code&gt;caps lock&lt;/code&gt; as prefix in tmux. An alternative solution is mapping the &lt;code&gt;caps lock&lt;/code&gt; key to something else. In OSX, you can set it to another modifier key, like &lt;code&gt;control&lt;/code&gt;, &lt;code&gt;shift&lt;/code&gt; or &lt;code&gt;esc&lt;/code&gt;: go to &lt;code&gt;System Preferences&lt;/code&gt; =&amp;gt; &lt;code&gt;Keyboard&lt;/code&gt; =&amp;gt; &lt;code&gt;Modifier keys&lt;/code&gt;. First I tried mapping it to &lt;code&gt;esc&lt;/code&gt;, and setting &lt;code&gt;esc&lt;/code&gt; as tmux prefix. It works, but this setup brought another problem: as a vim user, I use the &lt;code&gt;esc&lt;/code&gt; key a lot (to alternate between vim modes), so now I had to type &lt;code&gt;esc&lt;/code&gt;/&lt;code&gt;caps lock&lt;/code&gt; twice to send the &lt;code&gt;esc&lt;/code&gt; key to vim. It was ok, but not ideal.&lt;/p&gt;

&lt;p&gt;Then I tried another solution: I installed &lt;a href="https://github.com/tekezo/Karabiner-Elements"&gt;Karabiner-Elements&lt;/a&gt;, a Mac app which allows you to completely customize your keyboard. So I mapped the &lt;code&gt;caps lock&lt;/code&gt; key to &lt;code&gt;Home&lt;/code&gt; (which doesn't exist in Mac keyboard), and changed tmux prefix key to &lt;code&gt;Home&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; prefix Home
unbind C-b
bind-key Home send-prefix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I have a great configuration: I use a single key (&lt;code&gt;caps lock&lt;/code&gt;) as prefix, and without losing any key functionality.&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>tmux</category>
    </item>
    <item>
      <title>Cheap and reliable archiving with Amazon Glacier</title>
      <dc:creator>Guilherme Garnier</dc:creator>
      <pubDate>Mon, 31 Jul 2017 11:28:40 +0000</pubDate>
      <link>https://dev.to/ggarnier/cheap-and-reliable-archiving-with-amazon-glacier</link>
      <guid>https://dev.to/ggarnier/cheap-and-reliable-archiving-with-amazon-glacier</guid>
      <description>&lt;p&gt;Originally posted in &lt;a href="https://blog.guilhermegarnier.com/2017/07/cheap-and-reliable-archiving-with-amazon-glacier/"&gt;Guilherme Garnier blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Incidents like &lt;a href="https://en.wikipedia.org/wiki/WannaCry_ransomware_attack"&gt;WannaCry ransomware&lt;/a&gt; expose the importance of doing backups, which is usually forgotten by many people.&lt;/p&gt;

&lt;p&gt;When someone talks about backing up our personal files, we usually think about services like &lt;a href="https://www.dropbox.com"&gt;Dropbox&lt;/a&gt; and &lt;a href="https://drive.google.com"&gt;Google Drive&lt;/a&gt;. But they have a reasonable cost if you have more than a couple of GB of data. There are a lot of other solutions available. Most of them are cheaper, but not always reliable - imagine if you backup all your personal data to a small and unknown service, and a few months later, the company breaks. Or a security flaw exposes all your personal data! Of course this could also happen with Dropbox and Google Drive, but it's much less likely, being two large and serious companies.&lt;/p&gt;

&lt;p&gt;One alternative to them is &lt;a href="https://aws.amazon.com/glacier/"&gt;Amazon Glacier&lt;/a&gt;. It's a not so popular Amazon service for data archiving. You should notice it works differently from the usual backup solutions. When you sign up to Dropbox, for instance, you can install an app to your computer or mobile phone, or use the web interface to instantly access your files and upload new ones. Glacier is much more low level. It doesn't have a web interface, app or even command line tool! There's only an API, which you use to check your files, download or upload.&lt;/p&gt;

&lt;p&gt;And there's more: the download and upload rates are very slow. And to download a file, you first have to ask for a file retrieval job; the download will be available in a couple of hours!!!&lt;/p&gt;

&lt;p&gt;This seems like a terrible service, so why use it? Because it's very, very cheap! You only pay US$ 0.004 per GB per month for storage, besides &lt;a href="https://aws.amazon.com/glacier/pricing/"&gt;additional costs&lt;/a&gt; for requests. And even being slow and hard to use, it's a service offered by Amazon, which gives you confidence it won't suddenly disappear.&lt;/p&gt;

&lt;p&gt;Having said that, Glacier isn't a service to keep data you may need immediately. But it's ideal for something you probably won't need to access anytime soon. Think about your family pictures: when you want to access them, you probably doesn't need them right away; you're fine waiting a couple of hours for that.&lt;/p&gt;

&lt;p&gt;Glacier is also a great option for "backups of backups". If you want to be neurotic about backups (and you should!), you can archive a copy of your backups there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;The easiest way to use Glacier is with a third party client. I like &lt;a href="https://github.com/uskudnik/amazon-glacier-cmd-interface"&gt;amazon-glacier-cmd-interface&lt;/a&gt;. After setting up the basic configuration, you can create a vault and upload you files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glacier-cmd mkvault my-disaster-backup
$ glacier-cmd upload my-disaster-backup my-file1 my-file2 ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To list archives in a vault:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glacier-cmd inventory &amp;lt;vaultname&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The inventory retrieval job takes a couple of hours to be processed. You can check its status with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glacier-cmd listjobs &amp;lt;vaultname&amp;gt;
+------------------------------------------------------+---------------+--------------+--------------------+--------------------------+------------+
|                      VaultARN                        |    Job ID     | Archive ID   |       Action       |        Initiated         |   Status   |
+------------------------------------------------------+---------------+--------------+--------------------+--------------------------+------------+
| arn:aws:glacier:us-west-2:483413266890:vaults/backup | QYqdvM4k8q... |    None      | InventoryRetrieval | 2017-07-24T15:47:48.310Z | InProgress |
+------------------------------------------------------+---------------+--------------+--------------------+--------------------------+------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the job status change to &lt;code&gt;Succeeded&lt;/code&gt;, run the inventory command again to check the archive list.&lt;/p&gt;

&lt;p&gt;To download an archive, first you need to check its id in the inventory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glacier-cmd inventory &amp;lt;vaultname&amp;gt;
Inventory of vault: arn:aws:glacier:us-west-2:483413266890:vaults/backup
Inventory Date: 2017-07-05T11:22:15Z

Content:
+---------------+---------------------+----------------------+------------------+------------+
|  Archive ID   | Archive Description |       Uploaded       | SHA256 tree hash |    Size    |
+---------------+---------------------+----------------------+------------------+------------+
| uFg2FE_guu... | file1.tar.gz        | 2017-03-31T14:29:17Z | b41922e1a2...    | 1342622251 |
| 43Wjk63Dcu... | file2.tar.gz        | 2017-03-31T17:18:28Z | 2346170d22...    | 2347810677 |
+---------------+---------------------+----------------------+------------------+------------+
This vault contains 2 items, total size 2.5 GB.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, create an archive retrieval job using the archive id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glacier-cmd getarchive &amp;lt;vaultname&amp;gt; &amp;lt;archive id&amp;gt;
+-----------+---------------+
|   Header  |    Value      |
+-----------+---------------+
|   JobId   | Xa17IAadQG... |
| RequestId | cPcomv_vTf... |
+-----------+---------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the download is available (you can check its status with &lt;code&gt;glacier-cmd listjobs &amp;lt;vaultname&amp;gt;&lt;/code&gt;), download it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ glacier-cmd download &amp;lt;vaultname&amp;gt; &amp;lt;archive id&amp;gt; --outfile &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>backup</category>
      <category>amazon</category>
      <category>glacier</category>
    </item>
  </channel>
</rss>
