<?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: gie3d</title>
    <description>The latest articles on DEV Community by gie3d (@gie3d).</description>
    <link>https://dev.to/gie3d</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%2F288316%2F494cb861-3b0e-48e8-a9f8-1de0e3dfb734.jpg</url>
      <title>DEV Community: gie3d</title>
      <link>https://dev.to/gie3d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gie3d"/>
    <language>en</language>
    <item>
      <title>Error Archiving iOS with watchOS project in xcode</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Thu, 25 Aug 2022 06:30:49 +0000</pubDate>
      <link>https://dev.to/gie3d/error-archiving-ios-with-watchos-project-in-xcode-2gj0</link>
      <guid>https://dev.to/gie3d/error-archiving-ios-with-watchos-project-in-xcode-2gj0</guid>
      <description>&lt;p&gt;The error shows during archiving project&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MBhgtY96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6fgeze4awzrnq2cudf8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MBhgtY96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6fgeze4awzrnq2cudf8.png" alt="Image description" width="880" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix this, I went to &lt;code&gt;Build Settings&lt;/code&gt; of the following targets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;watch app&lt;/li&gt;
&lt;li&gt;watchkit extension&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and updated the watch and watchkit extensions &lt;code&gt;Base SDK&lt;/code&gt; and &lt;code&gt;Supported Platforms&lt;/code&gt; to &lt;code&gt;watchOS&lt;/code&gt; (you can just search for &lt;code&gt;Base SKD&lt;/code&gt; in the search input textfield&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AjUl2Qh1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4v4ij408e6hpoovy8bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AjUl2Qh1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4v4ij408e6hpoovy8bi.png" alt="Image description" width="850" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and update the value inside&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zgDCVOVp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zd115cl6f5ownjqjypu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zgDCVOVp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zd115cl6f5ownjqjypu.png" alt="Image description" width="847" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watchos</category>
      <category>xcode</category>
      <category>applewatch</category>
    </item>
    <item>
      <title>My note on JS Timezone, Firebase Cloud Functions and Luxon</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Wed, 17 Aug 2022 12:32:00 +0000</pubDate>
      <link>https://dev.to/gie3d/my-note-on-js-timezone-firebase-cloud-functions-and-luxon-4cnc</link>
      <guid>https://dev.to/gie3d/my-note-on-js-timezone-firebase-cloud-functions-and-luxon-4cnc</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Functions:&lt;/strong&gt; No matter what your defined region in cloud functions, the default timezone is UTC.&lt;/li&gt;
&lt;li&gt;Firebase Console shows date time based on your device region setting.&lt;/li&gt;
&lt;li&gt;Default Luxon .setZone (keepLocalTime: false) doesn't change the underlying timestamp
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TZ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UTC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;startDay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1660738904&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;d1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;d2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;day&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;d3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UTC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;day&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;d4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asia/Bangkok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;day&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// 2022-08-17T12:21:44.000+00:00&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// 2022-08-17T00:00:00.000+00:00&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// 2022-08-17T00:00:00.000Z&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// 2022-08-17T00:00:00.000+07:00&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the example above, I used the default setZone to set different timezones from the same timestamp and monitor the result. On the first line, I set the console timezone to UTC to match with what has been configured on Cloud Functions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;d4&lt;/code&gt; after setZone to Bangkok and set time to start of day, so it will set the time to 00:00:00 GMT+7 (it's 17:00:00 GMT+0)&lt;/p&gt;

&lt;p&gt;The computation after setZone will respect the timezone that we set &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;startOf('day') will be start of the day based on Bangkok timezone&lt;/li&gt;
&lt;li&gt;.toString() will print the time based on Bangkok timezone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similar to &lt;code&gt;d3&lt;/code&gt; that the computation after setZone will respect the timezone as UTC.&lt;/p&gt;

&lt;p&gt;However, if we use &lt;code&gt;setZone('Asia/Bangkok', { keepLocalTime: true})&lt;/code&gt;. It will change the underlying timestamp.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TZ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UTC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;startDay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1660738904&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toSeconds&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="c1"&gt;// 1660738904&lt;/span&gt;


&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asia/Bangkok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toSeconds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// 1660738904&lt;/span&gt;


&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asia/Bangkok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;keepLocalTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toSeconds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// 1660713704&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above example, the first and second give the same timestamp. But for the third, it changes the timestamp to reflect the same time with different timezone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TZ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UTC&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;startDay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1660738904&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="c1"&gt;// 2022-08-17T12:21:44.000+00:00&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asia/Bangkok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// 2022-08-17T19:21:44.000+07:00&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startDay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Asia/Bangkok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;keepLocalTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// 2022-08-17T12:21:44.000+07:00 --&amp;gt; try to keep the time 12:21:44 with timezone to GMT+7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>firebase</category>
      <category>javascript</category>
      <category>luxon</category>
      <category>datetime</category>
    </item>
    <item>
      <title>Add an Apple Watch Target on Flutter app</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Wed, 20 Jul 2022 16:06:42 +0000</pubDate>
      <link>https://dev.to/gie3d/add-an-apple-watch-target-on-flutter-app-3m0m</link>
      <guid>https://dev.to/gie3d/add-an-apple-watch-target-on-flutter-app-3m0m</guid>
      <description>&lt;p&gt;Refer from the Flutter document: &lt;a href="https://docs.flutter.dev/development/platform-integration/ios/apple-watch" rel="noopener noreferrer"&gt;https://docs.flutter.dev/development/platform-integration/ios/apple-watch&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First off, you need to follow the instruction provided in the Flutter document (link above) first.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Enable bitcode in Xcode&lt;br&gt;
Apple Watch targets require bitcode to be enabled, so follow the steps in &lt;a href="https://github.com/flutter/flutter/wiki/Creating-an-iOS-Bitcode-enabled-app" rel="noopener noreferrer"&gt;Creating an iOS Bitcode enabled app&lt;/a&gt; to use bitcode in your app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add an Apple Watch target&lt;br&gt;
In the menu, select File &amp;gt; New &amp;gt; Target. Once the dialog opens, select watchOS at the top and click Watch App for iOS App. Click Next, enter a product name, and select Enter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you run the project using a usual command &lt;code&gt;flutter run&lt;/code&gt;. You will get the error like this&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# flutter run                                                                                                                                                     
Launching lib/main.dart on iPhone 13 Pro in debug mode...
Running Xcode build...                                          
Xcode build done.                                            2.1s
Failed to build iOS app
Error output from Xcode build:
↳
    2022-07-20 23:02:24.107 xcodebuild[18239:137665] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-07-20 23:02:24.108 xcodebuild[18239:137665] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/_6/2nt5c3lx2tbc9bkg1vkb5tfm0000gp/T/flutter_tools.zDoJxh/flutter_ios_build_temp_dirlIvUEW/temporary_xcresult_bundle

    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator' (in target 'watch' from project 'Runner')
    error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator' (in target 'watch' from project 'Runner')
    error: Couldn't look up product type 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator' (in target 'watch' from project 'Runner')
    warning: duplicate output file '' on task: RegisterExecutionPolicyException /Users/gie/Develops/test/flutter/app_watch/build/ios/Debug-iphonesimulator (in target 'watch' from project 'Runner')
    error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'watch WatchKit Extension' from project 'Runner')
    error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'watch WatchKit Extension' from project 'Runner')
    error: Couldn't look up product type 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator' (in target 'watch WatchKit Extension' from project 'Runner')

    Result bundle written to path:
        /var/folders/_6/2nt5c3lx2tbc9bkg1vkb5tfm0000gp/T/flutter_tools.zDoJxh/flutter_ios_build_temp_dirlIvUEW/temporary_xcresult_bundle


