<?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: Dzung Nguyen</title>
    <description>The latest articles on DEV Community by Dzung Nguyen (@dzunguy).</description>
    <link>https://dev.to/dzunguy</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%2F576013%2Fab6cdba2-f31d-4467-9f86-5700da46a002.jpeg</url>
      <title>DEV Community: Dzung Nguyen</title>
      <link>https://dev.to/dzunguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dzunguy"/>
    <language>en</language>
    <item>
      <title>Developers to follow on Twitter?</title>
      <dc:creator>Dzung Nguyen</dc:creator>
      <pubDate>Sun, 28 Feb 2021 21:47:40 +0000</pubDate>
      <link>https://dev.to/dzunguy/developers-to-follow-on-twitter-450f</link>
      <guid>https://dev.to/dzunguy/developers-to-follow-on-twitter-450f</guid>
      <description>&lt;p&gt;Hi Devs,&lt;/p&gt;

&lt;p&gt;Recently I started using the blue bird talking app but I don't know how to find people to follow. If you're also on Twitter, would you mind recommending some tech people?&lt;/p&gt;

&lt;p&gt;All the best&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Shortcuts can take you longer</title>
      <dc:creator>Dzung Nguyen</dc:creator>
      <pubDate>Fri, 26 Feb 2021 19:13:56 +0000</pubDate>
      <link>https://dev.to/dzunguy/shortcuts-can-take-you-longer-5c8j</link>
      <guid>https://dev.to/dzunguy/shortcuts-can-take-you-longer-5c8j</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eaO8GU6p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sc98v6a2zzlxlp1nb22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eaO8GU6p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sc98v6a2zzlxlp1nb22.png" alt="Shortcuts can take you longer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yesterday my manager pinged me at 5pm about an urgent task. He's a big advocate of work life balance, so if he asks you something at 5pm, it must be important.&lt;/p&gt;

&lt;p&gt;The task was straightforward. To not revealing anything about the business, all I could say is that it's an analogy of "for all tables, find all rows where column &lt;code&gt;fruit&lt;/code&gt; = &lt;code&gt;BlueBerry&lt;/code&gt;".&lt;/p&gt;

&lt;p&gt;"The task is urgent. It's 5 pm. What's the &lt;em&gt;shortcut&lt;/em&gt;?" - I thought.&lt;/p&gt;

&lt;p&gt;"No way I would write a script now. Let's get the task done." - I reminded myself of &lt;a href="https://xkcd.com/1205/"&gt;that xkcd&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since the query was simple, and not all tables contain the column &lt;code&gt;fruit&lt;/code&gt;, so my shortcut was opening DataGrip, visually checking each table to see if they have that column, and executing this query &lt;code&gt;select count(*) from &amp;lt;table&amp;gt; where fruit = 'BlueBerry'&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It sounded easy-peasy and it just required some patient, right? Turned out it was not a shortcut at all.&lt;/p&gt;

&lt;p&gt;As we didn't create index for those columns, the query took 2 minute per table. I had to open many DataGrip query consoles and fired up a spreadsheet to keep track of the progress.&lt;/p&gt;

&lt;p&gt;And worse, half way done I noticed that there was a table where the column was &lt;code&gt;fruit_code&lt;/code&gt;, not &lt;code&gt;fruit&lt;/code&gt;. Shoot! I must have missed similar columns. Now I had to restart the progress. And it was officially a big mess.&lt;/p&gt;

&lt;p&gt;If I had not made a shortcut, if I had put more thoughts and "over-engineered" it, I would've written a script that queried the catalog to find the tables containing &lt;code&gt;%fruit%&lt;/code&gt;-like column, then ran the &lt;code&gt;select count(*)&lt;/code&gt; for each of those tables. I would be able to run the select queries in parallel after I realized they were slow. If I made a mistake, I would be able to correct it by modifying and re-running the script. These were many benefits of a proper script, and I haven't talked anything about reusability.&lt;/p&gt;

&lt;p&gt;This was not the first time my short term solutions had caused more harm than good. There's nothing wrong with taking shortcuts when the timeline is tight. My mistakes are setting completion time expectation too tight, and letting that fake urgency affects my judgements.&lt;/p&gt;

