<?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: Chris Yau</title>
    <description>The latest articles on DEV Community by Chris Yau (@calculatornow).</description>
    <link>https://dev.to/calculatornow</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4235615%2F028c38e9-24a5-4edb-9f84-7a9ba7e96974.png</url>
      <title>DEV Community: Chris Yau</title>
      <link>https://dev.to/calculatornow</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/calculatornow"/>
    <language>en</language>
    <item>
      <title>Handy calculators for developers: chmod, CIDR, hex, Unix time and more</title>
      <dc:creator>Chris Yau</dc:creator>
      <pubDate>Mon, 09 Nov 2026 17:31:09 +0000</pubDate>
      <link>https://dev.to/calculatornow/handy-calculators-for-developers-chmod-cidr-hex-unix-time-and-more-3f7h</link>
      <guid>https://dev.to/calculatornow/handy-calculators-for-developers-chmod-cidr-hex-unix-time-and-more-3f7h</guid>
      <description>&lt;p&gt;I'm Chris Yau, and I built &lt;a href="https://calculator.now/" rel="noopener noreferrer"&gt;Calculator.now&lt;/a&gt;, a free site with a large collection of online calculators. Most of the site is personal finance, health and school maths, but there's a corner of it I use every week as a developer: the tech calculators.&lt;/p&gt;

&lt;p&gt;None of these do anything you couldn't do with a shell one-liner. When I'm on a deploy call, reviewing a Terraform plan or answering "why is this file 403-ing?", I just want the answer &lt;em&gt;and&lt;/em&gt; the working on one screen, so I can paste it into a ticket. Here are six I use most, with a worked example for each and a snippet you can use to check the result yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. chmod: octal ⇄ symbolic ⇄ binary
&lt;/h2&gt;

&lt;p&gt;Every permission digit is just three bits: read = 4, write = 2, execute = 1. Add them up per class (owner, group, others) and you've got the octal mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Worked example:&lt;/strong&gt; a config file the app user can edit, its group can read, and nobody else can touch.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;r&lt;/th&gt;
&lt;th&gt;w&lt;/th&gt;
&lt;th&gt;x&lt;/th&gt;
&lt;th&gt;Sum&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Owner&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Group&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Others&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So it's &lt;code&gt;640&lt;/code&gt;, or &lt;code&gt;rw-r-----&lt;/code&gt;, or &lt;code&gt;u=rw,g=r,o=&lt;/code&gt; in symbolic form.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;640 config/app.env
&lt;span class="nb"&gt;stat&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'%a %A'&lt;/span&gt; config/app.env   &lt;span class="c"&gt;# 640 -rw-r-----&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://calculator.now/chmod-calculator/" rel="noopener noreferrer"&gt;chmod calculator&lt;/a&gt; lets you work from checkboxes, symbolic notation (&lt;code&gt;u=rwx,g=rx,o=r&lt;/code&gt;) or a 3- or 4-digit octal number. It gives you the &lt;code&gt;chmod&lt;/code&gt; command ready to copy, plus the binary form (&lt;code&gt;110 100 000&lt;/code&gt;) and an &lt;code&gt;rwx&lt;/code&gt; visual. It also handles SUID, SGID and the sticky bit, and has one-click presets for 755, 644, 700, 600 and the rest. The binary view helps when you're explaining to a junior dev why &lt;code&gt;777&lt;/code&gt; is a bad idea.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. CIDR blocks and subnets
&lt;/h2&gt;

