<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>awk on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/awk/</link>
    <description>Recent content in awk on S Anand</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 27 Sep 2025 13:17:52 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/awk/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to review trending GitHub repos on VS Code</title>
      <link>https://www.s-anand.net/blog/how-to-review-trending-github-repos-on-vs-code/</link>
      <pubDate>Sat, 27 Sep 2025 13:17:50 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/how-to-review-trending-github-repos-on-vs-code/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;How to review trending GitHub repos on VS Code&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/trending-repos.webp&#34;&gt;&lt;/p&gt;
&lt;p&gt;Here’s how I track trending &lt;a href=&#34;https://github.com/&#34;&gt;GitHub&lt;/a&gt; repos each week. I run a &lt;a href=&#34;https://github.com/sanand0/til/blob/43628ba72400451d20076df12dec823f08482c5b/trending-repos.sh&#34;&gt;scheduled script&lt;/a&gt; that saves a &lt;a href=&#34;https://github.com/sanand0/til/blob/43628ba72400451d20076df12dec823f08482c5b/trending-repos.tsv&#34;&gt;clean TSV&lt;/a&gt; I can scan fast.&lt;/p&gt;
&lt;p&gt;It uses &lt;a href=&#34;https://pypi.org/project/gtrending&#34;&gt;&lt;code&gt;uvx gtrending&lt;/code&gt;&lt;/a&gt; to fetch &lt;strong&gt;weekly&lt;/strong&gt; trending repos for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Rust&lt;/strong&gt;: High-quality system tools. (Anything in Rust seems cool.)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Go&lt;/strong&gt;: Reliable CLI/infra tools. (Like Rust, most Go code seems good.)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python&lt;/strong&gt;: Most AI/ML stuff&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TypeScript&lt;/strong&gt;: Most modern JS codebases&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;: Most front-end utilities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shell&lt;/strong&gt;: Productivity scripts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I pipe results through &lt;a href=&#34;https://jqlang.org/&#34;&gt;&lt;code&gt;jq&lt;/code&gt;&lt;/a&gt; to extract:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Language&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stars&lt;/strong&gt;: for popularity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Current period stars&lt;/strong&gt;: for growth&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Date&lt;/strong&gt;: when I run it&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Full name&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I use &lt;a href=&#34;https://en.wikipedia.org/wiki/AWK&#34;&gt;&lt;code&gt;awk&lt;/code&gt;&lt;/a&gt; to de-duplicate by repo and save into a &lt;a href=&#34;https://github.com/sanand0/til/blob/main/trending-repos.tsv&#34;&gt;TSV file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then I review the TSV in &lt;a href=&#34;https://code.visualstudio.com/&#34;&gt;VS Code&lt;/a&gt;. I stopped using Excel. &lt;a href=&#34;https://marketplace.visualstudio.com/items?itemName=mechatroner.rainbow-csv&#34;&gt;Rainbow CSV&lt;/a&gt; and &lt;a href=&#34;https://marketplace.visualstudio.com/items?itemName=janisdd.vscode-edit-csv&#34;&gt;Edit CSV&lt;/a&gt; make large TSVs easy to scan, sort, and re-structure. (I&amp;rsquo;m quite excited at the new tricks I&amp;rsquo;m learning to replace Excel!)&lt;/p&gt;
&lt;p&gt;I tag the first column with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;🟣 &lt;strong&gt;pending&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;🔴 &lt;strong&gt;ignore&lt;/strong&gt; (with reason in the last column)&lt;/li&gt;
&lt;li&gt;🟢 &lt;strong&gt;active&lt;/strong&gt; (I currently use it)&lt;/li&gt;
&lt;li&gt;⏺️ &lt;strong&gt;review&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I picked these icons carefully. A &lt;strong&gt;descending sort&lt;/strong&gt; puts 🟣 on top (to scan quickly) and ⏺️ at the bottom (for closer review). This also puts top-starred repos in each language first.&lt;/p&gt;
&lt;p&gt;The payoff for the right tools is high. This process makes it easy. I found &lt;a href=&#34;http://flameshot.org/&#34;&gt;Flameshot&lt;/a&gt;, &lt;a href=&#34;https://github.com/muesli/duf&#34;&gt;duf&lt;/a&gt; and &lt;a href=&#34;https://github.com/bahdotsh/wrkflw&#34;&gt;wrkflw&lt;/a&gt; this way.&lt;/p&gt;
&lt;p&gt;To try it, download and run &lt;a href=&#34;https://github.com/sanand0/til/blob/43628ba72400451d20076df12dec823f08482c5b/trending-repos.sh&#34;&gt;&lt;code&gt;bash trending-repos.sh&lt;/code&gt;&lt;/a&gt; and open the TSV it generates.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Faster data crunching</title>
      <link>https://www.s-anand.net/blog/faster-data-crunching/</link>
      <pubDate>Fri, 23 Sep 2011 18:20:10 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/faster-data-crunching/</guid>
      <description>&lt;p&gt;I’ve been playing with big data lately.&lt;/p&gt; &lt;p&gt;The good part is, it’s easy to get interesting results. The data is so unwieldy that even average value calculations provoke a “Amazing! I didn’t know that,” response (No exaggeration. I heard this from two separate ~ $1bn businesses this month.)&lt;/p&gt; &lt;p&gt;The bad part is that calculating even that simple average is slow.&lt;/p&gt; &lt;p&gt;For example, take this &lt;a href=&#34;https://files.s-anand.net/blog/a/school_10.rpt.bz2&#34;&gt;40MB file&lt;/a&gt; (380MB unzipped) and extract the first column.&lt;/p&gt; &lt;p&gt;The simplest Python script to get the first column looks like this:&lt;/p&gt;
