<?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: sean2024</title>
    <description>The latest articles on DEV Community by sean2024 (@sean2024).</description>
    <link>https://dev.to/sean2024</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%2F2457716%2F8c13cf5e-a63b-4d34-acbe-f7c268d465a3.jpg</url>
      <title>DEV Community: sean2024</title>
      <link>https://dev.to/sean2024</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sean2024"/>
    <language>en</language>
    <item>
      <title>Day 10: ls -l *</title>
      <dc:creator>sean2024</dc:creator>
      <pubDate>Thu, 28 Nov 2024 18:39:58 +0000</pubDate>
      <link>https://dev.to/sean2024/day-10-ls-l--40i4</link>
      <guid>https://dev.to/sean2024/day-10-ls-l--40i4</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hey all.  I was recently asked this question:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;describe what happens when &lt;code&gt;ls -l *&lt;/code&gt; is run on the Linux command line&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My description was very wrong.  But, now that I've got some time and room to learn a bit more, I've taken a few minutes to write up the actual answer.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Listing in Bash on Linux
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The &lt;em&gt;Actual&lt;/em&gt; Output
&lt;/h3&gt;

&lt;p&gt;Here's an example of the output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜  pwd $ ls -l *
-rw-r--r--@ 1 user  group    0 Month 01 14:05 LICENSE
-rw-r--r--@ 1 user  group  202 Month 01 14:05 go.mod
-rw-r--r--@ 1 user  group  896 Month 01 14:05 go.sum
-rw-r--r--@ 1 user  group  138 Month 01 14:05 main.go

cmd:
total 8
-rw-r--r--@ 1 user  group  1444 Month 01 14:05 root.go

internal:
total 16
-rw-r--r--@ 1 user  group   37 Month 01 16:05 main.go
-rw-r--r--@ 1 user  group  225 Month 01 14:10 main_test.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some things we see so far:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It shows the current working directory and all its non-hidden contents.
&lt;/li&gt;
&lt;li&gt;It shows permissions of the files in symbolic notation (as opposed to file mode notation like 0755).  These permissions include owner, group, and other permissions (in that order) along with &lt;code&gt;@&lt;/code&gt; indicating extended attributes like for SELinux.
&lt;/li&gt;
&lt;li&gt;It shows the total number of child elements below each directory child below the current working directory (pwd).
&lt;/li&gt;
&lt;li&gt;This listing shows the user and group indicated on the child (file or dir)&lt;/li&gt;
&lt;li&gt;The last mod date/time for the file.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How does &lt;code&gt;ls&lt;/code&gt; get this information?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stat&lt;/code&gt; - for getting file and directory info for each item listed, even with symbolic links and not using the &lt;code&gt;-l&lt;/code&gt; (long-listing) option.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lstat&lt;/code&gt; - for getting metadata information for when using &lt;code&gt;-l&lt;/code&gt; (long-listing) on symbolic link file types.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code Sample
&lt;/h2&gt;

&lt;p&gt;In an attempt to implement &lt;code&gt;ls&lt;/code&gt; with &lt;code&gt;-l&lt;/code&gt; support in go, &lt;a href="https://github.com/sochoa/go-ls/blob/main" rel="noopener noreferrer"&gt;here&lt;/a&gt; is a code sample.&lt;/p&gt;

&lt;h3&gt;
  
  
  What were the difficult parts?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mode Parsing&lt;/strong&gt; - Here's the &lt;code&gt;stat_t&lt;/code&gt; &lt;a href="https://github.com/sochoa/go-ls/blob/main/internal/stat/stat.go#L82-L98" rel="noopener noreferrer"&gt;mode parsing&lt;/a&gt; section.  The hardest part here was to find the right order of parsing.  Some of these file types are also other file types.    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Lookup&lt;/strong&gt; - It turns out that some user lookups fail.  That was annoying, so I had to fail over to "unknown".  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Permissions&lt;/strong&gt; - Parsing permissions so that it was understandable in the application layer was an interesting challenge.  Mostly it was difficult to explain through well-named variable names the concept of  single integer values being used to represent a series of values.  This is interesting as a single integer can be converted to binary and be used to indicate enum values within range of the original value's binary equivilent.  There were two operations that I ended up using to read the binary values: &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;bit shifting to the right (&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;) - This removed the parts of the binary value of the original int so that the resulting shifted value can be &lt;code&gt;&amp;amp;&lt;/code&gt;-ed with the offset of the part of the original value that we are looking for.
