<?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: Tomoyuki Aota</title>
    <description>The latest articles on DEV Community by Tomoyuki Aota (@tomoyukiaota).</description>
    <link>https://dev.to/tomoyukiaota</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%2F60690%2F722a8c25-6b30-43ca-a17f-c6216dde8bca.JPG</url>
      <title>DEV Community: Tomoyuki Aota</title>
      <link>https://dev.to/tomoyukiaota</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tomoyukiaota"/>
    <language>en</language>
    <item>
      <title>Replacing &lt;img&gt; with &lt;div&gt; when img.onerror is called</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Wed, 27 Apr 2022 15:11:10 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/replacing-with-when-imgonerror-is-called-20l5</link>
      <guid>https://dev.to/tomoyukiaota/replacing-with-when-imgonerror-is-called-20l5</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/1c92161439e504ff7177"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;When &lt;code&gt;img.onerror&lt;/code&gt; is called, there are several options instead of leaving the broken image:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;img.src&lt;/code&gt; to set a different image&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;img.style.display = 'none'&lt;/code&gt; to remove the element from DOM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/a/64610546/7947548"&gt;How to replace HTML img broken by missing or erroring image src&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/a/22051972/7947548"&gt;How to hide image broken Icon using only CSS/HTML?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my case, I wanted to replace &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;. I googled for a while but couldn't find the way. I did some experiments and found that configuring &lt;code&gt;img.outerHTML&lt;/code&gt; does the trick.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/tomoyukiaota/embed/yLpmaVq?height=600&amp;amp;default-tab=js,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In the code above, &lt;code&gt;targetImage.outerHTML = "&amp;lt;div&amp;gt;Invalid Image!&amp;lt;/div&amp;gt;";&lt;/code&gt; is set.&lt;br&gt;
Configuring style for the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; will make it prettier.&lt;/p&gt;

&lt;p&gt;As an actual example, I'm developing &lt;a href="https://photo-data-viewer.vercel.app/"&gt;Photo Data Viewer&lt;/a&gt;. This is an app to check Exif data of a photo. When the file other than photos is selected (i.e. files cannot be displayed with &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;), it displays "Unsupported File Format" using &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; instead of a photo.&lt;br&gt;
The code is &lt;a href="https://github.com/TomoyukiAota/photo-data-viewer/blob/07bfc5f09184468fa4368c692a7ad023122880d3/src/components/photo-image/PhotoImage.tsx#L65-L72"&gt;here&lt;/a&gt;.&lt;br&gt;
This app uses Next.js, so the code to set &lt;code&gt;onerror&lt;/code&gt; looks different, but setting &lt;code&gt;outerHTML&lt;/code&gt; is the same.&lt;/p&gt;

&lt;p&gt;I hope it helps!&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Creating multiple Vercel deployments with different configurations from a single GitHub repo</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Tue, 26 Apr 2022 15:47:25 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/creating-multiple-vercel-deployments-with-different-configurations-from-a-single-github-repo-49cf</link>
      <guid>https://dev.to/tomoyukiaota/creating-multiple-vercel-deployments-with-different-configurations-from-a-single-github-repo-49cf</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/54f533f6db0858d950e2"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;There was a case that I wanted to create multiple Vercel deployments with different configurations from a single GitHub repo.&lt;/p&gt;

&lt;p&gt;The motivation is that I want to deploy &lt;a href="https://github.com/TomoyukiAota/photo-data-viewer"&gt;photo-data-viewer repo&lt;/a&gt; as 1) a standalone web app called &lt;a href="https://photo-data-viewer.vercel.app/"&gt;Photo Data Viewer&lt;/a&gt; and 2) a feature in an Electron app called &lt;a href="https://tomoyukiaota.github.io/photo-location-map/"&gt;Photo Location Map&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Implementation-wise, webpack's target needs to be different:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web app needs &lt;code&gt;target === 'web'&lt;/code&gt; (default)&lt;/li&gt;
&lt;li&gt;Photo Location Map feature needs &lt;code&gt;target === 'electron-renderer'&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  How to configure
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;From photo-data-viewer repo, create 2 Vercel projects.

&lt;ul&gt;
&lt;li&gt;At first, I had an assumption that only 1 Vercel project can be created per GitHub repo. It took a while to recognize that this is wrong...&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set different environment variables for different Vercel projects.&lt;/li&gt;
&lt;li&gt;Reference the environment variables in the code.

&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;next.config.js&lt;/code&gt;, when environment variable &lt;code&gt;PDV_IN_PLM&lt;/code&gt; is set to &lt;code&gt;'True'&lt;/code&gt;, &lt;code&gt;config.taget = 'electron-renderer'&lt;/code&gt; is set.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/TomoyukiAota/photo-data-viewer/blob/07bfc5f09184468fa4368c692a7ad023122880d3/next.config.js#L29-L31"&gt;Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Deployments
&lt;/h1&gt;