&lt;p&gt;Let's talk about deadline. Almost all deadlines in American corporates are artificial. Teams delay their projects all the time, and even if they deliver it's usually a simplified version compared to their plan. If I had to simplify my job descriptions, it would be displaying some data from a database to some business persons' screens. What could go wrong if I take several more hours to complete a task? If a task were that important and urgent to them, they would have create a high severity ticket and escalate it.&lt;/p&gt;

&lt;p&gt;Urgency does have benefits. For me it could ignite some fire and make me focus easier. But be mindful when you start taking shortcuts. It's not the shortcuts that are harmful, it's the lazy thinking you start having when you say yes to shortcuts. Lazy thinking could lead you to the longer roads, and sometimes the wrong ones.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Coding Diary 1: Time zones and Python datetime</title>
      <dc:creator>Dzung Nguyen</dc:creator>
      <pubDate>Mon, 08 Feb 2021 19:49:47 +0000</pubDate>
      <link>https://dev.to/dzunguy/coding-diary-1-understanding-time-zones-and-python-datetime-s-timezone-5421</link>
      <guid>https://dev.to/dzunguy/coding-diary-1-understanding-time-zones-and-python-datetime-s-timezone-5421</guid>
      <description>&lt;p&gt;After a decade of surviving without understanding time zone properly, I've managed to learn about the topic today. I also learnt how to use Python datetime with timezone information.&lt;/p&gt;

&lt;p&gt;I had always thought that time zones were something like UTC+7. Turned out it was wrong. It's a time offset, and time offsets are different from time zones.&lt;/p&gt;

&lt;p&gt;A time offset is a number of hours before or after UTC. In some case an offset can be a number of hours and minutes. Examples of offsets are UTC-0500, UTC+0600, etc. With your time zone's offset, you can translate between UTC time and your time. Let's say you're living in Seattle summer, your offset will be UTC-0700. That means at UTC 00:00, you're still in the previous day at 17:00. When you're at 00:00, the UTC time is 07:00.&lt;/p&gt;

&lt;p&gt;A time zone is a region on Eeath where every one shares a same clock. A time zone contains a location-related name or an identifier, and usually one offset. In some case a time zone can contain multiple offsets. I call those "umbrella" time zones, as they contain multiple time zones. Pacific time zone is such an "umbrella" one. It contains PDT and PST. Examples of time zones are "Central Standard Time", "Pacific Daylight Time", etc.&lt;/p&gt;

&lt;p&gt;The West like complicating things so they change their time zone every 6 months.&lt;/p&gt;

&lt;p&gt;There are a couple of time zone databases. The standard one, that is implemented in Linux, Mac, and most programming languages, is IANA/Olso Time Zone Database, AKA the TZ database. Identifiers in this database is super familiar, such as "America/Los_Angeles". The other database is a Microsoft one and I've decided to ignore it for now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python datetime
&lt;/h2&gt;

&lt;p&gt;The Python datetime class, &lt;code&gt;from datetime import datetime&lt;/code&gt;, can be either 'naive' or timezone-aware. By default, &lt;code&gt;datetime&lt;/code&gt; objects are naive, as they don't contain any timezone information. We can make it aware of time zones by setting non-null &lt;code&gt;tzinfo&lt;/code&gt; attribute to the objects. &lt;code&gt;pytz&lt;/code&gt; is a common implementation of &lt;code&gt;tzinfo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Following code shows that, by default, &lt;code&gt;datetime&lt;/code&gt; objects are "naive":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; from datetime import datetime
&amp;gt;&amp;gt;&amp;gt; now = datetime.now()
&amp;gt;&amp;gt;&amp;gt; print(now)
2021-01-30 21:58:20.419069
&amp;gt;&amp;gt;&amp;gt; print(now.tzinfo)
None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can make it timezone-aware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; now_with_tz = datetime.now(tz=pytz.timezone('America/New_York'))
&amp;gt;&amp;gt;&amp;gt; print(now.hour, now_with_tz.hour)
21 1
&amp;gt;&amp;gt;&amp;gt; now_with_tz.tzinfo
&amp;lt;DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
