<?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>Forem: Ahmy Yulrizka</title>
    <description>The latest articles on Forem by Ahmy Yulrizka (@yulrizka).</description>
    <link>https://forem.com/yulrizka</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%2F284886%2F17c0f426-4250-42bc-8978-5307e5e6a198.png</url>
      <title>Forem: Ahmy Yulrizka</title>
      <link>https://forem.com/yulrizka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yulrizka"/>
    <language>en</language>
    <item>
      <title>free and vmstat command</title>
      <dc:creator>Ahmy Yulrizka</dc:creator>
      <pubDate>Tue, 15 Jul 2025 11:09:32 +0000</pubDate>
      <link>https://forem.com/yulrizka/free-and-vmstat-command-1cde</link>
      <guid>https://forem.com/yulrizka/free-and-vmstat-command-1cde</guid>
      <description>&lt;p&gt;from: &lt;a href="https://fedoramagazine.org/system-insights-with-command-line-tools-free-and-vmstat/" rel="noopener noreferrer"&gt;https://fedoramagazine.org/system-insights-with-command-line-tools-free-and-vmstat/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  free
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ free -h
       total    used    free   shared  buff/cache  available
Mem:    23Gi    14Gi   575Mi    3,3Gi        12Gi      8,8Gi
Swap:  8,0Gi   6,6Gi   1,4Gi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Free parses /proc/meminfo and prints totals for physical memory and swap, along with kernel buffers and cache. Use -h for human-readable units, -s 1 to refresh every second, and -c N to stop after N samples which is handy to get a trend when doing something in parallel. For example, free -s 60 -c 1440 gives a 24-hour CSV-friendly record without installing extra monitoring daemons.&lt;/p&gt;

&lt;p&gt;Free memory refers to RAM that is entirely unoccupied. It isn’t being used by any process or for caching.&lt;/p&gt;

&lt;p&gt;Available memory, on the other hand, represents an estimate of how much memory can be used by new or running processes without resorting to swap. It includes free memory plus parts of the cache and buffers that the system can reclaim quickly if needed.&lt;/p&gt;

&lt;p&gt;It is not a problem to have a low free memory, &lt;strong&gt;available memory is usually what to be concerned about.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Spotting problems with free
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Rapidly shrinking available combined with rising swap used indicates real memory pressure.&lt;/li&gt;
&lt;li&gt;Large swap-in/out spikes point to thrashing workloads or runaway memory consumers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  vmstat
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vmstat 1 3
procs -----------memory----------     
 r  b   swpd   free   buff  cache     
 2  0 7102404 1392528     36 12335148 
 0  0 7102404 1392560     36 12335188 
 0  0 7102404 1373640     36 12349928 

 ---swap-- -----io---- 
  si   so    bi    bo  
   8   21   130   724  
   0    0     0     0  
   0    0     8    48  

 -system-- -------cpu-------
 in     cs us sy id wa st gu
 2851   19 15  7 77  0  0  0
 5779 7246 14 10 77  0  0  0
 5141 6525 12  9 79  0  0  0
&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;Procs
    r: The number of runnable processes (running or waiting
       for run time).
    b: The number of processes blocked waiting for I/O to
       complete.

Memory
    These are affected by the --unit option.
    swpd: the amount of swap memory used.
    free: the amount of idle memory.
    buff: the amount of memory used as buffers.
    cache: the amount of memory used as cache.
    inact: the amount of inactive memory.  (-a option)
    active: the amount of active memory.  (-a option)

Swap
    These are affected by the --unit option.
    si: Amount of memory swapped in from disk (/s).
    so: Amount of memory swapped to disk (/s).

IO
    bi: Kibibyte received from a block device (KiB/s).
    bo: Kibibyte sent to a block device (KiB/s).

System
    in: The number of interrupts per second, including
        the clock.
    cs: The number of context switches per second.