Error (Xcode): unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator'

Error (Xcode): Couldn't look up product type 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator'

Error (Xcode): unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator'

Error (Xcode): Couldn't look up product type 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator'

Could not build the application for the simulator.
Error launching application on iPhone 13 Pro.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;What you need to do is to update the WatchKit Extension by providing it the &lt;code&gt;WKCompanionAppBundleIdentifier&lt;/code&gt; by using the following code:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;key&amp;gt;WKCompanionAppBundleIdentifier&amp;lt;/key&amp;gt;
&amp;lt;string&amp;gt;$(PRODUCT_BUNDLE_IDENTIFIER)&amp;lt;/string&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5s5edgyt4ykcr9w0hfag.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5s5edgyt4ykcr9w0hfag.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clean and rerun your project again
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter clean
flutter run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>flutter</category>
      <category>applewatch</category>
    </item>
    <item>
      <title>Renew letsencrypt cert and import to Spring project</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Wed, 25 May 2022 04:21:49 +0000</pubDate>
      <link>https://dev.to/gie3d/renew-letsencrypt-cert-and-import-to-spring-project-28gl</link>
      <guid>https://dev.to/gie3d/renew-letsencrypt-cert-and-import-to-spring-project-28gl</guid>
      <description>&lt;p&gt;Renew cert&lt;br&gt;