&lt;p&gt;The 2 Vercel projects are deployed as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Vercel project&lt;/th&gt;
&lt;th&gt;URL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Web app&lt;/td&gt;
&lt;td&gt;&lt;a href="https://photo-data-viewer.vercel.app"&gt;https://photo-data-viewer.vercel.app&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Photo Location Map&lt;/td&gt;
&lt;td&gt;&lt;a href="https://pdv-in-plm.vercel.app"&gt;https://pdv-in-plm.vercel.app&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note that &lt;a href="https://pdv-in-plm.vercel.app/"&gt;https://pdv-in-plm.vercel.app/&lt;/a&gt; does not work in the web browser. It is built for Electron renderer process, so it works well when it is opened from Electron renderer process like Photo Location Map.&lt;/p&gt;

&lt;h1&gt;
  
  
  Reference
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/vercel/vercel/discussions/4879#discussioncomment-356114"&gt;https://github.com/vercel/vercel/discussions/4879#discussioncomment-356114&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vercel</category>
    </item>
    <item>
      <title>[Markdown] Short notation for an image with a link using reference-style link</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Thu, 24 Jan 2019 16:26:49 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/markdown-short-notation-for-an-image-with-a-link-using-reference-style-link-3mg</link>
      <guid>https://dev.to/tomoyukiaota/markdown-short-notation-for-an-image-with-a-link-using-reference-style-link-3mg</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/193cdf4890dbb0e8bf49" rel="noopener noreferrer"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;In Markdown, when we want to put an image with a link, the notation tends to be lengthy.&lt;/p&gt;

&lt;p&gt;For example, the status badge for Travis CI will be like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://travis-ci.org/travis-ci/travis-web" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftravis-ci.org%2Ftravis-ci%2Ftravis-web.svg%3Fbranch%3Dmaster" alt="Build Status"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[![Build Status](https://travis-ci.org/travis-ci/travis-web.svg?branch=master)](https://travis-ci.org/travis-ci/travis-web)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(This badge is an example from &lt;a href="https://docs.travis-ci.com/user/status-images/" rel="noopener noreferrer"&gt;Embedding Status Images&lt;/a&gt; on Travis CI.)&lt;/p&gt;