CPU
    These are percentages of total CPU time.
    us: Time spent running non-kernel code.  (user time,
        including nice time)
    sy: Time spent running kernel code.  (system time)
    id: Time spent idle.  Prior to Linux 2.5.41, this
        includes IO-wait time.
    wa: Time spent waiting for IO.  Prior to Linux 2.5.41,
        included in idle.
    st: Time stolen from a virtual machine.  Prior to
        Linux 2.6.11, unknown.
    gu: Time spent running KVM guest code (guest time,
        including guest nice).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Catching a memory leak
&lt;/h3&gt;

&lt;p&gt;Run vmstat 500 in one terminal while your suspect application runs in another. If free keeps falling and si/so climb over successive samples, physical RAM is being exhausted and the kernel starts swapping, which is classic leak behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding I/O saturation
&lt;/h3&gt;

&lt;p&gt;When wa (CPU wait) and bo (blocks out) soar while r remains modest, the CPU is idle but stuck waiting for the disk. Consider adding faster storage or tuning I/O scheduler parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Detecting CPU over-commit
&lt;/h3&gt;

&lt;p&gt;A sustained r that is double the number of logical cores with low wa and plenty of free means CPU is the bottleneck, not memory or I/O. Use top or htop to locate the busiest processes, or scale out workloads accordingly.&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>linux</category>
    </item>
    <item>
      <title>JQ: counting lenght of an array</title>
      <dc:creator>Ahmy Yulrizka</dc:creator>
      <pubDate>Wed, 30 Aug 2023 10:04:02 +0000</pubDate>
      <link>https://forem.com/yulrizka/jq-counting-lenght-of-an-array-1jla</link>
      <guid>https://forem.com/yulrizka/jq-counting-lenght-of-an-array-1jla</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '[{"username":"user1"},{"username":"user2"}]' | jq '. | length'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>todayilearned</category>
      <category>unix</category>
    </item>
    <item>
      <title>Fix gpg: WARNING: unsafe permissions on homedir</title>
      <dc:creator>Ahmy Yulrizka</dc:creator>
      <pubDate>Mon, 20 Feb 2023 11:00:12 +0000</pubDate>
      <link>https://forem.com/yulrizka/fix-gpg-warning-unsafe-permissions-on-homedir-3ka8</link>
      <guid>https://forem.com/yulrizka/fix-gpg-warning-unsafe-permissions-on-homedir-3ka8</guid>
      <description>&lt;p&gt;When you copy gpg configuration form other machine, you might get warning as follow&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpg: WARNING: unsafe permissions on homedir '/home/user/.gnupg'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To fix this, make sure that The &lt;code&gt;.gnupg&lt;/code&gt; directory has the correct permission.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chown -R $(whoami) ~/.gnupg/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And files &amp;amp; folder inside has the correct permisson&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find ~/.gnupg -type f -exec chmod 600 {} \; # Set 600 for files
find ~/.gnupg -type d -exec chmod 700 {} \; # Set 700 for directories
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>support</category>
      <category>indonesia</category>
    </item>
    <item>
      <title>grep: using input file as pattern to search other file</title>
      <dc:creator>Ahmy Yulrizka</dc:creator>
      <pubDate>Tue, 17 Jan 2023 09:05:28 +0000</pubDate>
      <link>https://forem.com/yulrizka/grep-using-input-file-as-pattern-to-search-other-file-19a7</link>
      <guid>https://forem.com/yulrizka/grep-using-input-file-as-pattern-to-search-other-file-19a7</guid>
      <description>&lt;p&gt;Sometimes we need to use another file which contains a multiple line that &lt;br&gt;
we want to use as input pattern&lt;/p&gt;

&lt;p&gt;example:&lt;/p&gt;

&lt;p&gt;You have &lt;code&gt;a.txt&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;a
b
c
d
e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you want to search &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This case you can create &lt;code&gt;input.txt&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;a
c
e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and use this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep -f -F input.txt a.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the input txt is a list of &lt;em&gt;regex&lt;/em&gt; you can remove the &lt;code&gt;-F&lt;/code&gt; option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; -F, --fixed-strings
              Interpret PATTERNS as fixed strings, not regular expressions.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discuss</category>
      <category>gratitude</category>
    </item>
    <item>
      <title>This article is published to Dev.to with github Action</title>
      <dc:creator>Ahmy Yulrizka</dc:creator>
      <pubDate>Mon, 02 Jan 2023 11:50:27 +0000</pubDate>
      <link>https://forem.com/yulrizka/this-article-is-published-to-devto-with-github-action-d27</link>
      <guid>https://forem.com/yulrizka/this-article-is-published-to-devto-with-github-action-d27</guid>
      <description>&lt;p&gt;Happy New year!&lt;/p&gt;