&lt;code&gt;certbot renew&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or if you want to force renew&lt;br&gt;
&lt;code&gt;certbot renew --force-renew&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@server ~]# certbot renew --force-renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/yourdomain.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Renewing an existing certificate for yourdomain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all renewals succeeded:
  /etc/letsencrypt/live/yourdomain.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Go to &lt;code&gt;/etc/letsencrypt/live/yourdomain.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Convert the keys to PKCS12 using OpenSSL
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out keystore.p12 -name tomcat -CAfile chain.pem -caname root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Enter your password for the key
The file keystore.p12 with PKCS12 is now generated in /etc/letsencrypt/live/yourdomain.com.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure your server ssl key-store is pointed to the location your .p12 key created&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server.port: 8443
security.require-ssl=true
server.ssl.key-store:/etc/letsencrypt/live/example.com/keystore.p12
server.ssl.key-store-password: &amp;lt;your-password&amp;gt;
server.ssl.keyStoreType: PKCS12
server.ssl.keyAlias: tomcat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>letsencrypt</category>
      <category>cert</category>
      <category>springboot</category>
    </item>
    <item>
      <title>Back up &amp; restore postgres</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Mon, 23 May 2022 13:49:42 +0000</pubDate>
      <link>https://dev.to/gie3d/back-up-restore-postgres-2l0n</link>
      <guid>https://dev.to/gie3d/back-up-restore-postgres-2l0n</guid>
      <description>&lt;p&gt;Back up&lt;br&gt;
&lt;code&gt;pg_dump -F c testdb &amp;gt; testdb.dump&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Restore&lt;br&gt;
&lt;code&gt;pg_restore -d testdb testdb.dump&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>MacBook Pro,  how to select discrete graphics card or integrated graphics card</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Fri, 22 Oct 2021 03:19:33 +0000</pubDate>
      <link>https://dev.to/gie3d/macbook-pro-how-to-select-discrete-graphics-card-or-integrated-graphics-card-4f55</link>
      <guid>https://dev.to/gie3d/macbook-pro-how-to-select-discrete-graphics-card-or-integrated-graphics-card-4f55</guid>
      <description>&lt;p&gt;Apple only provides an option to let them choose the best graphics models while you're running on battery.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6glhdh832hw559o8jr2e.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6glhdh832hw559o8jr2e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But sometimes, many times... actually, I really need to be up with battery longer than 3-4 hours. Discrete graphic is one of the most battery consuming in my MBP. So, occasionally, I need to find a way to shut it off. (It may sound silly that you paid for a high performance graphic card, and you want to shut it off 🤧)&lt;/p&gt;