&lt;p&gt;In a table, such lengthy notation will be problematic, like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;OS&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ubuntu&lt;/td&gt;
&lt;td&gt;&lt;a href="https://travis-ci.org/travis-ci/travis-web" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftravis-ci.org%2Ftravis-ci%2Ftravis-web.svg%3Fbranch%3Dmaster" alt="Build Status"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| OS     | Status |
|:------:|:------:|
| Ubuntu | [![Build Status](https://travis-ci.org/travis-ci/travis-web.svg?branch=master)](https://travis-ci.org/travis-ci/travis-web) |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The table above has just one badge. When we want to put several badges in a row, the notation becomes so complex that it is difficult to recognize the column separator &lt;code&gt;|&lt;/code&gt;. For example, &lt;a href="https://github.com/srz-zumix/iutest/blob/master/README.md" rel="noopener noreferrer"&gt;README.md of srz-zumix/iutest&lt;/a&gt; has a table with many badges whose &lt;a href="https://raw.githubusercontent.com/srz-zumix/iutest/master/README.md" rel="noopener noreferrer"&gt;raw content&lt;/a&gt; looks very complicated.&lt;/p&gt;

&lt;p&gt;Can we get shorter notation somehow?&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.markdownguide.org/basic-syntax/#reference-style-links" rel="noopener noreferrer"&gt;Reference-style link&lt;/a&gt; is useful. For the table, it will be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| OS     | Status |
|:------:|:------:|
| Ubuntu | [![travisci-image]][travisci-link] |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;travisci-image&lt;/code&gt; and &lt;code&gt;travisci-link&lt;/code&gt; also needs be defined in the document, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[travisci-image]: https://travis-ci.org/travis-ci/travis-web.svg?branch=master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[travisci-link]: https://travis-ci.org/travis-ci/travis-web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this short notation for the badge, the notation of the table will be kept managable even when we put several badges in a row.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;travisci-image&lt;/code&gt; and &lt;code&gt;travisci-link&lt;/code&gt; are arbitrary strings, so we can do whatever we want, like giving them comprehensible names, adjusting length of the names so that the column separator &lt;code&gt;|&lt;/code&gt; aligns across rows, etc.&lt;/p&gt;

&lt;p&gt;Lastly, I created &lt;a href="https://gist.github.com/TomoyukiAota/812dd25222819347cb9c7eea973fc3b3" rel="noopener noreferrer"&gt;an example GitHub Gist&lt;/a&gt;. Click "Raw" button to see that this notation actually works!&lt;/p&gt;

</description>
      <category>markdown</category>
    </item>
    <item>
      <title>Exploring C++ equivalent of C#'s nameof operator</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Wed, 19 Dec 2018 17:12:53 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/exploring-c-equivalent-of-cs-nameof-operator-1p8c</link>
      <guid>https://dev.to/tomoyukiaota/exploring-c-equivalent-of-cs-nameof-operator-1p8c</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/b7791307f33ea88cd369"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;In C#, there is &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof"&gt;&lt;code&gt;nameof&lt;/code&gt;&lt;/a&gt; operator which can be used to get the string name of a variable, type, or member. &lt;br&gt;
One of useful cases is to log a message with the name of the method. In this case, if we use the string literal of the method name, IDE's rename feature will not automatically rename the string literal because it is not recognized as an identifier.&lt;br&gt;
If we use &lt;code&gt;nameof&lt;/code&gt;, it will be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nameof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s"&gt;"method entry"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we use &lt;code&gt;nameof&lt;/code&gt; like this, &lt;code&gt;f&lt;/code&gt; in &lt;code&gt;nameof(f)&lt;/code&gt; will be treated as an identifier, so it will be renamed when renaming the method.&lt;/p&gt;

&lt;p&gt;In this article, I'm going to explorer features in C++ which are similar to C#'s &lt;code&gt;nameof&lt;/code&gt; operator.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;__func__&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;C++ has &lt;code&gt;__func__&lt;/code&gt; which can be used in the body of a function. &lt;code&gt;__func__&lt;/code&gt; is a pre-defined identifier which holds the function name.&lt;br&gt;
An example is like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"This function is "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;__func__&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;f&lt;/code&gt; is called, &lt;code&gt;This function is f&lt;/code&gt; will be displayed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;__func__&lt;/code&gt; can retrieve the function name within its body, but C#'s &lt;code&gt;nameof&lt;/code&gt; is more versatile because it can be used with any method, function, and variable as long as the identifiers are available.&lt;/p&gt;

&lt;h1&gt;
  
  
  Define a macro
&lt;/h1&gt;

&lt;p&gt;In a function-like macro, when &lt;code&gt;#&lt;/code&gt; is placed right before the parameter, the string literal of the argument value is retrieved. For example, this code displays &lt;code&gt;5+5 = 10&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define PRINT(int) printf(#int " = %d\n",int)
&lt;/span&gt;&lt;span class="n"&gt;PRINT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Therefore, the following &lt;code&gt;NAMEOF&lt;/code&gt; macro will behave similar to C#'s &lt;code&gt;nameof&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define NAMEOF(name) #name
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The usage will be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;MyStruct&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;myMemberVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;myMemberFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;myGlobalVariable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NAMEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyStruct&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NAMEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyStruct&lt;/span&gt;&lt;span class="p"&gt;{}.&lt;/span&gt;&lt;span class="n"&gt;myMemberVariable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NAMEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyClass&lt;/span&gt;&lt;span class="p"&gt;{}.&lt;/span&gt;&lt;span class="n"&gt;myMemberFunction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NAMEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myGlobalVariable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NAMEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above will display the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MyStruct
MyStruct{}.myMemberVariable
MyClass{}.myMemberFunction
myGlobalVariable
myFunction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If I use rename feature to &lt;code&gt;myFunction&lt;/code&gt;, the &lt;code&gt;myFunction&lt;/code&gt; in &lt;code&gt;NAMEOF(myFunction)&lt;/code&gt; is renamed. (I used ReSharper's rename feature.)&lt;/p&gt;

&lt;p&gt;However, I said "&lt;code&gt;NAMEOF&lt;/code&gt; macro will behave &lt;em&gt;similar&lt;/em&gt; to C#'s &lt;code&gt;nameof&lt;/code&gt;". &lt;code&gt;NAMEOF&lt;/code&gt; macro is not exactly the same as C#'s &lt;code&gt;nameof&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;If we pass an undefined identifier, &lt;code&gt;myNonexistentWhatever&lt;/code&gt;, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NAMEOF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myNonexistentWhatever&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build succeeds, and &lt;code&gt;myNonexistentWhatever&lt;/code&gt; will be displayed. This is because macro expansion is just like editing plain text, which means that &lt;code&gt;myNonexistentWhatever&lt;/code&gt; will not be treated as an identifier. When macro expansion is done, the evaluation result is &lt;code&gt;"myNonexistentWhatever"&lt;/code&gt; (a string literal), so it will be a valid C++ code.&lt;/p&gt;

&lt;p&gt;Therefore, we need to confirm that there is no typo when using &lt;code&gt;NAMEOF&lt;/code&gt; macro in the first place.&lt;/p&gt;

&lt;p&gt;That being said, using &lt;code&gt;NAMEOF&lt;/code&gt; macro is better than simply writing string literal.&lt;/p&gt;

&lt;p&gt;There is a library, &lt;a href="https://github.com/bravikov/nameof"&gt;bravikov/nameof&lt;/a&gt;, which enhances the functionality to be more akin to C#'s &lt;code&gt;nameof&lt;/code&gt;. For example, when we write &lt;code&gt;nameof(Foo::Bar)&lt;/code&gt; for &lt;code&gt;enum Foo {Bar}&lt;/code&gt;, it will be evaluated as &lt;code&gt;"Bar"&lt;/code&gt; without preceding &lt;code&gt;Foo&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Lastly
&lt;/h1&gt;

&lt;p&gt;I googled this topic but could not find a lot of information. &lt;code&gt;NAMEOF&lt;/code&gt; macro in this article is taken from &lt;a href="https://stackoverflow.com/questions/38558180/does-qts-moc-c11-have-an-equivalent-of-cs-nameof-operator#comment64507414_38558180"&gt;a comment on StackOverflow&lt;/a&gt; and this article is created by elaborating it. Therefore, I'd be grad if some convention/tips/whatever are shared regarding this topc.&lt;/p&gt;

&lt;h1&gt;
  
  
  Reference
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/14351971/what-does-x-inside-a-c-macro-mean"&gt;https://stackoverflow.com/questions/14351971/what-does-x-inside-a-c-macro-mean&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cprogramming.com/tutorial/cpreprocessor.html"&gt;https://www.cprogramming.com/tutorial/cpreprocessor.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wandbox.org/permlink/w2tGPxN8UHknzNuT"&gt;https://wandbox.org/permlink/w2tGPxN8UHknzNuT&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cpp</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Creating a Pipfile for multiple versions of Python</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Sun, 30 Sep 2018 12:21:39 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/creating-a-pipfile-for-multiple-versions-of-python-9f2</link>
      <guid>https://dev.to/tomoyukiaota/creating-a-pipfile-for-multiple-versions-of-python-9f2</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/87017a4f57b8246b894c"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;A Pipfile created by &lt;code&gt;pipenv install&lt;/code&gt; command has the version number of Python. This Pipfile cannot be used on the machine with a different version of Python. &lt;sup id="fnref1"&gt;1&lt;/sup&gt; In this article, I'm going to introduce how to create a Pipfile which can be used for multiple versions of Python.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is the problem?
&lt;/h1&gt;

&lt;p&gt;When we want to start using Pipenv in a repository, the first thing we do is to issue &lt;code&gt;pipenv install&lt;/code&gt; command. This creates a Pipfile like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[[source]]&lt;/span&gt;

&lt;span class="py"&gt;url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://pypi.python.org/simple"&lt;/span&gt;
&lt;span class="py"&gt;verify_ssl&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"pypi"&lt;/span&gt;


&lt;span class="nn"&gt;[packages]&lt;/span&gt;



&lt;span class="nn"&gt;[dev-packages]&lt;/span&gt;



&lt;span class="nn"&gt;[requires]&lt;/span&gt;

&lt;span class="py"&gt;python_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"3.6"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This Pipfile is generated on a Windows PC with Python 3.6.4.&lt;/p&gt;

&lt;p&gt;Then, if we copy this Pipfile to another PC with Python 3.7 and issue &lt;code&gt;pipenv install&lt;/code&gt;, we will encounter the following error message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Requested Python version (3.6) not installed
Warning: Python 3.6 was not found on your system…
You can specify specific versions of Python with:
  $ pipenv --python path\to\python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On macOS/Linux with pyenv, &lt;a href="https://pipenv.readthedocs.io/en/latest/advanced/#automatic-python-installation"&gt;the required version of Python can be installed by Pipenv using pyenv&lt;/a&gt;, but pyenv is not available on Windows.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;If there is no need of specifying Python version, we can delete the &lt;code&gt;[requires]&lt;/code&gt; section. Then, &lt;code&gt;pipenv install&lt;/code&gt; command will be successful regardless of the version of Python installed on the machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;
&lt;span class="nn"&gt;[[source]]&lt;/span&gt;

&lt;span class="py"&gt;url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://pypi.python.org/simple"&lt;/span&gt;
&lt;span class="py"&gt;verify_ssl&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"pypi"&lt;/span&gt;


&lt;span class="nn"&gt;[packages]&lt;/span&gt;



&lt;span class="nn"&gt;[dev-packages]&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I've done here is described in the official document.&lt;br&gt;
&lt;a href="https://pipenv.readthedocs.io/en/latest/basics/#specifying-versions-of-python"&gt;https://pipenv.readthedocs.io/en/latest/basics/#specifying-versions-of-python&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The inclusion of [requires] python_version = "3.6" specifies that your application requires this version of Python, and will be used automatically when running pipenv install against this Pipfile in the future (e.g. on other machines). If this is not true, feel free to simply remove this section.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When this method is adopted, Pipfile.lock should not be included in version control. This because the content of Pipfile.lock can be different depending on the versions of Python.&lt;br&gt;
&lt;a href="https://pipenv.readthedocs.io/en/latest/basics/#general-recommendations-version-control"&gt;https://pipenv.readthedocs.io/en/latest/basics/#general-recommendations-version-control&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Do not keep Pipfile.lock in version control if multiple versions of Python are being targeted.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;To be exact, Pipfile cannot be used when the major or minor version is different. For example, Pipfile for Python 3.6 cannot be used on a machine with Python 3.7. On the other hand, Pipfile can be used when only the patch version is different. For example, Pipfile for Python 3.6.4 can be used on a machine with Python 3.6.5. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>python</category>
      <category>pipenv</category>
    </item>
    <item>
      <title>Creating a Pipfile which has different installation instructions depending on operating systems (PyTorch v0.4.1 as an example)</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Fri, 10 Aug 2018 10:24:12 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/creating-a-pipfile-which-has-different-installation-instructions-depending-on-operating-systems-pytorch-v041-as-an-example-56i8</link>
      <guid>https://dev.to/tomoyukiaota/creating-a-pipfile-which-has-different-installation-instructions-depending-on-operating-systems-pytorch-v041-as-an-example-56i8</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/5fe5b1d1a4e9fc475cf4"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;In this article, I'm going to describe how to create a Pipfile when we have different installation instructions depending on operating systems.&lt;/p&gt;

&lt;p&gt;As an actual example, I'm going to create a Pipfile which can be used on both macOS/Windows for &lt;a href="https://pytorch.org/"&gt;PyTorch&lt;/a&gt; v0.4.1.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;For most Python packages, installation instructions are the same regardless of operating systems. For example, &lt;code&gt;numpy&lt;/code&gt; can be installed like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipenv install numpy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, there are some packages which has different installation instructions depending on operating systems. For example, &lt;a href="https://pytorch.org/"&gt;PyTorch&lt;/a&gt; v0.4.1 is installed by the following command on macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipenv install torch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Windows, it is installed like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pipenv install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(In this example, I assume the installation of PyTorch is for Python 3.6 without CUDA.)&lt;/p&gt;

&lt;p&gt;In Pipfile, we need to let the former instruction run on macOS and let the latter instruction run on Windows. How can we achieve it?&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;Specify &lt;code&gt;sys_platform&lt;/code&gt; depending on operating systems. &lt;a href="https://docs.pipenv.org/advanced/#specifying-basically-anything"&gt;In the official document of Pipenv&lt;/a&gt;, the case of installing &lt;code&gt;pywinusb&lt;/code&gt; only on Windows is described.&lt;/p&gt;

&lt;p&gt;For PyTorch v0.4.1, the Pipfile I actually use is like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[[source]]

url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"


[packages]

theano = "*"
tensorflow = "*"
keras = "*"
numpy = "*"
scipy = "*"
matplotlib = "*"
seaborn = "*"
jupyter = "*"
jupyterlab = "*"
ipython = "*"
pandas = "*"
scikit-learn = "*"
spyder = "*"
pillow = "*"
torch = {version = "==0.4.1", sys_platform = "== 'darwin'"}
"b4b7455" = {file = "http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl", sys_platform = "== 'win32'"}
torchvision = "*"


[dev-packages]

pylint = "*"


[requires]

python_version = "3.6"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;[packages]&lt;/code&gt;, there are two lines for PyTorch v0.4.1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;torch = {version = "==0.4.1", sys_platform = "== 'darwin'"}
"b4b7455" = {file = "http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl", sys_platform = "== 'win32'"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In these lines, &lt;code&gt;sys_platform = "== 'darwin'"&lt;/code&gt; specifies that this is only for macOS, and &lt;code&gt;sys_platform = "== 'win32'"&lt;/code&gt; specifies that this is only for Windows.&lt;/p&gt;

&lt;p&gt;By the way, &lt;code&gt;"b4b7455"&lt;/code&gt; is written on Pipfile when &lt;code&gt;pipenv install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl&lt;/code&gt; is executed on Windows. I added &lt;code&gt;sys_platform = "== 'win32'"&lt;/code&gt; then.&lt;/p&gt;

&lt;p&gt;In GitHub, I created a repository, &lt;a href="https://github.com/TomoyukiAota/pipenv_cross-platform_example"&gt;pipenv_cross-platform_example&lt;/a&gt;, and put Pipfile and Pipfile.lock there, so this repository may be useful as an example.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pipenv</category>
      <category>pytorch</category>
    </item>
    <item>
      <title>When we read Stack Overflow, what does Stack Overflow read from us?</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Fri, 08 Jun 2018 14:58:15 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/when-we-read-stack-overflow-what-does-stack-overflow-read-from-us-3b1i</link>
      <guid>https://dev.to/tomoyukiaota/when-we-read-stack-overflow-what-does-stack-overflow-read-from-us-3b1i</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/e9f9a8290891ec9017f2" rel="noopener noreferrer"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;Before the Internet, a famous joke is created.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In America, you watch television.&lt;br&gt;
In Soviet Russia, television watches you!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After the Internet, we watch the contents of the web services like Facebook. And, the web services watch us.&lt;/p&gt;

&lt;p&gt;Companies have to notify the users of collecting information. This is not only due to the regulations but also to gain trust from the users.&lt;/p&gt;

&lt;p&gt;Many web services inform us about the kinds of collected information but not the actual data. However, to gain our trust, Stack Overflow allows the users to download  &lt;a href="https://meta.stackexchange.com/users/prediction-data" rel="noopener noreferrer"&gt;Personalized Prediction Data&lt;/a&gt; collected from the users' on-site activities. In this article, I'm going to download and explore my &lt;a href="https://meta.stackexchange.com/users/prediction-data" rel="noopener noreferrer"&gt;Personalized Prediction Data&lt;/a&gt; to see what it looks like.&lt;/p&gt;

&lt;h1&gt;
  
  
  Downloading and analyzing Personal Prediction Data
&lt;/h1&gt;

&lt;p&gt;To download your &lt;a href="https://meta.stackexchange.com/users/prediction-data" rel="noopener noreferrer"&gt;Personalized Prediction Data&lt;/a&gt;, you need to log in to Stack Exchange and click the blue "Start download" button. (If you are not logged in, values in personalized sections will be null.)&lt;/p&gt;

&lt;p&gt;The downloaded file is a JSON file which looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbtughqkw3exldiaumu87.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbtughqkw3exldiaumu87.PNG" alt="JSON file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is no document which explains what each value mean, so I looked at the data with some guesses.&lt;br&gt;
The interesting data is the { tag: value } style data in root/Data/TagViews. This is a key-value pair where the key is the tag in Stack Overflow. For example, it looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TagViews : {
  c++: 440,
  javascript: 183,
  ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The top 20 tags will be like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fklodwnh4de9bre9favsh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fklodwnh4de9bre9favsh.PNG" alt="Top 20 Stack Overflow tags"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tags and their values in this chart fit pretty well with my feelings of where I'm working on. It seems like Stack Overflow has a good guess of my current skills.&lt;/p&gt;

&lt;p&gt;For details of the analysis, please read the Jupyter notebook in &lt;a href="https://github.com/TomoyukiAota/stack_exchange_personalized_prediction_data" rel="noopener noreferrer"&gt;my GitHub repository&lt;/a&gt;. Clicking the badge below will take you to the notebook run by Binder.&lt;br&gt;
&lt;a href="https://mybinder.org/v2/gh/TomoyukiAota/stack_exchange_personalized_prediction_data/master" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmybinder.org%2Fbadge.svg" alt="Binder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Closing
&lt;/h1&gt;

&lt;p&gt;It was interesting to see what Stack Overflow collected from my on-site activities. I hope other companies will do the same.&lt;/p&gt;

</description>
      <category>stackoverflow</category>
      <category>python</category>
      <category>pandas</category>
      <category>jupyter</category>
    </item>
    <item>
      <title>Visualizing the patterns of missing value occurrence with Python</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Thu, 24 May 2018 15:18:44 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/visualizing-the-patterns-of-missing-value-occurrence-with-python-46dj</link>
      <guid>https://dev.to/tomoyukiaota/visualizing-the-patterns-of-missing-value-occurrence-with-python-46dj</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/fd75c28b802bad9e6632" rel="noopener noreferrer"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;During data analysis, we need to deal with missing values. Handling missing data is so profound that it will be an entire topic of a book. However, before doing anything to missing values, we need to know the pattern of occurrence of missing values. This article describes easy visualization techniques for missing value occurrence with Python. The techniques are useful in early stages of exploratory data analysis.&lt;/p&gt;

&lt;p&gt;I've uploaded &lt;a href="https://github.com/TomoyukiAota/visualization_of_missing_value_location" rel="noopener noreferrer"&gt;a Jupyter notebook in my GitHub repo&lt;/a&gt;. You can run it using Binder by clicking the badge below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://mybinder.org/v2/gh/TomoyukiAota/visualization_of_missing_value_location/master" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmybinder.org%2Fbadge.svg" alt="Binder" width="92" height="20"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisite
&lt;/h1&gt;

&lt;p&gt;I'm using &lt;a href="https://www.kaggle.com/c/titanic/data" rel="noopener noreferrer"&gt;the Titanic train dataset from Kaggle&lt;/a&gt; as an example. To begin with, following code is assumed to be executed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;train.csv&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Confirm the number of missing values in each column.
&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;class 'pandas.core.frame.DataFrame'&amp;gt;
RangeIndex: 891 entries, 0 to 890
Data columns (total 12 columns):
PassengerId    891 non-null int64
Survived       891 non-null int64
Pclass         891 non-null int64
Name           891 non-null object
Sex            891 non-null object
Age            714 non-null float64
SibSp          891 non-null int64
Parch          891 non-null int64
Ticket         891 non-null object
Fare           891 non-null float64
Cabin          204 non-null object
Embarked       889 non-null object
dtypes: float64(2), int64(5), object(5)
memory usage: 83.6+ KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Method 1: seaborn.heatmap
&lt;/h1&gt;

&lt;p&gt;The first method is by &lt;code&gt;seaborn.heatmap&lt;/code&gt;. The next single-line code will visualize the location of missing values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heatmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isnull&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;cbar&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa9t067qrzybw9tiiv63o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa9t067qrzybw9tiiv63o.png" alt="seaborn_heatmap.png" width="468" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Against Index, I can see that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Age column has missing values with variation in occurrence,&lt;/li&gt;
&lt;li&gt;Cabin column are almost filled with missing values with variation in occurrence, and&lt;/li&gt;
&lt;li&gt;Embarked column has few missing values in the beginning part.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not the case for this Titanic dataset, but especially in time series data, we need know if the occurrence of missing values are sparsely located or located as a big chunk. This heatmap visualization immediately tells us such tendency. Also, if more than 2 columns have correlation in missing value locations, such correlation will be visualized. (Again, not the case for this dataset, but it is important to know the fact that there is no such correlation in this dataset.)&lt;/p&gt;

&lt;p&gt;This single-line code tells us a lot of information of missing value occurrence.&lt;/p&gt;

&lt;h1&gt;
  
  
  Method 2: &lt;a href="https://github.com/ResidentMario/missingno" rel="noopener noreferrer"&gt;missingno&lt;/a&gt; module
&lt;/h1&gt;

&lt;p&gt;If you want to proceed further, &lt;a href="https://github.com/ResidentMario/missingno" rel="noopener noreferrer"&gt;missingno&lt;/a&gt; module will be useful.&lt;br&gt;
To begin with, install and import it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;missingno
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;missingno&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;msno&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want the similar result to &lt;code&gt;seaborn.heatmap&lt;/code&gt; described earlier, use &lt;code&gt;missingno.matrix&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;msno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;matrix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjlvqjn79v24kmk4cnsi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjlvqjn79v24kmk4cnsi0.png" alt="missingno_matrix" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to the heatmap, there is a bar on the right side of this diagram. This is a line plot for each row's data completeness. In this dataset, all rows have 10 - 12 valid values and hence 0 - 2 missing values.&lt;/p&gt;

&lt;p&gt;Also, &lt;code&gt;missingno.heatmap&lt;/code&gt; visualizes the correlation matrix about the locations of missing values in columns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;msno&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;heatmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6nmbw9h4l627bcx67w8b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6nmbw9h4l627bcx67w8b.png" alt="missingno_heatmap" width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;missingno&lt;/code&gt; module has more features, such as the bar chart of the number of missing values in each column and the dendrogram generated from the correlation of missing value locations. For more information, &lt;a href="https://github.com/ResidentMario/missingno" rel="noopener noreferrer"&gt;README&lt;/a&gt; is a good primer.&lt;/p&gt;

&lt;h1&gt;
  
  
  Closing
&lt;/h1&gt;

&lt;p&gt;Two easy visualization methods are described in this article. &lt;code&gt;seaborn.heatmap&lt;/code&gt; is the first choice as it requires &lt;code&gt;seaborn&lt;/code&gt; only, but it you need more, &lt;a href="https://github.com/ResidentMario/missingno" rel="noopener noreferrer"&gt;missingno&lt;/a&gt; module will help you.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pandas</category>
      <category>seaborn</category>
      <category>missingno</category>
    </item>
    <item>
      <title>Creating a short PowerShell command equivalent to "rm -rf" in Bash</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Thu, 29 Mar 2018 07:39:55 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/creating-an-alias-for-powershell-equivalent-of-rm--rf-in-bash-2gl3</link>
      <guid>https://dev.to/tomoyukiaota/creating-an-alias-for-powershell-equivalent-of-rm--rf-in-bash-2gl3</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/f94c9b0dfdeeb8a092f7"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;p&gt;In Bash, &lt;code&gt;rm -rf&lt;/code&gt; deletes a file or a directory. In PowerShell, I would like to do the same thing in a short command as well. Therefore, I created a PowerShell function to do the job.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Let's say that I want to delete &lt;code&gt;target&lt;/code&gt;. In PowerShell, the following command does the job.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Remove-Item -Recurse -Force target

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is a long command even with tab completion. The following command is shortened version using officially provided aliases.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -r -fo target

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is still long when compared to &lt;code&gt;rm -rf&lt;/code&gt; in Bash.&lt;br&gt;
Therefore, I decided to create a PowerShell function, &lt;code&gt;rmrf&lt;/code&gt;, for this job.&lt;/p&gt;
&lt;h1&gt;
  
  
  How to create the command
&lt;/h1&gt;

&lt;p&gt;PowerShell profile needs to be created.&lt;br&gt;
&lt;code&gt;echo $profile&lt;/code&gt; displays the file path of the profile. If the file does not exist, create it first.&lt;/p&gt;

&lt;p&gt;In PowerShell profile, add the following function.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;After editing the profile, restart PowerShell to reload the profile.&lt;/p&gt;

&lt;h1&gt;
  
  
  Result
&lt;/h1&gt;

&lt;p&gt;Issuing the following command will delete &lt;code&gt;target&lt;/code&gt;. It's short!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rmrf target

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>powershell</category>
    </item>
    <item>
      <title>How to start using C++ Core Guidelines Checker and GSL</title>
      <dc:creator>Tomoyuki Aota</dc:creator>
      <pubDate>Sun, 04 Mar 2018 16:58:10 +0000</pubDate>
      <link>https://dev.to/tomoyukiaota/how-to-introduce-c-core-guidelines-checker-and-gsl--2b61</link>
      <guid>https://dev.to/tomoyukiaota/how-to-introduce-c-core-guidelines-checker-and-gsl--2b61</guid>
      <description>&lt;h6&gt;
  
  
  (A Japanese translation is available &lt;a href="https://qiita.com/TomoyukiAota/items/28b39d77646daa74291a"&gt;here&lt;/a&gt;.)
&lt;/h6&gt;

&lt;h1&gt;
  
  
  Note
&lt;/h1&gt;

&lt;p&gt;In this article, I described how to start using C++ Core Guidelines Checker. However, C++ Core Guidelines Checker has some immature points, and &lt;a href="http://clang.llvm.org/extra/clang-tidy/"&gt;clang-tidy&lt;/a&gt; seems a better tool. Therefore, please consider using &lt;a href="http://clang.llvm.org/extra/clang-tidy/"&gt;clang-tidy&lt;/a&gt;. (&lt;a href="https://qiita.com/tenmyo"&gt;@tenmyo&lt;/a&gt; pointed out that &lt;a href="http://clang.llvm.org/extra/clang-tidy/"&gt;clang-tidy&lt;/a&gt; has checks based on C++ Core Guidelines.)&lt;/p&gt;

&lt;p&gt;I'm leaving the information about C++ Core Guidelines Checker just for reference.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What is C++ Core Guidelines Checker?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines"&gt;C++ Core Guidelines&lt;/a&gt; is created mainly by &lt;br&gt;
 Bjarne Stroustrup and Herb Sutter for writing better C++ code. Most of the items in the guidelines are designed to be supported by an analysis tool.&lt;/p&gt;

&lt;p&gt;C++ Core Guidelines Checker is a static analysis tool based on &lt;a href="http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines"&gt;C++ Core Guidelines&lt;/a&gt;. Microsoft is developing this tool, and Visual Studio 2017 supports it by default. This tool emits warnings for violating code in Error List window when VS builds the code. &lt;a href="https://docs.microsoft.com/en-us/visualstudio/code-quality/code-analysis-for-cpp-corecheck"&gt;Visual Studio C++ Core Guidelines Checker Reference | Microsoft Docs&lt;/a&gt; describes what warnings to be emitted for what kind of violation.&lt;/p&gt;

&lt;p&gt;As of May 2018, C++ Core Guidelines Checker works only on Visual Studio on Windows. Therefore, the content of this article applies only to such environment.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is GSL?
&lt;/h2&gt;

&lt;p&gt;GSL (Guidelines Support Library) is a library which contains types and functions that are suggested by &lt;a href="http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines"&gt;C++ Core Guidelines&lt;/a&gt;. The following article covers what types and functions are available.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.modernescpp.com/index.php/c-core-guideline-the-guidelines-support-library"&gt;C++ Core Guideline: The Guideline Support Library - ModernesCpp.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are several implementations of GSL. In this article, I will use &lt;a href="https://github.com/Microsoft/GSL"&gt;Microsoft/GSL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;GSL supports &lt;a href="https://github.com/Microsoft/GSL#supported-platforms"&gt;multiple platforms/compilers&lt;/a&gt;. I hope C++ Core Guidelines Checker will have multi-platform support as well.&lt;/p&gt;
&lt;h1&gt;
  
  
  How to begin using them?
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Enable C++ Core Guidelines Checker
&lt;/h2&gt;

&lt;p&gt;C++ Core Guidelines Checker has to be enabled in each VS project. The following pages cover the procedure to enable it. Also, several useful things (like disabling specific warnings) are described.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/visualstudio/code-quality/using-the-cpp-core-guidelines-checkers"&gt;Using the C++ Core Guidelines checkers | Microsoft Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blogs.msdn.microsoft.com/vcblog/2017/08/11/c-core-guidelines-checker-in-visual-studio-2017/"&gt;C++ Core Guidelines Checker in Visual Studio 2017 | Visual C++ Team Blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blogs.msdn.microsoft.com/vcblog/2017/08/14/managing-warnings-in-the-c-core-guidelines-checker/"&gt;Managing warnings in the C++ Core Guidelines Checker | Visual C++ Team Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Install GSL code
&lt;/h2&gt;

&lt;p&gt;Copy and paste &lt;a href="https://github.com/Microsoft/GSL/tree/master/include/gsl"&gt;gsl&lt;/a&gt; in your codebase. A package manager like Conan is preferable, but I could not find a well-maintenanced one. Hmm...&lt;/p&gt;
&lt;h2&gt;
  
  
  A wrapper of GSL
&lt;/h2&gt;

&lt;p&gt;Currently, C++ Core Guidelines Checker emits warnings to third-party libraries, and there are no settings to avoid it. (&lt;a href="https://stackoverflow.com/questions/45785126/selectively-disable-c-core-guidelines-checker-for-third-party-libraries"&gt;Microsoft recognizes this problem and working on it.&lt;/a&gt;)　To be specific, it emits warnings to GSL code when we use GSL. This behavior results in the flood of warnings to the code which are not mine. In order to avoid this, we need a wrapper of GSL, and we use GSL through the wrapper.&lt;/p&gt;

&lt;p&gt;The code of the wrapper of GSL is shown below. Here, some ifdefs of &lt;code&gt;_MSC_VER&lt;/code&gt; are because 1. &lt;code&gt;CppCoreCheck/warnings.h&lt;/code&gt; are created during VS 2017 installation, and 2. &lt;code&gt;#pragma&lt;/code&gt; directive for suppressing warnings are specific to MSVC.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#ifdef _MSC_VER
#if _MSC_VER &amp;gt;= 1910
#include &amp;lt;CppCoreCheck/warnings.h&amp;gt;
#pragma warning(disable: ALL_CPPCORECHECK_WARNINGS)
#endif // _MSC_VER &amp;gt;= 1910
#endif // _MSC_VER


#include &amp;lt;gsl/gsl&amp;gt;


#ifdef _MSC_VER
#if _MSC_VER &amp;gt;= 1910
#pragma warning(default: ALL_CPPCORECHECK_WARNINGS)
#endif // _MSC_VER &amp;gt;= 1910
#endif // _MSC_VER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Code example
&lt;/h1&gt;

&lt;p&gt;I created a code example.&lt;br&gt;
&lt;a href="https://github.com/TomoyukiAota/CoreCheckerAndGsl"&gt;https://github.com/TomoyukiAota/CoreCheckerAndGsl&lt;/a&gt;&lt;br&gt;
You should get something like this after the steps described above.&lt;/p&gt;

&lt;h1&gt;
  
  
  Afterword
&lt;/h1&gt;

&lt;p&gt;In this article, I described how to introduce C++ Core Guidelines Checker and GSL. I recognize that there is some awkwardness. C++ Core Guidelines Checker works only on VS on Windows. GSL is installed by copy and paste and a wrapper for suppressing warnings are required. However, I believe the warnings from C++ Core Guidelines Checker allows me to write better C++ code and GSL provides better types/functions, so I hope such awkwardness is cleared someday.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>gsl</category>
    </item>
  </channel>
</rss>