&lt;p&gt;Every time I have to size a VPC subnet I end up re-deriving the same formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;total addresses = 2^(32 − prefix)
usable hosts    = 2^(32 − prefix) − 2   (except /31 and /32)
network         = IP AND mask
broadcast       = network OR wildcard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Worked example:&lt;/strong&gt; &lt;code&gt;10.20.0.0/22&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subnet mask: &lt;code&gt;255.255.252.0&lt;/code&gt; (wildcard &lt;code&gt;0.0.3.255&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Total addresses: 2^10 = &lt;strong&gt;1,024&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Usable hosts: &lt;strong&gt;1,022&lt;/strong&gt; (&lt;code&gt;10.20.0.1&lt;/code&gt; to &lt;code&gt;10.20.3.254&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Broadcast: &lt;code&gt;10.20.3.255&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can sanity-check that in Python's standard library:&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;ipaddress&lt;/span&gt;

&lt;span class="n"&gt;net&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ipaddress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ip_network&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.20.0.0/22&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;netmask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hostmask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;broadcast_address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 255.255.252.0 0.0.3.255 10.20.3.255
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;num_addresses&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;num_addresses&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# 1024 1022
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Cloud providers usually reserve a few more addresses in each subnet, so check your provider's docs before you plan right up to the limit.)&lt;/p&gt;

&lt;p&gt;If you'd rather not open a REPL, the &lt;a href="https://calculator.now/cidr-calculator/" rel="noopener noreferrer"&gt;CIDR subnet calculator&lt;/a&gt; takes an IP plus either a prefix or a dotted mask. It returns the network and broadcast addresses, the usable range, the wildcard mask and the address class, and tells you whether the address is private. You can also tick boxes to show every octet in binary or hex, which is the clearest way I know to &lt;em&gt;see&lt;/em&gt; why &lt;code&gt;/22&lt;/code&gt; cuts the third octet in half. There's also a separate IP Subnet Calculator on the site with a handy &lt;code&gt;/24&lt;/code&gt; to &lt;code&gt;/32&lt;/code&gt; cheat-sheet table.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Unix timestamps
&lt;/h2&gt;

&lt;p&gt;Logs, JWT &lt;code&gt;exp&lt;/code&gt; claims and API payloads all speak in epoch seconds. Humans don't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Worked example:&lt;/strong&gt; what is &lt;code&gt;1714822400&lt;/code&gt;?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; @1714822400        &lt;span class="c"&gt;# Sat May  4 11:33:20 UTC 2024&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1714822400&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="nf"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// '2024-05-04T11:33:20.000Z'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things trip people up again and again:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Seconds vs milliseconds.&lt;/strong&gt; JavaScript's &lt;code&gt;Date.now()&lt;/code&gt; returns milliseconds, while most backends store seconds. If your date lands in the year 56,000-something, you forgot to divide by 1,000.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Y2038.&lt;/strong&gt; The largest signed 32-bit value, &lt;code&gt;2147483647&lt;/code&gt;, is &lt;code&gt;2038-01-19 03:14:07 UTC&lt;/code&gt;. Anything still storing time in a 32-bit &lt;code&gt;int&lt;/code&gt; overflows one second later.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;a href="https://calculator.now/unix-time-calculator/" rel="noopener noreferrer"&gt;Unix timestamp converter&lt;/a&gt; converts both ways (always in UTC) and shows a live current-epoch clock. It also does timestamp arithmetic: add or subtract seconds, minutes, hours, days, weeks, months or years from a base timestamp. That's the bit I use most, for questions like "if this token was issued at X with a 7-day TTL, when does it expire?"&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Hex, binary and octal (plus bitwise ops)
&lt;/h2&gt;

&lt;p&gt;Colour codes, memory addresses, flag fields and byte dumps all need quick base conversions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Worked example:&lt;/strong&gt; the CSS colour &lt;code&gt;#1E90FF&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;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1E90FF&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 30 144 255
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And going the other way: &lt;code&gt;0xFF&lt;/code&gt; = &lt;code&gt;255&lt;/code&gt; = &lt;code&gt;0b11111111&lt;/code&gt;, and octal &lt;code&gt;755&lt;/code&gt; = &lt;code&gt;0b111101101&lt;/code&gt;. That's the same number &lt;code&gt;chmod&lt;/code&gt; uses in section 1.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://calculator.now/hex-calculator/" rel="noopener noreferrer"&gt;hex calculator&lt;/a&gt; converts between decimal, hex, binary and octal. It can also run shift-left, shift-right, NOT, AND, OR and XOR against a second value. You can choose the bit width (8, 16, 32 or 64 bits), group digits in fours or eights, add &lt;code&gt;0x&lt;/code&gt;/&lt;code&gt;0b&lt;/code&gt;/&lt;code&gt;0o&lt;/code&gt; prefixes, and show the conversion steps. If you're debugging bit masks specifically, the site also has a dedicated Bitwise Calculator with a bit-by-bit operation table and unsigned right shift (&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  5. "How long will this download take?"
&lt;/h2&gt;

&lt;p&gt;This one is mostly about bits vs bytes. Network speeds are quoted in &lt;strong&gt;bits&lt;/strong&gt; per second, while file sizes are in &lt;strong&gt;bytes&lt;/strong&gt;, so you multiply by 8 before you divide.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;time (s) = (file size in bytes × 8) / (link speed in bits/s × efficiency)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Worked example:&lt;/strong&gt; pulling a 50 GB dataset over a 300 Mbps line at 90% efficiency:&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;size_bits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;50e9&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
&lt;span class="n"&gt;rate&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;300e6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.9&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;size_bits&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# ≈ 24.7 minutes
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://calculator.now/download-time-calculator/" rel="noopener noreferrer"&gt;download time calculator&lt;/a&gt; takes KB/MB/GB/TB and Kbps/Mbps/Gbps, lets you set an efficiency (overhead) percentage, and can show the result in seconds, minutes, hours and days at once. I find it useful for setting expectations before a big backup restore or a container registry migration.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. GB vs GiB: storage units
&lt;/h2&gt;

&lt;p&gt;Your "500 GB" disk shows up as about 465 GiB in the OS, and nothing went missing. Drive makers use decimal units (1 GB = 1,000,000,000 bytes), while many tools report binary units (1 GiB = 1,073,741,824 bytes).&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;500e9&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# 465.66 GiB
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://calculator.now/computer-storage/" rel="noopener noreferrer"&gt;storage unit converter&lt;/a&gt; on Calculator.now converts between bits, bytes and every unit up to petabytes, and can show binary units (KiB, MiB…) alongside. It also has two extras I didn't expect to use as much as I do. One estimates file sizes by type (text, images, audio, video or database records). The other works out how many files of a given size fit on a drive, and what percentage of it they'd use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother with a web calculator?
&lt;/h2&gt;

&lt;p&gt;Honestly, for a lot of this a REPL is faster &lt;em&gt;if you already remember the formula&lt;/em&gt;. I reach for the calculators when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I'm explaining something to someone else and want them to see the working, not just my answer;&lt;/li&gt;
&lt;li&gt;I want a second opinion on a value I'm about to put into a firewall rule or a &lt;code&gt;chmod -R&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;I'm on a machine (or a phone) where I don't have my usual shell set up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything runs in the browser with no sign-up. If something's wrong, or there's a dev calculator you wish existed, tell me in the comments. I read them, and requests help me decide what to build next.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I'm the founder of Calculator.now, so I'm biased. All the snippets above are plain standard-library code, so you can check every number without using my site at all.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devtools</category>
      <category>linux</category>
      <category>networking</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
