<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Prateek Punetha</title><link>/</link><description>Recent content on Prateek Punetha</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 01 Mar 2023 00:00:00 +0000</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><item><title>Back to Bash: Reflections on Filtering Wikipedia Episode Links a Year Later</title><link>/posts/filter-wikipedia-episodes/</link><pubDate>Wed, 01 Mar 2023 00:00:00 +0000</pubDate><guid>/posts/filter-wikipedia-episodes/</guid><description>&lt;h1 id="how-i-extracted-tv-episode-titles-using-command-line-magic">How I Extracted TV Episode Titles Using Command Line Magic&lt;/h1>
&lt;p>I enjoy watching TV shows and prefer to torrent them for offline viewing. The issue is that these shows often have strange names that don&amp;rsquo;t make sense and can be difficult to keep track of, especially since various individuals and groups post them on torrent sites. While I can use Wikipedia to obtain the actual episode names, manually copying and renaming each episode can be time-consuming. Therefore, I decided to automate the process using command-line tools and Ranger&amp;rsquo;s bulk renaming feature.&lt;/p></description><content>&lt;h1 id="how-i-extracted-tv-episode-titles-using-command-line-magic">How I Extracted TV Episode Titles Using Command Line Magic&lt;/h1>
&lt;p>I enjoy watching TV shows and prefer to torrent them for offline viewing. The issue is that these shows often have strange names that don&amp;rsquo;t make sense and can be difficult to keep track of, especially since various individuals and groups post them on torrent sites. While I can use Wikipedia to obtain the actual episode names, manually copying and renaming each episode can be time-consuming. Therefore, I decided to automate the process using command-line tools and Ranger&amp;rsquo;s bulk renaming feature.&lt;/p>
&lt;h2 id="the-problem">The Problem&lt;/h2>
&lt;p>First, I needed to find a way to scrape the episode title from a Wikipedia page. After some research, I discovered that the best way to do this was to download the page&amp;rsquo;s source code and then extract the relevant information using a tool like grep.&lt;/p>
&lt;h2 id="the-solution">The Solution&lt;/h2>
&lt;p>I started by writing a simple curl command that would download the source code of the Wikipedia page for a given TV show:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>curl -s &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$1&lt;span style="color:#e6db74">?action=raw&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This command uses the -s flag to suppress the output of curl, and $1 is the URL of the Wikipedia page. The ?action=raw part of the URL ensures that we get the raw source code of the page, rather than the formatted HTML.&lt;/p>
&lt;p>Next, I needed to extract the episode title from the source code. After looking through the code, I found that each episode title was surrounded by a tag that looked like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;Title&amp;#34;&lt;/span> &lt;span style="color:#f92672">==&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>To extract this information, I used grep to search for the tag and then extracted the episode title using sed. Here&amp;rsquo;s the final command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>curl -s &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$1&lt;span style="color:#e6db74">?action=raw&amp;#34;&lt;/span> | grep -B10 &lt;span style="color:#e6db74">&amp;#39;ShortSummary&amp;#39;&lt;/span> | grep -w &lt;span style="color:#e6db74">&amp;#39;Title&amp;#39;&lt;/span> | sed &lt;span style="color:#e6db74">&amp;#39;s/.*Title.*= //&amp;#39;&lt;/span> | nl -w6 -w1 -s &lt;span style="color:#e6db74">&amp;#34; - &amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Let&amp;rsquo;s break this command down:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>bash curl -s &amp;quot;$1?action=raw&amp;quot;&lt;/code>downloads the source code of the Wikipedia page.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>grep -B10 'ShortSummary'&lt;/code>searches for the line that contains the string &amp;ldquo;ShortSummary&amp;rdquo; and returns the 10 lines before it.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>grep -w 'Title'&lt;/code> searches for the line that contains the word &amp;ldquo;Title&amp;rdquo; and returns it.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>sed 's/.*Title.*= //'&lt;/code> removes everything before the episode title.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>nl -w6 -w1 -s &amp;quot; - &amp;quot;&lt;/code> adds numbering to the output.
With this command, I could simply pass in the URL of a TV show&amp;rsquo;s Wikipedia page, and it would return a numbered list of all the episode titles.&lt;/p>
&lt;p>Then, I can simply copy these names and use Ranger&amp;rsquo;s bulk rename feature to rename them.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Through some trial and error, I was able to come up with a simple command-line script that makes my life a little bit easier. I&amp;rsquo;m excited to keep exploring new ways to use command-line tools to solve everyday problems.&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://github.com/prateekpunetha/dotfiles/blob/master/bin/bin/eplist">&lt;strong>Link to the script&lt;/strong>&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>I hope you found this post helpful, and feel free to reach out to me if you have any questions or feedback!&lt;/p></content></item><item><title>Updating My ThinkPad BIOS from Linux</title><link>/posts/updating-thinkpad-bios-from-linux/</link><pubDate>Fri, 03 Sep 2021 00:00:00 +0000</pubDate><guid>/posts/updating-thinkpad-bios-from-linux/</guid><description>&lt;p>About a year ago, I got a ThinkPad E14 Gen 2 (Ryzen) and wanted to update its BIOS.&lt;/p>
&lt;p>However, I didn&amp;rsquo;t want to install Windows just to update the BIOS. After some research online, I discovered that Lenovo releases BIOS updates for ThinkPad in two formats - one is through the Bios Update Utility (Windows), which is a .exe file, and the other is a .iso file that can be flashed through a USB thumb drive.&lt;/p></description><content>&lt;p>About a year ago, I got a ThinkPad E14 Gen 2 (Ryzen) and wanted to update its BIOS.&lt;/p>
&lt;p>However, I didn&amp;rsquo;t want to install Windows just to update the BIOS. After some research online, I discovered that Lenovo releases BIOS updates for ThinkPad in two formats - one is through the Bios Update Utility (Windows), which is a .exe file, and the other is a .iso file that can be flashed through a USB thumb drive.&lt;/p>
&lt;p>Here&amp;rsquo;s how to update the BIOS under Linux:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Get the latest version of the BIOS in .iso format for your model from the Lenovo support site.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Download &lt;code>geteltorito&lt;/code>, a Perl script that extracts the boot image from the bios.iso file. You can grab it from &lt;a href="https://userpages.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito/geteltorito.pl">&lt;strong>here&lt;/strong>&lt;/a>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Extract the boot image from the bios.iso file (in my case, the file was r1auj38wd.iso) using the command &lt;code>$ geteltorito.pl -o bios_update.img r1auj38wd.iso&lt;/code>.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Copy the image to USB using the &lt;code>dd&lt;/code> command: &lt;code>$ sudo dd if=bios_update.img of=/dev/sda&lt;/code>. Note that you should replace &lt;code>/dev/sda&lt;/code> with the corresponding device name for your system.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Boot from your USB drive, follow the instructions, and update the BIOS.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;p>At first, I was nervous about what would happen if anything went wrong, but everything worked out just fine :)&lt;/p></content></item><item><title>Software I Use</title><link>/software-i-use/</link><pubDate>Wed, 14 Jul 2021 00:00:00 +0000</pubDate><guid>/software-i-use/</guid><description>&lt;p>&lt;img src="/img/home.webp" alt="Homescreen">&lt;/p>
&lt;h1 id="operating-system">Operating System&lt;/h1>
&lt;p>Arch Linux with BSPWM Tiling Window Manager.&lt;/p>
&lt;h1 id="terminal">Terminal&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>Kitty&lt;/strong>: Just a terminal emulator with images and Unicode support.&lt;/li>
&lt;/ul>
&lt;h1 id="shell">Shell&lt;/h1>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>zsh&lt;/strong>: I use zsh as a shell, because of features like plugins, spelling correction, and approximate completion. I don&amp;rsquo;t mind using other shells though, as on my server I use bash.&lt;/p>
&lt;p>I only use vanilla zsh, with my &lt;a href="https://github.com/prateekpunetha/dotfiles">configs&lt;/a>. I don&amp;rsquo;t use oh my zsh because it is slow and has unnecessary stuff which I don&amp;rsquo;t need.&lt;/p></description><content>&lt;p>&lt;img src="/img/home.webp" alt="Homescreen">&lt;/p>
&lt;h1 id="operating-system">Operating System&lt;/h1>
&lt;p>Arch Linux with BSPWM Tiling Window Manager.&lt;/p>
&lt;h1 id="terminal">Terminal&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>Kitty&lt;/strong>: Just a terminal emulator with images and Unicode support.&lt;/li>
&lt;/ul>
&lt;h1 id="shell">Shell&lt;/h1>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>zsh&lt;/strong>: I use zsh as a shell, because of features like plugins, spelling correction, and approximate completion. I don&amp;rsquo;t mind using other shells though, as on my server I use bash.&lt;/p>
&lt;p>I only use vanilla zsh, with my &lt;a href="https://github.com/prateekpunetha/dotfiles">configs&lt;/a>. I don&amp;rsquo;t use oh my zsh because it is slow and has unnecessary stuff which I don&amp;rsquo;t need.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h1 id="text-editing--programming">Text Editing &amp;amp; Programming&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>vim/Neovim&lt;/strong>: vim is a incredibly powerful and efficient text editor. The amount of stuff I&amp;rsquo;ve done in record time using vim is staggering.&lt;/li>
&lt;/ul>
&lt;h1 id="web-browser">Web Browser&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>Ungoogled Chromium&lt;/strong>: Chromium based web browser with google components and blobs removed. I use it with extensions like uBlock Origin, Vimium etc.&lt;/li>
&lt;/ul>
&lt;h1 id="file-manager">File Manager&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>ranger&lt;/strong>: A highly &lt;a href="https://github.com/prateekpunetha/dotfiles/tree/master/ranger/.config/ranger">configurable&lt;/a> file manager, with vi key bindings and other cool stuff.&lt;/li>
&lt;/ul>
&lt;h1 id="image-viewer">Image Viewer&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>sxiv&lt;/strong>: A hacker-friendly scriptable image viewer. It also supports animated GIFs, thumbnails, and slideshows.&lt;/li>
&lt;/ul>
&lt;h1 id="document-viewer">Document Viewer&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>zathura&lt;/strong>: zathura is a minimal yet highly customizable plugin-based document viewer. If you want to make it read pdf, you&amp;rsquo;ll need a plugin for that and the same goes for other types of doucments like ps, epub etc.&lt;/li>
&lt;/ul>
&lt;p>Previously I used to use xreader, but now I&amp;rsquo;ve switched to zathura, because it just works
the way I &lt;a href="https://github.com/prateekpunetha/dotfiles/blob/master/zathura/.config/zathura/zathurarc">want&lt;/a>
it to be.&lt;/p>
&lt;h1 id="media-player">Media Player&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>mpv&lt;/strong>: Neat and simple interface video player which works perfectly with a wide variety of video formats and has all the customizations I need.&lt;/li>
&lt;/ul>
&lt;h1 id="email">Email&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>neomutt&lt;/strong>: Simple yet powerful terminal based email client.&lt;/li>
&lt;/ul>
&lt;h1 id="sync">Sync&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>syncthing&lt;/strong>: Serverless device syncing.&lt;/li>
&lt;/ul>
&lt;h1 id="rss">RSS&lt;/h1>
&lt;ul>
&lt;li>&lt;strong>newsboat&lt;/strong>: A simple RSS feed reader for the terminal.&lt;/li>
&lt;/ul>
&lt;h1 id="other">Other&lt;/h1>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>rtorrent&lt;/strong>: BitTorrent client.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>aria2&lt;/strong>: All-in-one downloading tool.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>ffmpeg&lt;/strong>: General purpose command-line tool for video and audio recording, and conversion. I mainly use it for adding subs to video files, concatenation, and cropping.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>ImageMagick&lt;/strong>: I use it to edit, convert, resize or rotate images.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>rclone&lt;/strong>: Command line program for managing files over cloud storage. Yes, a Swiss army knife of cloud storage.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>youtube-dl&lt;/strong>: CLI tool for downloading youtube videos. Can download youtube playlists or even an entire youtube channel. It also supports downloading from many other &lt;a href="https://ytdl-org.github.io/youtube-dl/supportedsites.html">websites&lt;/a>.
Technically, I use &lt;a href="https://github.com/yt-dlp">yt-dlp&lt;/a> these days, because it has some additional features and it also fixes problems like buffering with mpv that I face with regular ytdl.&lt;/p>
&lt;/li>
&lt;/ul></content></item><item><title>My attempt at a blog</title><link>/posts/my-attempt-at-blog/</link><pubDate>Fri, 09 Jul 2021 00:00:00 +0000</pubDate><guid>/posts/my-attempt-at-blog/</guid><description>&lt;p>Previously, I had a website based on Jekyll, but I didn&amp;rsquo;t post much on it. Later, I realized that I come across a lot of new things each day. It would be a good idea if I shared what I learned. Not only will it help me with future references, but others as well.&lt;/p>
&lt;p>I intend to write about all topics that interest me, in no particular order:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Linux System Administration&lt;/p></description><content>&lt;p>Previously, I had a website based on Jekyll, but I didn&amp;rsquo;t post much on it. Later, I realized that I come across a lot of new things each day. It would be a good idea if I shared what I learned. Not only will it help me with future references, but others as well.&lt;/p>
&lt;p>I intend to write about all topics that interest me, in no particular order:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Linux System Administration&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Self-hosting and similar stuff&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Things I Use (Software, Hardware)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Shows: I watch a lot of shows, although I don&amp;rsquo;t binge-watch. I think I will talk about them as well.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>I hope you will enjoy it.&lt;/p></content></item><item><title>About Me</title><link>/about/</link><pubDate>Wed, 07 Jul 2021 00:00:00 +0000</pubDate><guid>/about/</guid><description>&lt;h1 id="hi-there">Hi there&lt;/h1>
&lt;p>My name is Prateek Punetha. I am 22 years old. Originally I am from Uttarakhand,
India. I am very keen on anything related to computers and technology. I am
currently pursuing a Master&amp;rsquo;s Degree in Computer Science from Maharashtra,
India.&lt;/p>
&lt;h1 id="contacting-me">Contacting Me&lt;/h1>
&lt;p>You can contact me using the following means:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://t.me/prateekpunetha">Telegram&lt;/a>&lt;/li>
&lt;li>Email me at &lt;a href="mailto:hi@prateekpunetha.dev">hi (at) prateekpunetha dot dev&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>For maximum privacy and security you can encrypt your messages with my
&lt;a href="/pubkey.txt">public key&lt;/a>.&lt;/p></description><content>&lt;h1 id="hi-there">Hi there&lt;/h1>
&lt;p>My name is Prateek Punetha. I am 22 years old. Originally I am from Uttarakhand,
India. I am very keen on anything related to computers and technology. I am
currently pursuing a Master&amp;rsquo;s Degree in Computer Science from Maharashtra,
India.&lt;/p>
&lt;h1 id="contacting-me">Contacting Me&lt;/h1>
&lt;p>You can contact me using the following means:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://t.me/prateekpunetha">Telegram&lt;/a>&lt;/li>
&lt;li>Email me at &lt;a href="mailto:hi@prateekpunetha.dev">hi (at) prateekpunetha dot dev&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>For maximum privacy and security you can encrypt your messages with my
&lt;a href="/pubkey.txt">public key&lt;/a>.&lt;/p>
&lt;h1 id="quick-links">Quick Links&lt;/h1>
&lt;ul>
&lt;li>&lt;a href="https://github.com/prateekpunetha">Github&lt;/a>&lt;/li>
&lt;li>&lt;a href="/pubkey.txt">GPG Key&lt;/a>&lt;/li>
&lt;/ul></content></item></channel></rss>