```python
for row in csv.reader(fileinput.input(), delimiter=&#39;\t&#39;):
    if len(row) &gt; 0: print row[0]
```
&lt;p&gt;That took a good 3 minutes to execute on my laptop.&lt;/p&gt;
&lt;p&gt;Since I’m used to &lt;a href=&#34;http://en.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_Unix_Command_Line&#34;&gt;UNIX data processing&lt;/a&gt;, I tried &lt;code&gt;cut -f1&lt;/code&gt;. Weirdly, that’s worse. 5 minutes. Paradoxically, &lt;/code&gt;awk &#39;{print $1}&#39;&lt;/code&gt; only takes 17 seconds. That&#39;s about 12 times faster. Clearly the tool makes a big difference. And we always knew &lt;a href=&#34;http://swtch.com/~rsc/regexp/regexp1.html&#34;&gt;UNIX&lt;/a&gt; was &lt;a href=&#34;http://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html&#34;&gt;fast&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But I also ran these on an &lt;a href=&#34;http://aws.amazon.com/ec2/&#34;&gt;Amazon EC2&lt;/a&gt; server, and a &lt;a href=&#34;http://www.hostgator.com/&#34;&gt;Hostgator&lt;/a&gt; server. Here’re the results.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&amp;nbsp;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;python&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;cut&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;awk&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;http://www.dell.com/us/business/p/latitude-e5400/pd&#34;&gt;My Dell E5400&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;3:04 (&lt;b&gt;1x&lt;/b&gt;)&lt;/td&gt;
&lt;td&gt;5:42 (&lt;b&gt;0.5x&lt;/b&gt;)&lt;/td&gt;
&lt;td&gt;0:17 (&lt;b&gt;11x&lt;/b&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;http://aws.amazon.com/ec2/#instance&#34;&gt;EC2 standard&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;0:33 (&lt;b&gt;6x&lt;/b&gt;)&lt;/td&gt;
&lt;td&gt;0:5.6 (&lt;b&gt;33x&lt;/b&gt;)&lt;/td&gt;
&lt;td&gt;0:16 (&lt;b&gt;11x&lt;/b&gt;)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;http://support.hostgator.com/articles/hosting-plans/server-specifications-specs&#34;&gt;Hostgator&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;0:19 (&lt;b&gt;10x&lt;/b&gt;)&lt;/td&gt;
&lt;td&gt;0:2.5 (&lt;b&gt;74x&lt;/b&gt;)&lt;/td&gt;
&lt;td&gt;0:0.7 (&lt;b&gt;265x&lt;/b&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;What took 3 minutes with Python my Dell E5400 took &lt;em&gt;less than a second&lt;/em&gt; on Hostgator’s server with awk. Over &lt;em&gt;250 times&lt;/em&gt; faster. (Not 250%. 250 &lt;em&gt;times&lt;/em&gt;). &lt;/p&gt;
&lt;p&gt;And it’s not just hardware. A good tool (awk) made things 11x faster on my machine. Good hardware (hostgator) made the same program 10x faster. But choosing the right combination can make things go faster than 11 x 10 = 110 times. Much faster.&lt;/p&gt;
&lt;p&gt;There are a few of things I’m taking away from this.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Good hardware can speed you up much as (or more than) choosing the right tool.&lt;/li&gt;
&lt;li&gt;Good hardware can be rented. From many places. Cheaply.&lt;/li&gt;
&lt;li&gt;Always test what’s fast. awk’s fastest on my machine and Hostgator, but not on EC2.&lt;/li&gt;&lt;/ol&gt;
</description>
    </item>
    <item>
      <title>The ubiquitous Peter Weinberger</title>
      <link>https://www.s-anand.net/blog/the-ubiquitous-peter-weinberger/</link>
      <pubDate>Fri, 14 Feb 2003 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/the-ubiquitous-peter-weinberger/</guid>
      <description>&lt;p&gt;The ubiquitous &lt;a href=&#34;http://www.chessbase.com/newsdetail.asp?newsid=791&#34;&gt;Peter Weinberger&lt;/a&gt;. A man whose face was etched on CDs, circuit boards, walls, tables, and even watertowers. &lt;a href=&#34;http://www.robotwisdom.com&#34;&gt;via RobotWisdom&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