&lt;p&gt;Did some quick research and found a command (from &lt;a href="https://nathansnelgrove.com/how-to-force-your-macbook-pro-to-use-its-discrete-graphics-card-when-its-plugged-in/):" rel="noopener noreferrer"&gt;https://nathansnelgrove.com/how-to-force-your-macbook-pro-to-use-its-discrete-graphics-card-when-its-plugged-in/):&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;# Always use the integrated graphics card while running on battery power
sudo pmset -b gpuswitch 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;gpuswitch has 3 options&lt;/p&gt;

&lt;p&gt;0 - use integrated graphics card&lt;br&gt;
1 - use discrete graphics card&lt;br&gt;
2 - automatically switch between discrete and integrated graphics card (default option)&lt;/p&gt;

&lt;p&gt;and &lt;br&gt;
-b - battery&lt;br&gt;
-c - plugged&lt;br&gt;
-a - both battery and plugged&lt;/p&gt;

&lt;p&gt;Hope I could be up with battery a bit longer...😥&lt;/p&gt;

</description>
      <category>macbookpro</category>
      <category>battery</category>
    </item>
    <item>
      <title>Set SSH client timeout </title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Wed, 21 Jul 2021 08:13:35 +0000</pubDate>
      <link>https://dev.to/gie3d/set-ssh-client-timeout-5h2g</link>
      <guid>https://dev.to/gie3d/set-ssh-client-timeout-5h2g</guid>
      <description>&lt;p&gt;It's configured at&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;change the value of this setting &lt;code&gt;ClientAliveInterval&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and then restart ssh&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service sshd restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>timeout</category>
    </item>
    <item>
      <title>cannot run an app test in XCode IDEDebugSessionErrorDomain</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Wed, 14 Jul 2021 17:45:30 +0000</pubDate>
      <link>https://dev.to/gie3d/cannot-run-an-app-test-in-xcode-idedebugsessionerrordomain-5hid</link>
      <guid>https://dev.to/gie3d/cannot-run-an-app-test-in-xcode-idedebugsessionerrordomain-5hid</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BCMQm4fZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qxrviiha01kzl50nr74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BCMQm4fZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qxrviiha01kzl50nr74.png" alt="2021-07-15 at 12.39 AM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my case, I ran the following command in the terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo DevToolsSecurity -enable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and boom! the problem got fixed&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to add image to drawable in Android Studio</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Wed, 14 Jul 2021 13:39:11 +0000</pubDate>
      <link>https://dev.to/gie3d/how-to-add-image-to-drawable-in-android-studio-5cmi</link>
      <guid>https://dev.to/gie3d/how-to-add-image-to-drawable-in-android-studio-5cmi</guid>
      <description>&lt;ol&gt;
&lt;li&gt;Open Project&lt;/li&gt;
&lt;li&gt;&lt;p&gt;View as Android&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0qiT6XTp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlz32ywlf5rdlglutxkq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0qiT6XTp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlz32ywlf5rdlglutxkq.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Resource Manager&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KJmwYbsS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czyqqiesyu6qkuejuwhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KJmwYbsS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czyqqiesyu6qkuejuwhg.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Press + and select "Import Drawables"  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select a picture&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Press Next&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Review and press Import&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>android</category>
      <category>drawable</category>
      <category>androidstudio</category>
    </item>
    <item>
      <title>Multi python versions on Mac using pyenv</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Tue, 05 Jan 2021 02:50:04 +0000</pubDate>
      <link>https://dev.to/gie3d/multi-python-versions-on-mac-using-pyenv-15b8</link>
      <guid>https://dev.to/gie3d/multi-python-versions-on-mac-using-pyenv-15b8</guid>
      <description>&lt;h2&gt;
  
  
  install using Homebrew
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew update
&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;brew install pyenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configure your Mac's environment
&lt;/h2&gt;

&lt;p&gt;Depends on your shell (mine was zsh)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'eval "$(pyenv init -)"' &amp;gt;&amp;gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Activate the change&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install a version of Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv install python3.4.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Set your environment python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv local python3.4.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
    </item>
    <item>
      <title>Unix commands cheat sheet</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Sun, 22 Nov 2020 14:37:18 +0000</pubDate>
      <link>https://dev.to/gie3d/kill-all-jmeter-executions-26jj</link>
      <guid>https://dev.to/gie3d/kill-all-jmeter-executions-26jj</guid>
      <description>&lt;h3&gt;
  
  
  Kill all jMeter (or any processes) executions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ps -ef | grep jmeter | awk '{print $2}' | xargs kill -9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be applied to any other processes running to. Just replace &lt;code&gt;grep jmeter&lt;/code&gt; to &lt;code&gt;grep your-process-name&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Stop a service running on a specified port
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat -vanp tcp | grep &amp;lt;port&amp;gt; | awk '{print $9}' | xargs kill -9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remove docker images according to a pattern
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker images -a | grep &amp;lt;pattern&amp;gt; | awk '{print $3}' | xargs docker rmi -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Detect user idle in react-native</title>
      <dc:creator>gie3d</dc:creator>
      <pubDate>Fri, 06 Nov 2020 04:36:58 +0000</pubDate>
      <link>https://dev.to/gie3d/detect-user-idle-in-react-native-5fci</link>
      <guid>https://dev.to/gie3d/detect-user-idle-in-react-native-5fci</guid>
      <description>&lt;p&gt;One of requirements in an app with sensitive data is to force user to logout if the user has been idle for certain amount of time. By idle, I mean the user doesn't touch anything in the app. Normally, we use &lt;code&gt;Touchable*&lt;/code&gt; to detect a user press event. But we cannot apply this on top of another element because it will override all touch event on the pages and your app won't be functional. After a brief research, I found that we can use &lt;code&gt;PanResponder&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My strategy is to apply &lt;code&gt;PanResponser&lt;/code&gt; on top of the app. We start a &lt;code&gt;setTimeout&lt;/code&gt; with a certain amount of time (supposed to be configurable) during the user opens the app. Whenever the user presses anywhere on the screen, we &lt;code&gt;clearTimeout&lt;/code&gt; and reset it. Note that I used &lt;code&gt;onStartShouldSetPanResponderCapture&lt;/code&gt; of &lt;code&gt;PanResponser&lt;/code&gt; event to detect user touch event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PanResponder&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AppContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timerId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;timeForInactivityInSecond&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setTimeForInactivityInSecond&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="mi"&gt;3600&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;resetInactivityTimeout&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;panResponder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;PanResponder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;onStartShouldSetPanResponderCapture&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// console.log('user starts touch');&lt;/span&gt;
        &lt;span class="nx"&gt;resetInactivityTimeout&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="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resetInactivityTimeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timerId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;timerId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// action after user has been detected idle&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;timeForInactivityInSecond&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt; &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="nx"&gt;panResponder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;panHandlers&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* &amp;lt;YourApp {...props} /&amp;gt; */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AppContainer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>reactnative</category>
    </item>
  </channel>
</rss>