&lt;p&gt;I have been writing "Today I learned (TIL)" article for a while. These are short note about&lt;br&gt;
development things that I learned and stored as a collection of &lt;a href="https://github.com/yulrizka/til" rel="noopener noreferrer"&gt;markdown file in GitHub&lt;/a&gt;.&lt;br&gt;
I hosted it with &lt;a href="https://www.gitbook.com/" rel="noopener noreferrer"&gt;GitBook&lt;/a&gt; on &lt;a href="https://til.yulrizka.com" rel="noopener noreferrer"&gt;https://til.yulrizka.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As articles are already written in Markdown, I would like to have this synchronized to my &lt;a href="https://dev.to/yulrizka"&gt;Dev.to&lt;/a&gt; &lt;br&gt;
whenever there is update to the contents. The idea is to run a script on new commit that sync the change to Dev.to.&lt;/p&gt;

&lt;p&gt;So, I have created a small &lt;a href="https://github.com/yulrizka/til/blob/master/.scripts/main.go" rel="noopener noreferrer"&gt;golang script&lt;/a&gt; that triggered&lt;br&gt;
in a GitHub action workflow that does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Figure out markdown file that added or changed in the current commit.&lt;/li&gt;
&lt;li&gt;Fetch all articles from &lt;em&gt;Dev.to&lt;/em&gt; via an API.&lt;/li&gt;
&lt;li&gt;For each local article, compare it to Dev.to (using a canonical URL).&lt;/li&gt;
&lt;li&gt;Create or Update the article accordingly via the API.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is an example of the pipeline running &lt;a href="https://github.com/yulrizka/til/actions/runs/3812108410" rel="noopener noreferrer"&gt;https://github.com/yulrizka/til/actions/runs/3812108410&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wrote stuff about cli tricks, git, network, go, etc. Check out the full list on &lt;a href="https://til.yulrizka.com" rel="noopener noreferrer"&gt;https://til.yulrizka.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>coding</category>
      <category>debugging</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Easily checkout branch from checkout history with git-checkout-history</title>
      <dc:creator>Ahmy Yulrizka</dc:creator>
      <pubDate>Fri, 08 Jan 2021 14:20:20 +0000</pubDate>
      <link>https://forem.com/yulrizka/easily-checkout-branch-from-checkout-history-with-git-checkout-history-script-5eea</link>
      <guid>https://forem.com/yulrizka/easily-checkout-branch-from-checkout-history-with-git-checkout-history-script-5eea</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ks9hGfLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vbuizzhnu1pmuor8uo9q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ks9hGfLu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vbuizzhnu1pmuor8uo9q.gif" alt="Screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/yulrizka/git-checkout-history"&gt;https://github.com/yulrizka/git-checkout-history&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During development we sometime working on multiple branch at once. Switching between branches becoming a hassle because we need to specify the branch name each time.&lt;/p&gt;

&lt;p&gt;To Make it easier, i created this &lt;a href="https://github.com/yulrizka/git-checkout-history"&gt;git-checkout-history&lt;/a&gt; and with combination with &lt;a href="https://github.com/junegunn/fzf"&gt;fzf&lt;/a&gt; make changing branches a breeze. It remembers the order of the previous checkout so last checkout will come first. Changing branch also can done with up and down arrow and also support fuzzy search (you just need to type some part of the branch name).&lt;/p&gt;

&lt;p&gt;If you like the idea, please try it and let me know if something does not work.&lt;/p&gt;

&lt;p&gt;Tips: the command can be shorted with alias. Example for bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ alias gch="git checkout-history"
$ gch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>git</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