&lt;/li&gt;
&lt;li&gt;bit is set via bitmask (&lt;code&gt;&amp;amp;&lt;/code&gt;) - When the value is shifted to the right so that the resulting value when &lt;code&gt;v &amp;amp; offset == offset&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symbolic Link De-referencing&lt;/strong&gt; - The interesting part here was checking for link loops and then having a test confirming successful detection.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In all, this experiment was very informative.  Learning how to parse integer values with bit-wise offsets and then to apply bit-mask in order to determine if a value is set is an interesting and efficient technique.  &lt;/p&gt;

</description>
      <category>sre</category>
      <category>linux</category>
      <category>filesystems</category>
    </item>
    <item>
      <title>Day 2: Leetcode</title>
      <dc:creator>sean2024</dc:creator>
      <pubDate>Wed, 20 Nov 2024 04:55:20 +0000</pubDate>
      <link>https://dev.to/sean2024/day-2-leetcode-4102</link>
      <guid>https://dev.to/sean2024/day-2-leetcode-4102</guid>
      <description>&lt;p&gt;Hey everyone!&lt;/p&gt;

&lt;p&gt;I'm thrilled to share that I've embarked on a journey to level up my coding skills, and today marks Day 2 of this adventure. 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  My Study Goals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Solve 3-9 Medium to Hard Leetcode Problems Daily&lt;/li&gt;
&lt;li&gt;Pushing myself with challenging problems to sharpen my problem-solving abilities.&lt;/li&gt;
&lt;li&gt;Deep Dive into Each Problem&lt;/li&gt;
&lt;li&gt;Not just aiming for the correct answer but truly understanding the underlying concepts and multiple solution approaches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Dedicated Study Time
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;2 Hours Daily on coding problems.&lt;/li&gt;
&lt;li&gt;2 Hours Weekly on system design to broaden my architectural knowledge.&lt;/li&gt;
&lt;li&gt;2 Hours Weekly on a personal project:

&lt;ul&gt;
&lt;li&gt;Possibly developing a library that could benefit my team at work (unrelated to actual work projects).&lt;/li&gt;
&lt;li&gt;Alternatively, creating something to deepen my understanding of the network layer.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Coin Jar Motivation
&lt;/h2&gt;

&lt;p&gt;To keep myself motivated, I've started a fun ritual. For every problem I solve, I drop a coin into a jar.  My monthly goal is to fill up the jar each quarter (no pun intended).  It's a tangible way to visualize my progress and stay committed. Plus, who doesn't love the satisfying clink of a coin dropping after cracking a tough problem?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I'm Sharing This
&lt;/h2&gt;

&lt;p&gt;I believe that documenting and sharing my journey will... &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hold Me Accountable -  Knowing that others are following along encourages me to stay on track.&lt;/li&gt;
&lt;li&gt;Help Others - Maybe my experiences, struggles, and triumphs can inspire or assist someone else on a similar path.&lt;/li&gt;
&lt;li&gt;Build Community - I'd love to connect with others who are also preparing for interviews or looking to improve their skills.
## Looking Ahead&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm excited about this effort, and I know that consistency is key. I'll be sharing regular updates on my progress, insights from the problems I tackle, and any tips or resources I find helpful.  &lt;/p&gt;

</description>
      <category>programming</category>
      <category>interview</category>
      <category>study</category>
    </item>
  </channel>
</rss>
