<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Dwarak</title>
		<description>Code. Life. Fun.</description>
		<link>https://blog.dwarak.in</link>
		<atom:link href="https://blog.dwarak.in/feed.xml" rel="self" type="application/rss+xml" />
		
		
		
		
		
			<item>
				<title>Index</title>
				<description>&lt;div&gt;

  &lt;h2&gt; Paper Notes &lt;/h2&gt;
  &lt;p&gt; Notes from papers that I&apos;ve read &lt;/p&gt;
  &lt;hr/&gt;

  
  
      &lt;section&gt;
          &lt;h4&gt;&lt;b&gt;1. &lt;a href=&quot;/papers/Google-File-System/&quot;&gt;Google File System&lt;/a&gt;&lt;/b&gt;&lt;/h4&gt;
      &lt;/section&gt;
  
&lt;/div&gt;
</description>
				<pubDate>Sun, 17 May 2026 22:05:15 +0000</pubDate>
				<link>https://blog.dwarak.in/papers/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/papers/</guid>
			</item>
		
			<item>
				<title>Index</title>
				<description>&lt;div&gt;

  &lt;h2&gt; Book Notes &lt;/h2&gt;
  &lt;p&gt; Reviews/Notes of some books that I&apos;ve read &lt;/p&gt;
  &lt;hr/&gt;

  
  
      &lt;section&gt;
          &lt;h4&gt;&lt;b&gt;1. &lt;a href=&quot;/books/Ponniyin-Selvan/&quot;&gt;Ponniyin Selvan (பொன்னியின் செல்வன்)&lt;/a&gt;&lt;/b&gt;&lt;/h4&gt;
          &lt;i&gt;Kalki Krishnamurthy&lt;/i&gt;
      &lt;/section&gt;
  
      &lt;section&gt;
          &lt;h4&gt;&lt;b&gt;2. &lt;a href=&quot;/books/Harry-Potter-Series/&quot;&gt;Harry Potter Series&lt;/a&gt;&lt;/b&gt;&lt;/h4&gt;
          &lt;i&gt;J. K. Rowling&lt;/i&gt;
      &lt;/section&gt;
  
      &lt;section&gt;
          &lt;h4&gt;&lt;b&gt;3. &lt;a href=&quot;/books/Aasarakovai/&quot;&gt;Aasarakovai&lt;/a&gt;&lt;/b&gt;&lt;/h4&gt;
          &lt;i&gt;Peruvayil Mulliyar&lt;/i&gt;
      &lt;/section&gt;
  
&lt;/div&gt;
</description>
				<pubDate>Sun, 17 May 2026 22:05:15 +0000</pubDate>
				<link>https://blog.dwarak.in/books/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/books/</guid>
			</item>
		
			<item>
				<title>Tailscale For The Win</title>
				<description>&lt;p&gt;This was a long time coming. After all, which homelab-ber does not run &lt;a href=&quot;https://tailscale.com/&quot;&gt;Tailscale&lt;/a&gt;? I have a very (read, super large) collection of media that I have always missed accessing outside of my home network. But do not want it to be publicly accessible like &lt;a href=&quot;https://www.navidrome.org/&quot;&gt;Navidrome&lt;/a&gt;. I believe a separate post for my home lab setup is warranted. But we’ll reserve that for another time.&lt;/p&gt;

&lt;p&gt;What do I know about Tailscale? Just that it is a lean setup for &lt;a href=&quot;https://www.wireguard.com/&quot;&gt;Wireguard&lt;/a&gt; tunnels. I haven’t had time to venture into understanding what it is beyond. Conceptually though, it makes sense and so I’m sticking with that definition for now.&lt;/p&gt;

&lt;p&gt;For some reason, I have always put off setting up Tailscale for a while. Perhaps trying to setup my own &lt;a href=&quot;https://openid.net/developers/how-connect-works/&quot;&gt;OIDC&lt;/a&gt; (short for OpenID Connect) provider took a very very long time that ran into debating whether I should continue running by &lt;a href=&quot;https://www.digitalocean.com/products/droplets&quot;&gt;DO droplet&lt;/a&gt; or explore &lt;a href=&quot;https://www.hetzner.com/&quot;&gt;Hetzner&lt;/a&gt; like the other internet folks do. I got tired of that and for the moment, I have gone ahead with using Github to prove my identity.&lt;/p&gt;

&lt;p&gt;Right now, I had a single point agenda - setup a LXC container for Tailscale and include a reverse proxy to &lt;a href=&quot;https://jellyfin.org/&quot;&gt;Jellyfin&lt;/a&gt; and &lt;a href=&quot;https://immich.app/&quot;&gt;Immich&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I assume you run &lt;a href=&quot;https://www.proxmox.com/en/&quot;&gt;Proxmox&lt;/a&gt; as your hypervisor. But the setup should be very similar in any other home lab env.&lt;/p&gt;

&lt;h2 id=&quot;step-1---install-tailscale&quot;&gt;Step 1 - Install Tailscale&lt;/h2&gt;

&lt;p&gt;To keep this post super brief, I’m going to refer to you to the super nice tutorial that Tailscale folks had already put together &lt;a href=&quot;https://www.youtube.com/watch?v=JC63OGSzTQI&quot;&gt;here&lt;/a&gt;. We’ll only differ in the way we provide access to the Tailnet.&lt;/p&gt;

&lt;p&gt;Having individual LXC containers run Tailscale seems like a waste of resources and frankly a security nightmare. I like how &lt;a href=&quot;https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/&quot;&gt;Cloudflare Tunnel&lt;/a&gt; setup works where I can setup a single tunnel container and have it route all my requests to any of my subnetworks. Perhaps this is possible natively in Tailscale too, I wonder? Will need to check on that sometime.&lt;/p&gt;

&lt;h2 id=&quot;step-2---use-a-reverse-proxy&quot;&gt;Step 2 - Use a Reverse Proxy&lt;/h2&gt;

&lt;p&gt;For now though, I setup &lt;a href=&quot;https://caddyserver.com/&quot;&gt;Caddy&lt;/a&gt; as reverse proxy to forward requests internally.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# apt install -y debian-keyring debian-archive-keyring apt-transport-https curl&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# curl -1sLf &apos;https://dl.cloudsmith.io/public/caddy/stable/gpg.key&apos; | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# curl -1sLf &apos;https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt&apos; | tee /etc/apt/sources.list.d/caddy-stable.list&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# chmod o+r /etc/apt/sources.list.d/caddy-stable.list&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# apt update &amp;amp;&amp;amp; apt install caddy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Latest on the above can be found &lt;a href=&quot;https://caddyserver.com/docs/install&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;caddyfile-setup&quot;&gt;Caddyfile setup&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /etc/caddy/Caddyfile
:80 &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        root &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; /usr/share/caddy
        file_server
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Used vanilla port for Jellyfin&lt;/span&gt;
:8096 &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    reverse_proxy 192.168.1.133:8096
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And voila! I was able to stream my media over Tailnet from my Proxmox server to Android phone connected over public internet without hiccups. (1080p works. 4k struggles. But that can also be due to transcoding issues. Haven’t checked that yet.)&lt;/p&gt;

&lt;h2 id=&quot;what-next&quot;&gt;What Next?&lt;/h2&gt;

&lt;p&gt;This has definitely piqued my curiosity to understand Tailscale and Tailnet more! Importantly, Wireguard and understand how things work. Can this lead me to setup &lt;a href=&quot;https://pangolin.net/&quot;&gt;Pangolin&lt;/a&gt; eventually? We’ll see.&lt;/p&gt;
</description>
				<pubDate>Sun, 17 May 2026 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2026/05/17/Tailscale-For-The-Win/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2026/05/17/Tailscale-For-The-Win/</guid>
			</item>
		
			<item>
				<title>Ways to Expose a service within k8s</title>
				<description>&lt;p&gt;So I’ve started using k8s for work! It is l parts exciting and boggling. Just the sheer amount of options and resources you have to learn and be comfortable configuring is probably why k8s is sucequah a pain for so many. [&lt;a href=&quot;https://news.ycombinator.com/item?id=42252336&quot;&gt;1&lt;/a&gt;] [&lt;a href=&quot;https://news.ycombinator.com/item?id=29360204&quot;&gt;2&lt;/a&gt;] [&lt;a href=&quot;https://news.ycombinator.com/item?id=42246883&quot;&gt;3&lt;/a&gt;] [&lt;a href=&quot;https://news.ycombinator.com/item?id=42253231&quot;&gt;4&lt;/a&gt;] [&lt;a href=&quot;https://news.ycombinator.com/item?id=34897312&quot;&gt;5&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;Nonetheless, here we are! And I’m too novice to form opinions at the moment - so I’ll leave it at that.&lt;/p&gt;

&lt;p&gt;This post is probably one of the many I’ll be writing down as I tread down this path - capturing anecdotes and gotchas along the way.&lt;/p&gt;

&lt;h2 id=&quot;enough-chitchat-what-are-we-talking-today&quot;&gt;Enough ChitChat. What are we talking today?&lt;/h2&gt;

&lt;p&gt;At its core, k8s is a container orchestrator. Which means it can run your workloads - just that it needs to be containerized.&lt;/p&gt;

&lt;p&gt;Assume your workload is a simple stateless service that you want to connect to from outside. What are the different options you have?&lt;/p&gt;

&lt;h3 id=&quot;clusterip&quot;&gt;ClusterIP&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/k8s-service-expose/ClusterIP.png&quot; alt=&quot;ClusterIP&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;apiVersion&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;v1&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;metadata&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;myapp-service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ClusterIP&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;protocol&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TCP&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;80&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;targetPort&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;8080&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is the very basic setup that you get once you expose a service within k8s using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;expose&lt;/code&gt; subcommand within &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubectl&lt;/code&gt;. Having a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ClusterIP&lt;/code&gt; will help services within your cluster talk to each other. But that’s about it. You cannot talk to services to/from outside the internal k8s network.&lt;/p&gt;

&lt;p&gt;Okay, well so much for a system that you can’t talk to from outside. That’s what you have the proxy for.&lt;/p&gt;

&lt;h3 id=&quot;port-forwarding&quot;&gt;Port-Forwarding&lt;/h3&gt;

&lt;p&gt;You could setup a k8s proxy by running&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;kubectl proxy &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;9999
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And you can connect to the k8s API via this proxy like so&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;http://localhost:9999/api/v1/proxy/namespaces/&amp;lt;NAMESPACE&amp;gt;/services/&amp;lt;SERVICE-NAME&amp;gt;:&amp;lt;PORT-NAME&amp;gt;/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So for the service above, we can connect like so&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;http://localhost:9999/api/v1/proxy/namespaces/default/services/myapp-service:80/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is mostly used for debugging, temporarily verifying&lt;/p&gt;

&lt;h3 id=&quot;nodeport&quot;&gt;NodePort&lt;/h3&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;apiVersion&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;v1&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;metadata&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;myapp-service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NodePort&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;80&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;targetPort&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;8080&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;nodePort&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30004&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A simple change to let others reach/talk to your service would be to change the Service Spec from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ClusterIP&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NodePort&lt;/code&gt;. It is exactly what it’s name is - a unique port assigned in every node the service runs at.&lt;/p&gt;

&lt;p&gt;So assume you have a service that runs in 3 pods across 3 different nodes - 1 pod/node (to keep it simple). So the services within the pod take the same set of ports in each of the nodes they are run at.&lt;/p&gt;

&lt;p&gt;This is very similar to the age old setup of having a service run with a single port across a bunch of machines routed to by a LB sitting in front.&lt;/p&gt;

&lt;p&gt;There are 3 port definitions relevant here -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;port&lt;/code&gt; - The port exposed by the Kubernetes service internally within the cluster. Other pods or services inside the cluster will use this port to communicate with the service. Pods inside the cluster access the service at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;myapp-service:80&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;targetPort&lt;/code&gt; - The port on the actual application (or container) that the service forwards traffic to. The service uses this port to route traffic to the containers running the application. The application inside the container listens on port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;8080&lt;/code&gt;. Kubernetes routes the traffic received on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;port&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;80&lt;/code&gt;) or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nodePort&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;30004&lt;/code&gt;) to this port on the target pod.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nodePort&lt;/code&gt; - The port opened on all cluster nodes to allow external access to the service. Enables access to the service from outside the cluster through &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;NodeIP&amp;gt;:&amp;lt;NodePort&amp;gt;&lt;/code&gt;. In the above example, any client outside the cluster can reach the service by sending a request to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;NodeIP&amp;gt;:30004&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The caveat here though is, it has a Limited port range (default: 30000–32767). Also, if your node/VM that hosts the pods change, the LB will have to deal with that. Not a good setup for service discovery.&lt;/p&gt;

&lt;h3 id=&quot;loadbalancer&quot;&gt;LoadBalancer&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/k8s-service-expose/LB.png&quot; alt=&quot;LoadBalancer&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;apiVersion&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;v1&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;metadata&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;myapp-service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;LoadBalancer&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;protocol&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TCP&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;80&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;targetPort&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is the typical LB that we discussed with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ClusterIP&lt;/code&gt;. In most cases, this is a network load balancer provided for by your cloud provider. For bespoke or on-prem setups, nginx could be used to setup a LB in front of the nodes.&lt;/p&gt;

&lt;h3 id=&quot;ingress&quot;&gt;Ingress&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/k8s-service-expose/Ingress.png&quot; alt=&quot;Ingress&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;apiVersion&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;networking.k8s.io/v1&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;kind&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Ingress&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;metadata&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;myapp-service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;spec&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;rules&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;example.com&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;paths&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/logs&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;pathType&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Prefix&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;backend&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
              &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;log-service&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
                  &lt;span class=&quot;na&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;80&lt;/span&gt;
          &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/web&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;pathType&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Prefix&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;backend&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
              &lt;span class=&quot;na&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;web-service&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
                  &lt;span class=&quot;na&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;80&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;tls&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hosts&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;example.com&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;secretName&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;tls-secret&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Service object operates at Layer 4. This means it canonly forward TCP/UDP communications and does not “look” inside the connections.&lt;/p&gt;

&lt;p&gt;Having &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NodePort&lt;/code&gt; means you have multiple open ports in each of the nodes (for every hosted service) and one LB for each of those services, which is very costly. Especially in cloud based envs.&lt;/p&gt;

&lt;p&gt;Ingress is used to expose multiple services with a single external endpoint (HTTP/HTTPS). Very simply, it is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nginx&lt;/code&gt; for k8s environments.&lt;/p&gt;

&lt;p&gt;It can process application level information like DNS host names, port specific routing, do advanced routing basis the endpoints (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/logs&lt;/code&gt; -&amp;gt; ServiceA, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/web&lt;/code&gt; -&amp;gt; ServiceB), TLS termination among others.&lt;/p&gt;

&lt;p&gt;Most popular Ingress controllers are Traefik, HAProxy, Nginx&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0&quot;&gt;Kubernetes NodePort vs LoadBalancer vs Ingress? When should I use what?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sysdig.com/blog/kubernetes-services-clusterip-nodeport-loadbalancer/&quot;&gt;Kubernetes Services: ClusterIP, Nodeport and LoadBalancer&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
				<pubDate>Mon, 20 Jan 2025 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2025/01/20/Ways-To-Expose-A-Service-Within-k8s/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2025/01/20/Ways-To-Expose-A-Service-Within-k8s/</guid>
			</item>
		
			<item>
				<title>Google File System</title>
				<description>&lt;h2 id=&quot;trivia&quot;&gt;Trivia&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;The original paper was published in 2003 at SOSP (Symposium on Operating Systems Principles)&lt;/li&gt;
  &lt;li&gt;Distributed file system built for Google’s computational needs - to support hundreds of clients concurrently reading/writing to large files, while ensuring HA, performance and reliability.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;original-motivation&quot;&gt;Original Motivation&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Google stored dozens of copies of the entire web.&lt;/li&gt;
  &lt;li&gt;Google was serving thousands of queries/second. Each query reads 100s of MB data and each query consumes many CPU cycles.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Needed a large, distributed, highly fault tolerant file system.&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;To build a replicated storage layer using commodity hardware&lt;/strong&gt; – to power batch jobs. (Eventually powered other projects)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Since GFS was primarily designed for batch workloads&lt;/strong&gt;, it is optimized for appends rather than modifying files – users are generally expected to write large files at once than modify/write small files&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;assumptions--design-motivations&quot;&gt;Assumptions / Design Motivations&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Fault-tolerance and auto-recovery needed to be built-in.&lt;/li&gt;
  &lt;li&gt;Standard I/O assumptions (e.g. block size) to be re-examined.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Appends are the prevalent form of writing&lt;/strong&gt;. And most files are written once and read many times.&lt;/li&gt;
  &lt;li&gt;Everything must run on commodity hardware with &lt;strong&gt;frequent component failures&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Aggregate read/write bandwidth more relevant instead of per client.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;apis&quot;&gt;APIs&lt;/h2&gt;

&lt;p&gt;Not POSIX compliant.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Read&lt;/strong&gt; (file, startOffset, endOffset)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Write&lt;/strong&gt; (file, startOffset, endOffset) - Not often invoked in practice&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;AtomicRecordAppend&lt;/strong&gt; (file, data)
    &lt;ol&gt;
      &lt;li&gt;Data guaranteed not to be interleaved with current atomic appends&lt;/li&gt;
      &lt;li&gt;Returns offset where data is written&lt;/li&gt;
      &lt;li&gt;Use-case - Pubsub on GFS or Merging data&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;architecture&quot;&gt;Architecture&lt;/h2&gt;

&lt;h3 id=&quot;overview&quot;&gt;Overview&lt;/h3&gt;

&lt;p&gt;Consists of a &lt;strong&gt;Master&lt;/strong&gt; and &lt;strong&gt;Chunk nodes.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Master node maintains the metadata&lt;/li&gt;
  &lt;li&gt;A lower layer (i.e. a set of chunkservers) stores the data in units called “chunks”.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image1.png&quot; alt=&quot;GFS Architecture&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Each file is split into 64 MB chunks and distributed across servers.
    &lt;ul&gt;
      &lt;li&gt;Why? For distributing load across multiple nodes for reads/writes.&lt;/li&gt;
      &lt;li&gt;And most reads/writes happen in a contiguous block of data.&lt;/li&gt;
      &lt;li&gt;64MB is a trade-off between load balancing and providing a contiguous block of data size that clients usually operate on.&lt;/li&gt;
      &lt;li&gt;Also, 64MB was a huge block size when GFS was originally designed.&lt;/li&gt;
      &lt;li&gt;Chunks are stored as a plain Linux file on a chunkserver and is extended only as needed. (&lt;strong&gt;Lazy space allocation&lt;/strong&gt;)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Other points
    &lt;ul&gt;
      &lt;li&gt;Less chunk metadata when chunk size is big - both for client side metadata caching and storage in GFS.&lt;/li&gt;
      &lt;li&gt;Bad if there are many small files - since in the worst case, you can have only 1 chunk and many clients accessing the same file can create a hot partition. But not the usual case in practice.&lt;/li&gt;
      &lt;li&gt;Clients are more likely to do a bunch of sequential operations. So, can keep persistent TCP connections.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;master&quot;&gt;Master&lt;/h3&gt;

&lt;p&gt;Simple design. Global state allows for better decision making.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Stores mapping between files and chunks. (filename -&amp;gt; array-of-chunkhandle table and a chunkhandle -&amp;gt; list-of-chunkservers table)&lt;/li&gt;
  &lt;li&gt;Has prefix compression to save file names in memory&lt;/li&gt;
  &lt;li&gt;Chunk handles - 64 bytes.&lt;/li&gt;
  &lt;li&gt;Chunks are replicated over 3 nodes by default. (RF=3)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;chunk-servers&quot;&gt;Chunk Servers&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image2.png&quot; alt=&quot;Chunk Server&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;operation-log&quot;&gt;Operation Log&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Master stores 3 types of information
    &lt;ol&gt;
      &lt;li&gt;File/Chunk namespaces.&lt;/li&gt;
      &lt;li&gt;Mapping between files-&amp;gt;chunks&lt;/li&gt;
      &lt;li&gt;Location of chunk’s replicas.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;To avoid Master becoming a bottleneck, we store the above metadata in memory. But we also persist 1.a, and 1.b in disk from time to time. 1.c. not written to reduce space.&lt;/li&gt;
  &lt;li&gt;Operation log - (glorified) WAL
    &lt;ol&gt;
      &lt;li&gt;Orders all operations&lt;/li&gt;
      &lt;li&gt;Must be written and synchronously replicated to other nodes before Master returns any data back to clients.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;handling-master-failure&quot;&gt;Handling Master Failure&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Master can replay its operation log to restore its old state&lt;/li&gt;
  &lt;li&gt;Note - Log only contains 1.a and 1.b. Not 1.c -&amp;gt; location of chunk replicas.
    &lt;ol&gt;
      &lt;li&gt;Solution: Master queries chunk server to identify what they hold.&lt;/li&gt;
      &lt;li&gt;Problem: Takes a long time.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Other problem: Op log can be very long.
    &lt;ol&gt;
      &lt;li&gt;Solution: Checkpointing state from time to time. Only read logs after the most recent checkpoint.&lt;/li&gt;
      &lt;li&gt;Problem: Checkpointing can slow down Master.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;gfs-reads&quot;&gt;GFS Reads&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image3.png&quot; alt=&quot;GFS Reads&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Caching and batched reads -&amp;gt; fewer operations for Master.&lt;/li&gt;
  &lt;li&gt;It is possible that one of the cached replicas has missed some writes and our client may read from it.&lt;/li&gt;
  &lt;li&gt;Since most mutations are just appends, we don’t see incorrect data. Just less than we’d like.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;gfs-writes&quot;&gt;GFS Writes&lt;/h3&gt;

&lt;h4 id=&quot;considerations&quot;&gt;Considerations&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;How can we write as fast as possible considering Google’s network bandwidth?&lt;/li&gt;
  &lt;li&gt;How can we determine an ordering of concurrent writes?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Answer: By separating data transfer and ordering of writes.&lt;/p&gt;

&lt;h4 id=&quot;data-transfer&quot;&gt;Data Transfer&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image4.png&quot; alt=&quot;Data Transfer&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Data is pipelined. As soon as A receives packets, it forwards data to B, C etc.&lt;/li&gt;
  &lt;li&gt;Data is always sent to the closest replica that hasn’t received it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;concurrent-writes&quot;&gt;Concurrent Writes&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image5.png&quot; alt=&quot;Concurrent Write Problem in GFS&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;When we make writes to chunks, we want all replicas to see the same data!&lt;/li&gt;
  &lt;li&gt;Only way to make this happen - write to chunk replicas in the same order on all clients.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;chunk-leases&quot;&gt;Chunk Leases&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image6.png&quot; alt=&quot;Chunk Leases in GFS&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;When a client wants to write to a chunk, Master will assign one of the replicas a “chunk lease” if not already assigned.
    &lt;ul&gt;
      &lt;li&gt;Chunk lease - primary node for the particular chunk, which will determine the order of writes&lt;/li&gt;
      &lt;li&gt;Initial timeout of 60s, can be extended in heartbeats.&lt;/li&gt;
      &lt;li&gt;Primary chunk picks the order of writes and forwards to other replicas.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;write-consistency&quot;&gt;Write Consistency&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;By splitting the data transfer and order of writes, we get maximum throughput while keeping the data in a chunk the same across replicas.
    &lt;ol&gt;
      &lt;li&gt;If we fail to apply a write to all replicas, client will retry a couple of times.&lt;/li&gt;
      &lt;li&gt;If retries keep failing, Master checks the version number of chunks in replicas&lt;/li&gt;
      &lt;li&gt;Each chunk has a version number, so if Master notices a replica with a lower version number than others, it will consider the replica invalid and replace it with a new node.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;writes-to-multiple-chunks&quot;&gt;Writes to Multiple Chunks&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image7.png&quot; alt=&quot;Writes to Multiple chunks&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Situation:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If a write by the application is large or straddles a chunk boundary, GFS client code breaks it down into multiple write operations.&lt;/li&gt;
  &lt;li&gt;x is on chunk1, y is on chunk2.&lt;/li&gt;
  &lt;li&gt;A is primary for chunk1, C is primary for chunk2&lt;/li&gt;
  &lt;li&gt;Writes across chunks can be interleaved.&lt;/li&gt;
  &lt;li&gt;Need distributed locks to solve for this. Super complicated!&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;atomic-record-appends&quot;&gt;Atomic Record Appends&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;GFS exposes an operation to append data at the end of a file without worrying about data being overwritten by any concurrent writes/needing to get a lock.&lt;/li&gt;
  &lt;li&gt;Record append is the simplest way to ensure the data has been written consistently. When one client writes a chunk, the chunk will be locked, the other client’s writing will be arranged for the next chunk. GFS keeps every appending chunk written &lt;strong&gt;at least once atomically&lt;/strong&gt;. When multiple clients write a chunk concurrently, &lt;strong&gt;at least once atomically&lt;/strong&gt; keeps the record appended as multiple-producer/single-consumer.&lt;/li&gt;
  &lt;li&gt;How does this work?
    &lt;ul&gt;
      &lt;li&gt;Client pushes data to replicas of last file chunk
        &lt;ul&gt;
          &lt;li&gt;If data fits in the chunk, apply like a normal write and return offset.&lt;/li&gt;
          &lt;li&gt;Otherwise, pad the chunk to full size (Lazy space allocation), tell client to retry. Replicas are padded as well.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;If write fails and subset of replicas do not get data, client retries&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Catch
    &lt;ul&gt;
      &lt;li&gt;Possibility of duplicates when write is retried.&lt;/li&gt;
      &lt;li&gt;Downstream consumers must be equipped to handle padding/duplicates.&lt;/li&gt;
      &lt;li&gt;Any operations should be idempotent/de-duplicated.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;implications-for-clients&quot;&gt;Implications For Clients&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Prefer appends to writes.
    &lt;ol&gt;
      &lt;li&gt;No need for locking.&lt;/li&gt;
      &lt;li&gt;No interleaving&lt;/li&gt;
      &lt;li&gt;Readers need to be able to handle padding/duplicates.
        &lt;ol&gt;
          &lt;li&gt;Use checksums to confirm the validity of the data.&lt;/li&gt;
          &lt;li&gt;Generate idempotency keys from duplicates.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once data is written, how do we ensure its durability?&lt;/p&gt;

&lt;h3 id=&quot;ensuring-durability---replication&quot;&gt;Ensuring Durability - Replication&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;GFS has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RF=3&lt;/code&gt;
    &lt;ol&gt;
      &lt;li&gt;“Rack aware”, to place chunks across racks, to reduce the risk of rack failure.&lt;/li&gt;
      &lt;li&gt;Data is lost when all replicas of a chunk are lost.&lt;/li&gt;
      &lt;li&gt;Choose replicas with low disk usage and not many recently created files.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Master “heartbeats” replicas to keep track of replicas per chunk
    &lt;ol&gt;
      &lt;li&gt;Any corrupted/outdated chunk not counted – master will bring up a newer replica.&lt;/li&gt;
      &lt;li&gt;Copies data from existing replicas&lt;/li&gt;
      &lt;li&gt;Higher priority given to chunks with fewer remaining replicas&lt;/li&gt;
      &lt;li&gt;Amount of replica copying at once is limited to avoid overloading GFS.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;State replicas identified with version numbers. How about corrupted ones? Checksums!&lt;/p&gt;

&lt;h4 id=&quot;checksums&quot;&gt;Checksums&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;To ensure data integrity, we basically sum up the bytes in a message&lt;/li&gt;
  &lt;li&gt;If data doesn’t match checksum, there is likely corruption&lt;/li&gt;
  &lt;li&gt;Checksums for every 64kb kept in memory. Meaning - 64MB/64kb = ~1000 checksums/chunk of data and kept in memory and WAL.&lt;/li&gt;
  &lt;li&gt;For reads
    &lt;ul&gt;
      &lt;li&gt;Chunkserver verifies check sums before returning data&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;For append
    &lt;ul&gt;
      &lt;li&gt;Compute checksums as we write.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;For writes
    &lt;ul&gt;
      &lt;li&gt;Checksums are expensive.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;other-performance-optimizations&quot;&gt;Other Performance Optimizations&lt;/h3&gt;

&lt;h4 id=&quot;copy-on-write-file-snapshotting&quot;&gt;Copy On Write File Snapshotting&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;Easily copy a file with another name,&lt;/li&gt;
  &lt;li&gt;No actual copy happens. Master adds another file pointing to the same exact chunks.
    &lt;ul&gt;
      &lt;li&gt;Primary replica lease revoked for chunks. Chunks must ask the Master to write again.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;When a user wants to modify one of the chunks, it gets duplicated!
    &lt;ul&gt;
      &lt;li&gt;Master knows when a chunk is referenced by multiple files&lt;/li&gt;
      &lt;li&gt;All replicas of a chunk duplicated locally (Saved network B/W)&lt;/li&gt;
      &lt;li&gt;Master metadata updated to point to new chunk&lt;/li&gt;
      &lt;li&gt;Can write to new chunk&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flipside - unequal # of chunks across chunkserver nodes. Solution - Rebalancing.&lt;/p&gt;

&lt;h4 id=&quot;rebalancing-chunks&quot;&gt;Rebalancing Chunks&lt;/h4&gt;

&lt;p&gt;Master checks for an uneven number of chunks across chunkserver nodes and distributes them as a background thread.&lt;/p&gt;

&lt;h4 id=&quot;master-namespace-concurrency&quot;&gt;Master Namespace Concurrency&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;We run the Master in a multi-threaded fashion.&lt;/li&gt;
  &lt;li&gt;Each path has a reader/writer lock.&lt;/li&gt;
  &lt;li&gt;This is for metadata operations (creating file path)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;E.g.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/                        R
/logs/server1/           R
/logs/server1/log1.txt   W
/logs/server1/log2.txt  
   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;lazy-garbage-collection&quot;&gt;Lazy Garbage Collection&lt;/h4&gt;

&lt;p&gt;Background thread to free-up disk space containing chunks that are corrupted, stale or deleted.&lt;/p&gt;

&lt;h4 id=&quot;shadow-master&quot;&gt;Shadow Master&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;HA setup for GFS.&lt;/li&gt;
  &lt;li&gt;Warm node backing the Master. Op logs streamed to the warm node&lt;/li&gt;
  &lt;li&gt;Can be made to take over when Master node fails.&lt;/li&gt;
  &lt;li&gt;Stale metadata possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;highlights&quot;&gt;Highlights&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Failure is expected
    &lt;ol&gt;
      &lt;li&gt;Op log and checkpointing in Master node.&lt;/li&gt;
      &lt;li&gt;Version number, checksums, rack aware replicas in chunkservers.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Design for your requirements
    &lt;ol&gt;
      &lt;li&gt;Favours small appends over large writes, many reads.&lt;/li&gt;
      &lt;li&gt;Optimized for N/W bandwidth, data transfer pipelining vs. data ordering&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Single Master is OKAY
    &lt;ol&gt;
      &lt;li&gt;Allows global view of state&lt;/li&gt;
      &lt;li&gt;Need optimizations to avoid bottlenecks&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;drawbacks&quot;&gt;Drawbacks&lt;/h2&gt;

&lt;h3 id=&quot;master-node-fault-tolerance&quot;&gt;Master Node Fault-Tolerance&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;GFS relies on a single master node to manage metadata (file namespace, chunk locations, etc.). This can become a bottleneck, both in terms of performance and scalability. If the master node becomes overloaded, it can limit the throughput of the entire system.&lt;/li&gt;
  &lt;li&gt;Additionally, the failure of the master node, while recoverable, can disrupt the system until it is fully restored.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;ineffective-for-smaller-files--not-suited-for-random-writes&quot;&gt;Ineffective for Smaller Files / Not suited for Random Writes&lt;/h3&gt;

&lt;p&gt;GFS is optimized for large files and large sequential writes. However, it performs poorly with small files and random writes, leading to hot partitions.&lt;/p&gt;

&lt;h3 id=&quot;consistency-issues&quot;&gt;Consistency Issues&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;GFS only provides &lt;strong&gt;relaxed consistency guarantees&lt;/strong&gt;. This means that applications must be tolerant of inconsistencies, which can occur during failures or concurrent writes.&lt;/li&gt;
  &lt;li&gt;While this works for certain applications, such as log processing and batch jobs, it can be problematic for use cases requiring strong consistency guarantees.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;high-latency-for-realtime-applications&quot;&gt;High Latency For Realtime Applications&lt;/h3&gt;

&lt;p&gt;GFS was optimized for batch processing, leading to higher latency for real-time applications like Search and Gmail.&lt;/p&gt;

&lt;h2 id=&quot;gfs-vs-colossus&quot;&gt;GFS vs Colossus&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/paper-gfs/image8.png&quot; alt=&quot;Colossus&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;differentiators&quot;&gt;Differentiators&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Disaggregation of resources - Scalable Metadata System and Storage Layer.&lt;/li&gt;
  &lt;li&gt;Also, minimal # of hops between client and disk.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;components&quot;&gt;Components&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Client Library&lt;/strong&gt;
    &lt;ol&gt;
      &lt;li&gt;Interface for applications to interact with Colossus.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Control Plane&lt;/strong&gt;
    &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;Curators&lt;/strong&gt;
        &lt;ol&gt;
          &lt;li&gt;Scalable Metadata Service, storing it in BigTable. - 100x better than the largest GFS cluster.&lt;/li&gt;
          &lt;li&gt;The curators manage metadata, keeps track of where all the files are located and their relevant information.&lt;/li&gt;
          &lt;li&gt;Clients talk directly to curators for control operations, such as file creation, and can scale horizontally.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Custodians&lt;/strong&gt;
        &lt;ol&gt;
          &lt;li&gt;Background Storage Manager.&lt;/li&gt;
          &lt;li&gt;Manages the disk space and performs garbage collection.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;D Servers&lt;/strong&gt;
        &lt;ol&gt;
          &lt;li&gt;File servers that store data.&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;gfs-vs-hdfs&quot;&gt;GFS vs HDFS&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Feature&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;GFS&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;HDFS&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Master Node/HA&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Single master node, no HA by default&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;NameNode with HA and secondary NameNode&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Fault Tolerance&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Replication of chunks (3 copies)&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Replication of blocks (3 copies, HA)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Consistency&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Relaxed, allows inconsistencies&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Stricter, write-once-read-many&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;File Access&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Sequential writes, inefficient small files&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Sequential writes, improved small file handling&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Block Size&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;64 MB&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;128 MB&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Random Writes&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Inefficient&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Not supported&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Interface&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Proprietary&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;POSIX compliant API&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Servers&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Master, Chunkserver&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Name node, Data node&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;WAL&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Oplog&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Journal, edit log&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Database files&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Bigtable sits on top of GFS&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;HBase sits on top of HDFS&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=haho0XAFoeY&quot;&gt;Jordan Has No Life - GFS Review&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://queue.acm.org/detail.cfm?id=1594206&quot;&gt;GFS: Evolution on Fast-forward&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=EpIgvowZr00&amp;amp;t=10s&quot;&gt;MIT 6.824: Distributed Systems - GFS Lecture&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=q4WC_6SzBz4&amp;amp;t=500s&quot;&gt;A peek behind the VM at the Google Storage infrastructure - Colossus&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://pdos.csail.mit.edu/6.824/papers/gfs-faq.txt&quot;&gt;MIT 6.824: Distributed Systems - GFS Lecture - FAQ&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://pdos.csail.mit.edu/6.824/notes/l-gfs.txt&quot;&gt;MIT 6.824: Distributed Systems - GFS Lecture - Notes&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
				<pubDate>Sat, 05 Oct 2024 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/papers/Google-File-System/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/papers/Google-File-System/</guid>
			</item>
		
			<item>
				<title>Transferring Email Between Service Providers</title>
				<description>&lt;p&gt;I manage a bunch of domains and often times, run them on paid service providers. I used to run my primary domain with Outlook. But with time, their service had locked-in a lot of features for free users. First configuring and creating additional mail boxes, then issues setting up &lt;a href=&quot;https://www.cloudflare.com/learning/email-security/dmarc-dkim-spf/&quot;&gt;DMARC, DKIM and SPF records&lt;/a&gt; for owenrs of custom/free domains and restricting supported email clients and the like. I wanted to shift to a provider with a decent customer and email client client support. &lt;a href=&quot;https://migadu.com/&quot;&gt;Migadu&lt;/a&gt; seemed like the perfect fit.&lt;/p&gt;

&lt;p&gt;The only downside to the entire exercise is retaining my previous emails. There were a lot of useful email transactions that were saved in my mailbox over the years and I did not want to miss out on them. That is when I discovered &lt;a href=&quot;https://imapsync.lamiral.info/&quot;&gt;Imapsync&lt;/a&gt; tool - that you can run yourself.&lt;/p&gt;

&lt;h3 id=&quot;dryrun&quot;&gt;Dryrun&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;imapsync &lt;span class=&quot;nt&quot;&gt;--dry&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--host1&lt;/span&gt; outlook.office365.com &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--user1&lt;/span&gt; me@dwarak.in &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--ssl1&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--sep1&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--prefix1&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;  &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--host2&lt;/span&gt; imap.migadu.com &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--user2&lt;/span&gt; me@dwarak.in &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--ssl2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;actual&quot;&gt;Actual&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;imapsync &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--host1&lt;/span&gt; outlook.office365.com &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--user1&lt;/span&gt; me@dwarak.in &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--authmech1&lt;/span&gt; LOGIN &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--ssl1&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--sep1&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--passfile1&lt;/span&gt; pass-dwarak.txt &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--prefix1&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;  &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--host2&lt;/span&gt; imap.migadu.com &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--user2&lt;/span&gt; me@dwarak.in &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--passfile2&lt;/span&gt; pass-migadu.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;My only gripe with this tool is its availability with popular upstream package repositories like apt. This is still not available to install via apt package manager at the time of writing. &lt;a href=&quot;https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919587&quot;&gt;Debian bug #919587&lt;/a&gt;. Hopefully, that gets resolved. Otherwise, this is a fantastic tool to work with :)&lt;/p&gt;
</description>
				<pubDate>Sun, 25 Aug 2024 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2024/08/25/Transferring-Email-Between-Providers/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2024/08/25/Transferring-Email-Between-Providers/</guid>
			</item>
		
			<item>
				<title>Recommended Readings for CS Graduate</title>
				<description>&lt;blockquote&gt;
  &lt;p&gt;The following is my own response on the lobste.rs’ thread - &lt;a href=&quot;https://lobste.rs/s/d1c7vd/recommended_readings_for_recent_cs&quot;&gt;Recommended readings for a recent CS graduate &lt;/a&gt;, saved here for reference purposes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;things-you-can-consider---in-no-particular-order&quot;&gt;Things you can consider - (in no particular order)&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Start following the &lt;a href=&quot;https://blog.acolyer.org/&quot;&gt;morning paper&lt;/a&gt; - small pieces of wisdom that you can accumulate everyday&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://lobste.rs/s/wqujvc/books_every_programmer_should_read&quot;&gt;Some book recommendations that every programmer should read - previous lobsters thread&lt;/a&gt;. Do check out &lt;a href=&quot;https://lobste.rs/s/wqujvc/books_every_programmer_should_read#c_ngzhio&quot;&gt;hwayne@’s response&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;You will surely find something interesting to pick at &lt;a href=&quot;https://hackernewsbooks.com/&quot;&gt;HackerNewsBooks book aggregator&lt;/a&gt; - alongside some fiction/non-fiction too. &lt;del&gt;[NOTE - The site’s aggregation functionality has been down for a while]&lt;/del&gt; &lt;strong&gt;The site is back up now.&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;Follow &lt;a href=&quot;https://github.com/papers-we-love/papers-we-love&quot;&gt;PapersWeLove&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;some-of-my-personal-favourites-here&quot;&gt;Some of my personal favourites here&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://john.regehr.org/reading_list/&quot;&gt;A Reading List for Computer Scientists&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://akkadia.org/drepper/cpumemory.pdf&quot;&gt;What Every Programmer Should Know About Memory&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.brendangregg.com/books.html&quot;&gt;Brendan Gregg’s Book List&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://begriffs.com/posts/2017-04-13-longterm-computing-reading.html&quot;&gt;Good books for Deep Hacks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dev.to/lpasqualis/11-books-all-software-engineers-must-read&quot;&gt;11 Books All Software Engineers Must Read&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://blog.jessfraz.com/post/books/&quot;&gt;Books I recommend by Jessie Frazelle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://metaredux.com/posts/2020/03/27/the-books-that-every-programmer-should-read.html#fn:3&quot;&gt;The Books That Every Programmer Should Read&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;also-check&quot;&gt;Also Check&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;/2018/11/24/CS-Book-List/&quot;&gt;CS Book List&lt;/a&gt;&lt;/p&gt;
</description>
				<pubDate>Sun, 13 Dec 2020 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2020/12/13/Recommended-Readings-For-CS-Graduate/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2020/12/13/Recommended-Readings-For-CS-Graduate/</guid>
			</item>
		
			<item>
				<title>nVidia Does Hate Linux</title>
				<description>&lt;p&gt;Last weekend was fantastic. One more line struck off my to-do list. I had the chance to build my first desktop. While this isn’t a post about how to choose the best PC parts, I’d still like you to know the parts I picked, for my rant to make sense.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Type&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Item&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;CPU&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/bddxFT/amd-ryzen-7-2700x-37ghz-8-core-processor-yd270xbgafbox&quot;&gt;AMD Ryzen 7 2700X 3.7 GHz 8-Core Processor&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Motherboard&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/XQgzK8/asus-rog-strix-b450-f-gaming-atx-am4-motherboard-strix-b450-f-gaming&quot;&gt;Asus ROG STRIX B450-F GAMING ATX AM4 Motherboard&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Memory&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/jGvbt6/crucial-16-gb-1-x-16-gb-ddr4-2400-memory-ct16g4dfd824a&quot;&gt;Crucial 16 GB (1 x 16 GB) DDR4-2400 Memory&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Storage&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/hzdxFT/gigabyte-256gb-m2-2280-solid-state-drive-gp-gsm2ne8256gntd&quot;&gt;Gigabyte 256 GB M.2-2280 NVME Solid State Drive&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Video Card&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/2BjWGX/msi-video-card-gt7102gd3lp&quot;&gt;MSI GeForce GT 710 2 GB Video Card&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Power Supply&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/6rc48d/corsair-vs-450w-80-certified-atx-power-supply-cp-9020170-na&quot;&gt;Corsair VS 450 W 80+ Certified ATX Power Supply&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Keyboard&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;a href=&quot;https://in.pcpartpicker.com/product/q7648d/corsair-k55-rgb-wired-gaming-keyboard-ch-9206015-na&quot;&gt;Corsair K55 RGB Wired Gaming Keyboard&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Most of the choices were obvious. Though I could’ve gone with the latest Ryzen 3000 series CPU, I didn’t know how well the support was. Also, since I am yet to figure how I’ll be using this CPU (definitely not extensive gaming) I didn’t want to burn all my cash for a top-of-the-line costly choice, when I had a cheaper alternate(Ryzen 2000s) that more than compensated for what I would want. Price point is also the reason I went with AMD than Intel. Motherboard, ironically is a gaming motherboard which I’m guessing will prove useful if and when I plan to upgrade the parts. &lt;a href=&quot;https://en.wikipedia.org/wiki/NVM_Express&quot;&gt;NVMe&lt;/a&gt; based M.2 SSD disks are not a luxury anymore. The write speed is consistent between 600-750 MBps which translates to dramatic performance in boot and file access times. Reads touch over 4 Gigs per second, which I’m guessing is a screw up with the script I wrote. Theoretically though they can touch 1GBps.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/zero &lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/tmp/tempfile &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;512M &lt;span class=&quot;nv&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10 &lt;span class=&quot;nv&quot;&gt;oflag&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;dsync &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;progress&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
5368709120 bytes &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;5.4 GB, 5.0 GiB&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; copied, 9 s, 607 MB/s
10+0 records &lt;span class=&quot;k&quot;&gt;in
&lt;/span&gt;10+0 records out
5368709120 bytes &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;5.4 GB, 5.0 GiB&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; copied, 8.84148 s, 607 MB/s
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/tmp/tempfile &lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/null &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;512M &lt;span class=&quot;nv&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10 &lt;span class=&quot;nv&quot;&gt;oflag&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;dsync &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;progress&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
4294967296 bytes &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;4.3 GB, 4.0 GiB&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; copied, 1 s, 4.2 GB/s
10+0 records &lt;span class=&quot;k&quot;&gt;in
&lt;/span&gt;10+0 records out
5368709120 bytes &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;5.4 GB, 5.0 GiB&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; copied, 1.2505 s, 4.3 GB/s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Power consumption of the CPU came about 220W, for which 450W Corsair SMPS also fit the bill. The one-fucked-up-decision I took was to get a nVidia based Graphics Card!&lt;/p&gt;

&lt;p&gt;While I didn’t know earlier that &lt;a href=&quot;https://www.reddit.com/r/linuxmasterrace/comments/50n99n/why_nvidia_is_so_unfriendly_with_linux/&quot;&gt;nVidia hated Linux&lt;/a&gt;, I definitely didn’t expect the support to be this bad. I didn’t want to compromise on my CPU’s display refresh rate and I made sure I got a graphics card that gave &lt;a href=&quot;https://www.geforce.com/hardware/desktop-gpus/geforce-gt-710/specifications&quot;&gt;4k resolution with 60Hz refresh rate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I flashed my drive with Ubuntu MATE 18.04.2 LTS and all was well until I upgraded my desktop to the latest nVidia 430.26 driver. Even when I was able to set 60Hz refresh rate for 3840x2160 4k resolution, I was seeing my screen getting torn by the subsequent frames that it tried to process. Thanks to nVidia, Freesync(or GSync as they call it) was &lt;a href=&quot;https://forums.geforce.com/default/topic/1094573/geforce-drivers/freesync-with-hdmi/&quot;&gt;not supported with HDMI&lt;/a&gt; too. After a bunch of experiements, I had to downgrade to a more comfortable QHD 2560x1440 resolution.&lt;/p&gt;

&lt;p&gt;MATE Desktop complicates this by failing to detect the window scaling factor. (Setting within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mate-tweak&lt;/code&gt; tool.).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/nvidia-hates-linux/mate-tweak.png&quot; alt=&quot;mate-tweak&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I finally had to resort to manually setting the value within the Apperance dialog. [Reference - &lt;a href=&quot;https://askubuntu.com/a/692023&quot;&gt;Ask Ubuntu - Ubuntu Mate desktop scaling for 4k displays&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/nvidia-hates-linux/appearance.png&quot; alt=&quot;mate-desktop-appearance-dialog&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This was such a let down. For someone who isn’t interested in playing graphics-heavy games in a Windows machine, the only reason to spend money would be better window graphics. Why is nVidia doing such a fuck-all job with linux support?&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;a href=&quot;https://in.pcpartpicker.com/list/pQYtV6&quot;&gt;My CPU Build&lt;/a&gt;&lt;/p&gt;
</description>
				<pubDate>Mon, 05 Aug 2019 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2019/08/05/nVidia-Does-Hate-Linux/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2019/08/05/nVidia-Does-Hate-Linux/</guid>
			</item>
		
			<item>
				<title>Aasarakovai</title>
				<description>&lt;p&gt;A while ago, I came across a great profile in Twitter - &lt;a href=&quot;https://twitter.com/OldTamilPoetry&quot;&gt;OldTamilPoetry&lt;/a&gt; which brings a lot of classical Tamil poetry back into light with soulful translations. Many of them blew my mind, one of which was Aasarakovai. Little did I know about this literature, let alone the poem.&lt;/p&gt;

&lt;p&gt;Talk about timing - just when I am discovering more about personalities and social behavior (growing up in short. But who would miss the chance to show off some book reading skills :P), this poem was such an eye opener. Not that the thought is unique today. But to think of this being ever relevant - since more than a millennium ago is so profound. To find what would typically be told by the likes of Steve Pinker and Jordan Peterson in a Sangam Literature Tamil poem is “deep” to say the least - for the lack of a better word. Made me realize Wisdom and Sapience are never restrained by the illusion of superiority in language or race.&lt;/p&gt;

&lt;p&gt;All the while, it is equally comical to see that our species hasn’t evolved philosophically for ages. Is this an assertion of us being genetically good at bullshitting? You tell me!&lt;/p&gt;

&lt;pre&gt;
விரைந்து உரையார்; மேன்மேல் உரையார்; பொய் ஆய
பரந்து உரையார்; பாரித்து உரையார்;ஒருங்கு எனைத்தும்
சில் எழுத்தினானே, பொருள் அடங்க, காலத்தால்
சொல்லுப செவ்வி அறிந்து!
&lt;/pre&gt;

&lt;h3 id=&quot;translation&quot;&gt;Translation&lt;/h3&gt;

&lt;p&gt;Don’t talk fast; don’t talk often;
don’t embellish with lies; don’t be verbose – but
cover the subject with clarity, use few words
and speak at the right moment.&lt;/p&gt;

&lt;p&gt;One must not talk fast; should not repeat his sentences; should not exaggerate and lie; and must not use too many words. On the other hand, cover the subject completely and with clarity, use only few words to explain oneself and wait for the right time to put forward his thoughts.&lt;/p&gt;

&lt;hr /&gt;
&lt;ul&gt;
  &lt;li&gt;Reference from &lt;a href=&quot;https://twitter.com/OldTamilPoetry/status/1148093132430426113&quot;&gt;OldTamilPoetry status on Aasarakovai&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://oldtamilpoetry.com/&quot;&gt;OldTamilPoetry Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
				<pubDate>Tue, 30 Jul 2019 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/books/Aasarakovai/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/books/Aasarakovai/</guid>
			</item>
		
			<item>
				<title>Harry Potter Series</title>
				<description>&lt;p&gt;Quite a number of kids grow up to become potter heads - For it not only conjures images of a far away land where magic is real and dragons are alive, it has a certain charm about it and a beautiful way of teaching some of life’s best lessons through its characters.&lt;/p&gt;

&lt;p&gt;I grew up with it as a kid and no matter how much I read, I still find a thing or two giving me “Aha!” moments every single time. It is very surreal, I know :)&lt;/p&gt;

&lt;p&gt;Some of its best quotes here -&lt;/p&gt;

&lt;h3 id=&quot;1-socerers-stone&quot;&gt;1. Socerer’s Stone&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“The truth.” Dumbledore sighed. “It is a beautiful and terrible thing, and should therefore be treated with great caution.”&lt;/li&gt;
  &lt;li&gt;“It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends.” - Dumbledore&lt;/li&gt;
  &lt;li&gt;“It does not do to dwell on dreams and forget to live.”&lt;/li&gt;
  &lt;li&gt;“Fear of a name increases fear of the thing itself.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;2-chamber-of-secrets&quot;&gt;2. Chamber of Secrets&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“It is our choices, Harry, that show what we truly are, far more than our abilities.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;3-prisoner-of-azkaban&quot;&gt;3. Prisoner of Azkaban&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“Happiness can be found, even in the darkest of times, if one only remembers to turn on the light.”&lt;/li&gt;
  &lt;li&gt;“You think the dead we loved truly ever leave us? You think that we don’t recall them more clearly in times of great trouble?”&lt;/li&gt;
  &lt;li&gt;“What you fear most of all is —fear. Very wise…”&lt;/li&gt;
  &lt;li&gt;“He was my mum and dad’s best friend. He’s a convicted murderer, but he’s broken out of wizard prison and he’s on the run. He likes to keep in touch with me, though…keep up with my news…check if I’m happy…”&lt;/li&gt;
  &lt;li&gt;“Mischief Managed.”&lt;/li&gt;
  &lt;li&gt;“The consequences of our actions are always so complicated, so diverse, that predicting the future is a very difficult business indeed.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;4-goblet-of-fire&quot;&gt;4. Goblet of Fire&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“If you want to know what a man’s like, take a good look at how he treats his inferiors, not his equals”&lt;/li&gt;
  &lt;li&gt;“It matters not what someone is born, but what they grow to be”&lt;/li&gt;
  &lt;li&gt;“Remember, if the time should come when you have to make a choice between what is right and what is easy, remember what happened to a boy who was good, and kind, and brave, because he strayed across the path of Lord Voldemort. Remember Cedric Diggory.”&lt;/li&gt;
  &lt;li&gt;“We are only as strong as we are united, as weak as we are divided.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;5-order-of-phoenix&quot;&gt;5. Order Of Phoenix&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“Wit beyond measure is man’s greatest treasure.”&lt;/li&gt;
  &lt;li&gt;“Indifference and neglect often do much more damage than outright dislike.”&lt;/li&gt;
  &lt;li&gt;Things we lose have a way of coming back to us in the end, if not always in the way we expect&lt;/li&gt;
  &lt;li&gt;Youth can not know how age thinks and feels. But old men are guilty if they forget what it was to be young.&lt;/li&gt;
  &lt;li&gt;“You should write a book,” Ron told Hermione as he cut up his potatoes, “translating mad things girls do so boys can understand them.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;6-half-blood-prince&quot;&gt;6. Half Blood Prince&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“It is the unknown we fear when we look upon death and darkness, nothing more.”&lt;/li&gt;
  &lt;li&gt;“Dumbledore says people find it far easier to forgive others for being wrong than being right.”&lt;/li&gt;
  &lt;li&gt;“When you have seen as much of life as I have, you will not underestimate the power of obsessive love.”&lt;/li&gt;
  &lt;li&gt;“Dumbledore’s man through and through, aren’t you Potter?”. “Yeah I am,” said Harry. “Glad we straightened that out.”&lt;/li&gt;
  &lt;li&gt;“Killing is not so easy as the innocent believe.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;7-deathly-hallows&quot;&gt;7. Deathly Hallows&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;“Do not pity the dead, Harry. Pity the living, and, above all those who live without love.”&lt;/li&gt;
  &lt;li&gt;“We’re all human, aren’t we? Every human life is worth the same, and worth saving.”&lt;/li&gt;
  &lt;li&gt;“It is a curious thing, Harry, but perhaps those who are best suited to power are those who have never sought it. Those who, like you, have leadership thrust upon them, and take up the mantle because they must, and find to their own surprise that they wear it well.”&lt;/li&gt;
  &lt;li&gt;“I’m going to keep going until I succeed — or die. Don’t think I don’t know how this might end. I’ve known it for years.”&lt;/li&gt;
  &lt;li&gt;“Words are, in my not-so-humble opinion, our most inexhaustible source of magic. Capable of both inflicting injury, and remedying it.&lt;/li&gt;
  &lt;li&gt;“Of course it is happening inside your head, Harry, but why on earth should that mean that it is not real?”&lt;/li&gt;
  &lt;li&gt;“Dumbledore watched her fly away, and as her silvery glow faded he turned back to Snape, and his eyes were full of tears. “After all this time?” “Always,” said Snape.”&lt;/li&gt;
&lt;/ol&gt;
</description>
				<pubDate>Thu, 31 Jan 2019 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/books/Harry-Potter-Series/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/books/Harry-Potter-Series/</guid>
			</item>
		
			<item>
				<title>CS Book List</title>
				<description>&lt;p&gt;Here I present to you the Maslow’s Hierarchy of (Computer) Knowledge with book references that I collected from various sources.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/cs-books/cs-book-hierarchy.jpg&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Be curious. Read widely. Try new things. What people call intelligence just boils down to curiosity - Aaron Swartz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;1-hardware-hw---the-fundamentals&quot;&gt;1. Hardware (H/W) - The fundamentals.&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/18118111-computer-organization-and-design-mips-edition&quot;&gt;Computer Organization and Design MIPS Edition&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/70135.Computer_Architecture&quot;&gt;Computer Architecture: A Quantitative Approach&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;2-operating-systems&quot;&gt;2. Operating Systems&lt;/h2&gt;

&lt;p&gt;This can be basic Operating system fundamentals or a little higher level of abstraction - Linux/BSD Operating system design.&lt;/p&gt;

&lt;h4 id=&quot;basics&quot;&gt;Basics&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/83833.Operating_System_Concepts&quot;&gt;Operating System Concepts&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/166195.Modern_Operating_Systems&quot;&gt;Modern Operating Systems&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;linuxbsd&quot;&gt;Linux/BSD&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/337343.The_Design_of_the_UNIX_Operating_System&quot;&gt;The Design of the UNIX Operating System&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/337375.Lions_Commentary_on_UNIX_6th_Edition_with_Source_Code&quot;&gt;Lions’ Commentary on Linux&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/112388.The_Design_and_Implementation_of_the_FreeBSD_Operating_System&quot;&gt;The Design and Implementation of the FreeBSD Operating System&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;3-components-within-os---stacks&quot;&gt;3. Components within OS - Stacks&lt;/h2&gt;

&lt;h4 id=&quot;networking&quot;&gt;Networking&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/83847.Computer_Networking&quot;&gt;Computer Networking: A Top-Down Approach&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Unix Network Programming - &lt;a href=&quot;https://www.goodreads.com/book/show/258607.Unix_Network_Programming_Volume_1&quot;&gt;Volume #1&lt;/a&gt; and &lt;a href=&quot;https://www.goodreads.com/book/show/258608.UNIX_Network_Programming_Volume_2&quot;&gt;Volume #2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://hpbn.co/&quot;&gt;High Performance Browser Networking - a hands-on overview of what every web developer needs to know&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;databases&quot;&gt;Databases&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/161304.Database_Management_Systems&quot;&gt;Introductory - Database Management Systems&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/1416957.Transaction_Processing&quot;&gt;Advanced - Transaction Processing: Concepts and Techniques&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;compilers&quot;&gt;Compilers&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/6770855-language-implementation-patterns&quot;&gt;Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/887908.Advanced_Compiler_Design_and_Implementation&quot;&gt;Advanced Compiler Design and Implementation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/112262.Compilers&quot;&gt;Compilers: Principles, Techniques, and Tools&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;4-algorithms--logic&quot;&gt;4. Algorithms &amp;amp; Logic&lt;/h2&gt;

&lt;h4 id=&quot;algorithms&quot;&gt;Algorithms&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/108986.Introduction_to_Algorithms&quot;&gt;Introduction to Algorithms - CLRS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/425208.The_Algorithm_Design_Manual&quot;&gt;The Algorithm Design Manual&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;programming-language-theory&quot;&gt;Programming Language Theory&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/43713.Structure_and_Interpretation_of_Computer_Programs&quot;&gt;Structure and Interpretation of Computer Programs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://htdp.org/&quot;&gt;Intermediate - How to Design Programs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/772585.Concepts_Techniques_and_Models_of_Computer_Programming&quot;&gt;Advanced - Concepts, Techniques, and Models of Computer Programming&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;mathematics-for-cs&quot;&gt;Mathematics for CS&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Yet to find out&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;5-writing-great-code&quot;&gt;5. Writing Great Code&lt;/h2&gt;

&lt;h4 id=&quot;entry-level-engineer&quot;&gt;Entry-Level Engineer&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;The Art of Computer Programming&lt;/li&gt;
  &lt;li&gt;Introduction to Algorithms - [Also referenced above]&lt;/li&gt;
  &lt;li&gt;Clean Code&lt;/li&gt;
  &lt;li&gt;Version Control with Git&lt;/li&gt;
  &lt;li&gt;Head First Design Patterns&lt;/li&gt;
  &lt;li&gt;Design Patterns: Elements of Reusable Code&lt;/li&gt;
  &lt;li&gt;Test-Driven Development&lt;/li&gt;
  &lt;li&gt;Dependency Injection (in Java) - Guice, Spring and Dagger&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;mid-level-engineer&quot;&gt;Mid-Level Engineer&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;Domain Driven Design&lt;/li&gt;
  &lt;li&gt;Refactoring&lt;/li&gt;
  &lt;li&gt;Working Effectively with Legacy Code&lt;/li&gt;
  &lt;li&gt;Foundations of Security&lt;/li&gt;
  &lt;li&gt;Agile Testing&lt;/li&gt;
  &lt;li&gt;Don’t Make Me Think&lt;/li&gt;
  &lt;li&gt;Software Project Survival Guide&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;senior-engineer&quot;&gt;Senior Engineer&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;CODE: Hidden Language of Computer Hardware and Software&lt;/li&gt;
  &lt;li&gt;Beautiful Design&lt;/li&gt;
  &lt;li&gt;Java Concurrency&lt;/li&gt;
  &lt;li&gt;Programming Pearls&lt;/li&gt;
  &lt;li&gt;NoSQL Distilled&lt;/li&gt;
  &lt;li&gt;Rocket Surgery Made Easy&lt;/li&gt;
  &lt;li&gt;Crucial Conversations&lt;/li&gt;
  &lt;li&gt;The Senior Software Engineer&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;principal-engineer&quot;&gt;Principal Engineer&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;Communications of the ACM&lt;/li&gt;
  &lt;li&gt;Beautiful Design&lt;/li&gt;
  &lt;li&gt;Pragmatic Programmer&lt;/li&gt;
  &lt;li&gt;Code Complete&lt;/li&gt;
  &lt;li&gt;Software Systems Architecture&lt;/li&gt;
  &lt;li&gt;All Software is Legacy&lt;/li&gt;
  &lt;li&gt;Building Secure Software&lt;/li&gt;
  &lt;li&gt;Success Through Failure: The Paradox of Design&lt;/li&gt;
  &lt;li&gt;Mythical Man Month&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;resouces&quot;&gt;Resouces&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://teachyourselfcs.com/&quot;&gt;teachyourselfcs.com&lt;/a&gt; - Great reference for video courses, materials, references&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://catonmat.net/archive?q=favorite%20books&quot;&gt;My 100 Favorite Programming, Computer and Science Books - by catonmat&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dtsdwarak.github.io/cs_prep/&quot;&gt;CS Prep Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
				<pubDate>Sat, 24 Nov 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/11/24/CS-Book-List/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/11/24/CS-Book-List/</guid>
			</item>
		
			<item>
				<title>Ponniyin Selvan (பொன்னியின் செல்வன்)</title>
				<description>&lt;p&gt;I’m afraid, I’m only bound by my creative abilities from hailing the astonishment this novel evokes. A few chapters into the novel and you already get teleported to an alternate universe - so enchantingly illustrated!&lt;/p&gt;

&lt;p&gt;This post is only meant for some anecdotes that I really liked.&lt;/p&gt;

&lt;h2 id=&quot;marungu-vandu&quot;&gt;Marungu Vandu&lt;/h2&gt;

&lt;p&gt;The below song was picturised as a joyous group of young women singing with pride the spate of Kaveri - over its beauty.&lt;/p&gt;

&lt;pre&gt;
மருங்கு வண்டு சிறந்தாற்ப்ப,
மணிப்பூ ஆடை - அதுபோர்த்துக்
கருங்கயற்கண் விழித்து ஒல்கி
நடந்தாய் வாழி! காவேரி!

கருங்கயற்கண் விழித்து ஒல்கி
நடந்த எல்லாம் நின்கணவன்
திருந்து செங்கோல் வளையாமை
அறிந்தேன் வாழி காவேரி!

பூவர் சோலை மயிலாடப்
புரிந்து குயில்கள் இசைபாடக்
காமர் மாலை அருகசைய
நடந்தாய் வாழி காவேரி!

காமர் மாலை அருகசைய
நடந்தாய் வாழி காவேரி!
நாம வேலின் திறங்கண்டே
அறிந்தேன் வாழி காவேரி!
&lt;/pre&gt;

&lt;h4 id=&quot;translation&quot;&gt;Translation&lt;/h4&gt;

&lt;p&gt;Now over to the part that piques our curiosity.&lt;/p&gt;

&lt;p&gt;As the bees hum on all sides you don a cloth of colourful flowers and throwing around side glances from your eyes in the form of the black fish you move on. May you flourish, Kaveri!&lt;/p&gt;

&lt;p&gt;Oh Kaveri! Wherever you flow throwing side glances in the form of fish I learnt that your master(the Chola king) exercised his sway with a sceptre which was not bent i.e. he ruled over his country in a just manner - Kaveri is described as a woman and the reason she has got her eyes open is to keep a check on her master.&lt;/p&gt;

&lt;p&gt;As peacocks dance in the groves full of flowers and as the cuckoos sang in unison with them, you glided along Kaveri, with swaying garlands of flowers on your body.&lt;/p&gt;

&lt;p&gt;Oh Kaveri, wherever you went along with swaying garlands I learnt about the efficacy of the spear of your master, the Chola King.&lt;/p&gt;

&lt;h4 id=&quot;references&quot;&gt;References&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://creative.sulekha.com/celebrating-kaaveeri_246558_blog&quot;&gt;Celebrating Kaveri&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://books.google.co.in/books?id=rkIElyxr6dkC&amp;amp;pg=PA69&amp;amp;lpg=PA69&amp;amp;dq=marungu+vandu+tamil&amp;amp;source=bl&amp;amp;ots=lLRLJNVA9B&amp;amp;sig=8QgA8Lr3PjWbalvFBiT2IaMUPJw&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ved=2ahUKEwipjPiE-OfdAhVCVH0KHTTdC1wQ6AEwDHoECAcQAQ#v=onepage&amp;amp;q=marungu%20vandu%20tamil&amp;amp;f=false&quot;&gt;Marungu Vandu - Silapathikaram Google Books&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
				<pubDate>Tue, 02 Oct 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/books/Ponniyin-Selvan/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/books/Ponniyin-Selvan/</guid>
			</item>
		
			<item>
				<title>Few YouTube playlists to catch up on</title>
				<description>&lt;p&gt;Over time I had aggregated a bunch of YouTube playlists that I wanted to follow up on.&lt;/p&gt;

&lt;h2 id=&quot;csmath&quot;&gt;CS/Math&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PL5PHm2jkkXmi5CxxI7b3JCL1TWybTDtKq&quot;&gt;Spring 2015 – Computer Architecture Lectures – Carnegie Mellon&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;15-721 Advanced Database Systems - &lt;a href=&quot;https://www.youtube.com/playlist?list=PLSE8ODhjZXjYgTIlqf4Dy9KQpQ7kn1Tl0&quot;&gt;Spring 2017&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/playlist?list=PLSE8ODhjZXjbisIGOepfnlbfxeH7TW-8O&quot;&gt;Spring 2016&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PL5Q2soXY2Zi9OhoVQBXYFIZywZXCPl4M_&quot;&gt;Computer Architecture - ETH Zürich - Fall 2017&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLE6LEE8y2Jp_z8pkiuvHo7Vz-eQEKsk-I&quot;&gt;ops-class.org 2017 Lectures - Operating Systems&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLSE8ODhjZXja3hgmuwhf89qboV1kOxMx7&quot;&gt;15-445/645 Intro to Database Systems (Fall 2018)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb&quot;&gt;MIT 6.006 Introduction to Algorithms, Fall 2011&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLZHQObOWTQDMsr9K-rj53DwVRMYO3t5Yr&quot;&gt;Essence of calculus&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLE18841CABEA24090&quot;&gt;MIT 6.001 Structure and Interpretation, 1986&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLrw6a1wE39_tb2fErI4-WkMbsvGQk9_UB&quot;&gt;MIT 6.824 Distributed Systems (Spring 2020)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLeKd45zvjcDFUEv_ohr_HdUFe97RItdiB&quot;&gt;Distributed Systems lecture series - University of Cambridge&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.cl.cam.ac.uk/teaching/2021/ConcDisSys/dist-sys-notes.pdf&quot;&gt;Associated Reading Material&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLUl4u3cNGP60_JNv2MmK3wkOt9syvfQWY&quot;&gt;MIT 18.404J Theory of Computation, Fall 2020&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLUl4u3cNGP63VIBQVWguXxZZi0566y7Wf&quot;&gt;MIT 6.172 Performance Engineering of Software Systems, Fall 2018&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;More relevant material can be found at &lt;a href=&quot;https://teachyourselfcs.com&quot;&gt;teachyourselfcs.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;fun&quot;&gt;Fun&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLAROrg3NQn7cyu01HpOv5BWo217XWBZu0&quot;&gt;Electronic Basics by GreatScott!&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLE726R7YUJTePGvo0Zga2juUBxxFTH4Bk&quot;&gt;Comprehensive Guide To pfSense 2.3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/user/eaterbc/playlists&quot;&gt;Ben Eater’s Electronics Playlists&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;economicshistory&quot;&gt;Economics/History&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PL0x7Tsixz0flbu4qaVnulcOJ3zhlEFP6E&quot;&gt;Contemporary Themes in India’s Economy by Dr Arvind Subramanian&lt;/a&gt; – &lt;a href=&quot;http://www.iitd.ac.in/CEAIITD/index.html&quot;&gt;Course Page&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=ELYR5txmTpa_c&quot;&gt;Pradhanmantri: Season 1&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;behavioral-sciences&quot;&gt;Behavioral Sciences&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLUl4u3cNGP60IKRN_pFptIBxeiMc0MCJP&quot;&gt;MIT 9.13 The Human Brain, Spring 2019&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;I’ll update the post when I get more material.&lt;/p&gt;
</description>
				<pubDate>Mon, 20 Aug 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/08/20/Few-Playlists-To-Catch-Up-On/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/08/20/Few-Playlists-To-Catch-Up-On/</guid>
			</item>
		
			<item>
				<title>Setup Samba in Your Network Server</title>
				<description>&lt;p&gt;Network file sharing has been such a pain, or it did seem so for a long time, until recently where I was pressed to have a server running in my local server.&lt;/p&gt;

&lt;p&gt;My dell machine runs a Ubuntu server 16.04 over the local LAN and hosts a good number of movies and hosts them over a Plex server for viewing. I haven’t exposed the Plex media server over the internet for security and privacy reasons. And whenever I go out of town, I prefer to take a local copy of them in my phone to kill time.&lt;/p&gt;

&lt;p&gt;Every time I wanted to take a copy in my phone, I had to manually plug the HDD off my machine and copy it over my phonne via work laptop. Why pull my hair off when I could simply setup a local network share?&lt;/p&gt;

&lt;p&gt;And so I did…&lt;/p&gt;

&lt;p&gt;Install samba in your machine&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;samba
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When you do,&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;whereis samba
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;you must see something similar to this-&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now over to creating an actual samba share.&lt;/p&gt;

&lt;p&gt;I have my movies in HDD mounted at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/media/seagate&lt;/code&gt; and so, I need to share them now. If you just need a frontend to copy the files over to the remote machine, create a folder at an appropriate place and then use that instead.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vi /etc/samba/smb.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Append the following to the above config file.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Hard disk share
[seagate]
    comment = seagate-hdd
    path = /media/seagate
    read only = no
    browsable = yes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Restart your samba service.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service smbd restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To configure password auth for your server,&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;smbpasswd &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; username
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The same can be achieved if you run other distros as well. Make sure to figure out the appropriate package names.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;I wrote this post to help as a reference for my own future setup. Content used from &lt;a href=&quot;https://tutorials.ubuntu.com/tutorial/install-and-configure-samba#0&quot;&gt;Ubuntu Tutorials Page&lt;/a&gt;. If you’d like to explore the Samba configuration further, use this &lt;a href=&quot;https://help.ubuntu.com/community/Samba/SambaServerGuide&quot;&gt;help page&lt;/a&gt;.&lt;/p&gt;
</description>
				<pubDate>Sat, 26 May 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/05/26/Setup-Samba-File-Server/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/05/26/Setup-Samba-File-Server/</guid>
			</item>
		
			<item>
				<title>Stuff to do with your own server - Part II</title>
				<description>&lt;p&gt;As a continuation of the earlier post on &lt;a href=&quot;/2017/02/26/Stuff-To-Do-With-Your-Own-Server/&quot;&gt;Stuff To Do With Your Own Server&lt;/a&gt;, I setup a DO droplet to host a couple of services online to avoid any disruptions that can happen in my local server.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/&quot;&gt;Algo VPN&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-nextcloud-on-ubuntu-16-04&quot;&gt;NextCloud&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Monitoring stack - Net data - Not yet configured&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;to-do&quot;&gt;To do&lt;/h3&gt;
&lt;p&gt;The thing to note is that, if you run a nextcloud instance as a snap as mentioned in the blog post given above, you may not be able to host multiple services running in port 80 in the same box. If you want that to happen, you should run the nextcloud snap at a different port and use nginx as a reverse proxy (in its true sense).&lt;/p&gt;

&lt;h4 id=&quot;update&quot;&gt;Update&lt;/h4&gt;

&lt;p&gt;What more can be done? Try my &lt;a href=&quot;/2017/02/26/Stuff-To-Do-With-Your-Own-Server/#optional-stuff&quot;&gt;previous post&lt;/a&gt;.&lt;/p&gt;
</description>
				<pubDate>Sun, 11 Mar 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/03/11/Host-Your-VPN/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/03/11/Host-Your-VPN/</guid>
			</item>
		
			<item>
				<title>Best technical conference talks to follow.</title>
				<description>&lt;p&gt;Over time, I’ve been following up on a lot of technical conference talks happening around. Just that I don’t get enough time to muck around and go through them with all my pending tasks at work.&lt;/p&gt;

&lt;p&gt;What follows below is the list of some of the best technical talks I wish to follow up on.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linux.conf.au/&quot;&gt;LinuxConf AU&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/user/linuxconfau2018&quot;&gt;2018 playlist&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://fosdem.org&quot;&gt;Fosdem&lt;/a&gt; - &lt;a href=&quot;https://fosdem.org/2018/schedule/&quot;&gt;2018 playlist&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://ccc.de/&quot;&gt;Chaos Computer Club&lt;/a&gt; - &lt;a href=&quot;https://media.ccc.de/&quot;&gt;Video Archive&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.blackhat.com/&quot;&gt;Black Hat&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/user/BlackHatOfficialYT&quot;&gt;YouTube channel&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cppcon.org/&quot;&gt;CppCon&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/user/CppCon&quot;&gt;YouTube channel&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.socallinuxexpo.org&quot;&gt;Southern California Linux Expo&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/user/socallinuxexpo/playlists&quot;&gt;YouTube channel&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://linuxfestnorthwest.org&quot;&gt;Linux Fest North West&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/channel/UCqeKeRXssKqbK4XHqLYrctQ/playlists&quot;&gt;YouTube channel&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.thestrangeloop.com/&quot;&gt;Strange Loop&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/channel/UC_QIfHvN9auy2CoOdSfMWDw/playlists&quot;&gt;YouTube channel&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://bangbangcon.com/&quot;&gt;BangBangCon&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://pwlconf.org/&quot;&gt;Papers We Love conference&lt;/a&gt; - &lt;a href=&quot;https://www.youtube.com/user/PapersWeLove/playlists&quot;&gt;Papers We Love YouTube channel&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;
&lt;p&gt;I’ll update this post when I find more.&lt;/p&gt;
</description>
				<pubDate>Wed, 07 Feb 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/02/07/Best-Technical-Conferences-To-Follow/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/02/07/Best-Technical-Conferences-To-Follow/</guid>
			</item>
		
			<item>
				<title>Starting with i3wm</title>
				<description>&lt;p&gt;Few things have always interested me for no reason - viz., setting up a server - what I really mean is spinning up a new server/VM instance with a new operating system that I haven’t tried yet, trying out a new window manager, stacking a shelf full of books.&lt;/p&gt;

&lt;p&gt;As part of that exercise this Saturday has been trying out the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i3&lt;/code&gt; window manager. Part of the reason is my nerd curiosity which has been tempting me to try it for a while. But part of it is also the efficiency at which you can get things done. It is super efficient if you want a desktop environment that is less resource intensive. The one I currently use is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mate-desktop&lt;/code&gt; - which is already super productive. But &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i3&lt;/code&gt; looks promising.&lt;/p&gt;

&lt;p&gt;For more information, follow the &lt;a href=&quot;https://www.youtube.com/playlist?list=PL5ze0DjYv5DbCv9vNEzFmP6sU7ZmkGzcf&quot;&gt;Youtube Screencasts on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i3wm&lt;/code&gt; by CodeCast&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Below are some shortcuts that can be used wih &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i3wm&lt;/code&gt; - more like notes from the Screencast.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Starting a new terminal - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + E&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Moving across the Windows - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + Arrow Keys&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Set window tiling to Stacked - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + S&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Set window tiling to Tab mode - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + W&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Close the window - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + Shift + Q&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Resize window - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + R&lt;/code&gt;. Use the right and left arrow keys to resize now.&lt;/li&gt;
  &lt;li&gt;Move windows around - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + Shift + Arrow Keys&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Move around workspaces - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + &amp;lt;workspace_Number&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Move windows between workspaces - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + Shift + &amp;lt;workspace_Number&amp;gt;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Run dialog - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + D&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Quit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i3&lt;/code&gt; / Logout - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mod + Shift + E&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;update&quot;&gt;Update&lt;/h3&gt;

&lt;p&gt;The progress so far has been pretty good. With the exception of following issues -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Dual monitor display profile.&lt;/li&gt;
  &lt;li&gt;Adjusting display profile upon dock/undock.&lt;/li&gt;
  &lt;li&gt;File manager integration with GUI (like with Firefox etc). Clicking “open with File Manager” option on apps like Firefox crashes i3.&lt;/li&gt;
  &lt;li&gt;Task bar integration for
    &lt;ul&gt;
      &lt;li&gt;Bluetooth&lt;/li&gt;
      &lt;li&gt;Sound&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Easy way to connect wifi networks (This I can still achieve via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nmcli&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;More to follow!&lt;/p&gt;
</description>
				<pubDate>Sat, 03 Feb 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/02/03/Starting-with-i3wm/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/02/03/Starting-with-i3wm/</guid>
			</item>
		
			<item>
				<title>Book Recommendations from 2017</title>
				<description>&lt;p&gt;Some of the best books from this &lt;a href=&quot;https://lobste.rs/s/i9s39q/best_books_you_have_read_2017&quot;&gt;lobsters thread&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;tech&quot;&gt;Tech&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Google SRE Book&lt;/li&gt;
  &lt;li&gt;Python Data Science Handbook&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.in/Designing-Data-Intensive-Applications-Reliable-Maintainable-ebook/dp/B06XPJML5D&quot;&gt;Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Category Theory for Programmers&lt;/li&gt;
  &lt;li&gt;Inventing the Internet by Janet Abbate&lt;/li&gt;
  &lt;li&gt;Serious Cryptography&lt;/li&gt;
  &lt;li&gt;Interconnections: Bridges, Routers, Switches, and Internetworking Protocols by Radia Perlman&lt;/li&gt;
  &lt;li&gt;The Leprechauns of Software Engineering&lt;/li&gt;
  &lt;li&gt;The Phoenix Project by Gene Kim&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;book-list&quot;&gt;Book list&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://begriffs.com/posts/2017-04-13-longterm-computing-reading.html&quot;&gt;Bergriff’s books for deep hacks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://shape-of-code.coding-guidelines.com/2017/12/08/christmas-book-for-2017/&quot;&gt;Christmas books for 2017 list&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;non-fiction&quot;&gt;Non-Fiction&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Weapons of Math Destruction: How Big Data Increases Inequality and Threatens Democracy&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.goodreads.com/book/show/722412.The_Dream_Machine&quot;&gt;The Dream Machine: J.C.R. Licklider and the Revolution That Made Computing Personal&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.in/Idea-Factory-Great-American-Innovation/dp/0143122797&quot;&gt;The Idea Factory: Bell Labs and the Great Age of American Innovation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;The Upside of Downtime: Why Boredom is Good&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://mitpress.mit.edu/books/programmed-inequality&quot;&gt;Programmed Inequality - How Britain Discarded Women Technologists and Lost Its Edge in Computing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://mitpress.mit.edu/hownot&quot;&gt;How Not to Network a Nation - The Uneasy History of the Soviet Internet&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://mitpress.mit.edu/books/stuff-bits&quot;&gt;The Stuff of Bits - An Essay on the Materialities of Information&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.wiley.com/en-us/The+Ambivalent+Internet%3A+Mischief%2C+Oddity%2C+and+Antagonism+Online-p-9781509501267&quot;&gt;The Ambivalent Internet: Mischief, Oddity, and Antagonism Online&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Never Split the Difference – Chris Voss&lt;/li&gt;
  &lt;li&gt;Tell me how it ends – Valeria Luiselli&lt;/li&gt;
  &lt;li&gt;The most important thing – Howard Marks&lt;/li&gt;
  &lt;li&gt;Crossing the Chasm – Geoffrey Moore&lt;/li&gt;
  &lt;li&gt;How Children Learn by John Holt&lt;/li&gt;
  &lt;li&gt;Born a Crime: Stories From a South African Childhood by Trevor Noah&lt;/li&gt;
  &lt;li&gt;The Social Amoebae: The Biology of Cellular Slime Molds&lt;/li&gt;
  &lt;li&gt;Poor Economics: A Radical Rethinking of the Way to Fight Global Poverty by Abhijit Banerjee&lt;/li&gt;
  &lt;li&gt;Design of everyday things by Donald A. Norman&lt;/li&gt;
  &lt;li&gt;Zen and the Art of Motorcycle Maintenance: An Inquiry Into Values by Robert M. Pirsig.&lt;/li&gt;
  &lt;li&gt;Gödel’s Proof by Ernest Nagel, James Roy Newman and Douglas R. Hofstadter.&lt;/li&gt;
  &lt;li&gt;Deep Work&lt;/li&gt;
  &lt;li&gt;The Apollo Guidance Computer: Architecture And Operation&lt;/li&gt;
  &lt;li&gt;Lab Girl -	Hope Jahren&lt;/li&gt;
  &lt;li&gt;Exploding the phone : the untold story of the teenagers and outlaws who hacked Ma Bell - Phil Lapsley&lt;/li&gt;
  &lt;li&gt;Sapiens: A Brief History of Humankind&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;fiction&quot;&gt;Fiction&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;The Three-Body Problem by Cixin Liu&lt;/li&gt;
  &lt;li&gt;Revenger by Alastair Reynolds&lt;/li&gt;
  &lt;li&gt;All Systems Red by Martha Wells&lt;/li&gt;
  &lt;li&gt;The Red by Linda Nagata&lt;/li&gt;
  &lt;li&gt;Red Mars by KSR&lt;/li&gt;
  &lt;li&gt;Nova by Chip Delany.&lt;/li&gt;
  &lt;li&gt;The Devil in Silver by Victor LaValle&lt;/li&gt;
  &lt;li&gt;Hyperion – Dan Simmons&lt;/li&gt;
  &lt;li&gt;The Dispossessed, by Ursula K.LeGuin&lt;/li&gt;
  &lt;li&gt;Autonomous - by Annalee Newitz&lt;/li&gt;
  &lt;li&gt;The Fifth Season (Broken Earth series) by N.K. Jemisin&lt;/li&gt;
  &lt;li&gt;Revenger by Alistair Reynold&lt;/li&gt;
  &lt;li&gt;The Forever War by Joe Haldeman&lt;/li&gt;
  &lt;li&gt;Starship Troopers by Robert Heinlein&lt;/li&gt;
  &lt;li&gt;Harry Potter and the Methods of Rationality&lt;/li&gt;
  &lt;li&gt;Library at mount Char - Scott Hawkins&lt;/li&gt;
  &lt;li&gt;Tau Zeo - Poul Anderson&lt;/li&gt;
  &lt;li&gt;Binti - Nnedi Okorafor&lt;/li&gt;
  &lt;li&gt;Worlds of Exile and Illusion: Rocannon’s World, Planet of Exile, City of Illusions&lt;/li&gt;
  &lt;li&gt;Subjective Cosmology Series by Greg Egan&lt;/li&gt;
  &lt;li&gt;Cryptonomicon by Neal Stephenson&lt;/li&gt;
  &lt;li&gt;Autonomous by Annalee Newitz&lt;/li&gt;
  &lt;li&gt;git commit murder by Michael Warren Lucas&lt;/li&gt;
&lt;/ol&gt;
</description>
				<pubDate>Mon, 01 Jan 2018 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2018/01/01/Best-Books-Of-2017/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2018/01/01/Best-Books-Of-2017/</guid>
			</item>
		
			<item>
				<title>Stuff to do with your own server</title>
				<description>&lt;p&gt;These days, we find a lot of computing devices unused - at home and at office. There are so many of them around, you can practically run all of your day-to-day web based services by yourself. All you need is a bunch of old CPUs (even one would do to get started) and a decent internet connection. It is fun and a super exhilarating experience to run and manage your own server! This becomes all the more relevant when you care about your data privacy.&lt;/p&gt;

&lt;p&gt;Here is a sample of what you can do with it and along the way I would also show you what I did with my old HCL laptop that was lying dormant for more than a couple of years. The same can be replicated with a Raspberry Pi too.&lt;/p&gt;

&lt;h3 id=&quot;run-linux&quot;&gt;Run Linux&lt;/h3&gt;

&lt;p&gt;Operating System is a purely individual choice. Personally, I’d prefer a headless debian based distro - for its ease of use and package availability. Before you start setting up, I’d strongly encourage you run a BIOS memory check and a disk check. We don’t know how these devices would perform under load and ensuring hardware health is a good option. Replace components if necessary - better than getting a new device altogether. Also consider a battery check if you run a laptop.&lt;/p&gt;

&lt;h3 id=&quot;essentials&quot;&gt;Essentials&lt;/h3&gt;

&lt;p&gt;A list of essentials (or rather what I did) that your server has to run.&lt;/p&gt;

&lt;p&gt;My laptop’s RAM got damaged last summer and I couldn’t get a compatible replacement anywhere. So, of the 4 GB RAM the OEM had sold it with, only 2 GB is functional now. There isn’t much scope to run memory-heavy applications, but the following definitely holds good. The peak average memory load comes close to 70%.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.ubuntu.com/lts/serverguide/samba-fileserver.html&quot;&gt;Samba Shares&lt;/a&gt; - to share files within devices on your network. &lt;a href=&quot;/2018/05/26/Setup-Samba-File-Server/&quot;&gt;Follow my post here to create samba share on your server&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.linuxbabe.com/cloud-storage/setup-nextcloud-server-ubuntu-16-04-apache-mariadb-php7&quot;&gt;Nextcloud/Owncloud&lt;/a&gt; - your personal Dropbox.
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04&quot;&gt;Secure your server with LetsEncrypt&lt;/a&gt;. Make sure you setup a cron to auto renew every 3 months. (&lt;strong&gt;&lt;em&gt;Details included in the blog post link.&lt;/em&gt;&lt;/strong&gt;)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.plex.tv/&quot;&gt;Plex Media server&lt;/a&gt; - your home Media Center.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;monitoring&quot;&gt;Monitoring&lt;/h3&gt;

&lt;p&gt;One thing that is an absolute necessity is a monitoring stack. When you run things yourself, remember - anything can go wrong anywhere. Tracing your errors and monitoring your device’s health is paramount. &lt;a href=&quot;https://github.com/firehol/netdata&quot;&gt;net-data&lt;/a&gt; is an excellent choice. But, if you’d like to have an option, you can consider &lt;a href=&quot;https://github.com/afaqurk/linux-dash&quot;&gt;linux-dash&lt;/a&gt; too.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/firehol/netdata/wiki/Installation&quot;&gt;Installing net-data&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Configuring &lt;a href=&quot;https://github.com/firehol/netdata/wiki/Running-behind-apache&quot;&gt;net-data via apache server&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-14-04&quot;&gt;Setting up auth with apache server&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s the monitoring dashboard for my laptop.
&lt;img src=&quot;/assets/images/own-server/hcl-monitor.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;optional-stuff&quot;&gt;Optional Stuff&lt;/h3&gt;

&lt;p&gt;Few things I’d like to have. Few of them hosted locally. And a few hosted in my remote droplet.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Syncthing - [LOCAL]&lt;/li&gt;
  &lt;li&gt;PXE Server - [LOCAL]&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;Cryptocurrency mining&lt;/del&gt; - Too expensive.&lt;/li&gt;
  &lt;li&gt;Audio FM streaming with Arduino interface - [LOCAL]&lt;/li&gt;
  &lt;li&gt;Private blog - wordpress, ghost et.al. (Jekyll may be a good option too)&lt;/li&gt;
  &lt;li&gt;Mumble Server. (Communications) Riot Server if you want better options.&lt;/li&gt;
  &lt;li&gt;Openshift Origin/Dokku server - If you’re setting up a Dev Desktop.&lt;/li&gt;
  &lt;li&gt;XMPP Server&lt;/li&gt;
  &lt;li&gt;&lt;del&gt;OpenVPN Server&lt;/del&gt; - Try AlgoVPN.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://turtlapp.com/docs/server/&quot;&gt;Turtl Notes&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Kubernetes cluster&lt;/li&gt;
  &lt;li&gt;Mastadon server - if you are really into social networking.&lt;/li&gt;
  &lt;li&gt;Self hosted git repositories - gitea or gitolite or Gitlab.&lt;/li&gt;
  &lt;li&gt;Orchestrate all of the services via Caddy Webserver.&lt;/li&gt;
  &lt;li&gt;Flickr alternatives - &lt;a href=&quot;https://www.mediagoblin.org/&quot;&gt;MediaGoblin&lt;/a&gt;, &lt;a href=&quot;https://piwigo.com/&quot;&gt;Piwigo&lt;/a&gt;, &lt;a href=&quot;https://perkeep.org/&quot;&gt;Perkeep&lt;/a&gt; etc&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;domain-dns-hosting&quot;&gt;Domain DNS hosting&lt;/h3&gt;

&lt;p&gt;You may not want to expose your media server and your private blogs to public internet. But, for pretty much anything else you will have to do it - for daily usage. Almost every router today comes with the ability to port forward.&lt;/p&gt;

&lt;p&gt;If you have a static IP address, you are all set. With port forwarding setup, you can go ahead and access your services.&lt;/p&gt;

&lt;p&gt;If you want to mask it behind a domain name, you can get a domain for cheap rates at &lt;a href=&quot;https://www.crazydomains.in/&quot;&gt;CrazyDomains.in&lt;/a&gt;. But again, that’s a personal choice.&lt;/p&gt;

&lt;h3 id=&quot;dynamic-dns-with-cloudflare&quot;&gt;Dynamic DNS with Cloudflare&lt;/h3&gt;

&lt;p&gt;If you don’t have a static IP though, you need to get a domain.&lt;/p&gt;

&lt;p&gt;To host DNS, I’d strongly suggest &lt;a href=&quot;https://www.cloudflare.com/&quot;&gt;Cloudflare&lt;/a&gt;. It is very developer friendly and provides free SSL certificates. You can use &lt;a href=&quot;https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record&quot;&gt;Cloudflare’s API to update your DNS&lt;/a&gt; periodically too.&lt;/p&gt;

&lt;p&gt;Here’s the script to do that. You may edit this to your need.
&lt;script src=&quot;https://gist.github.com/dtsdwarak/19abfd5d1ae18c4cd929d082b9d207fc.js&quot;&gt;&lt;/script&gt;&lt;/p&gt;

&lt;p&gt;Create a cron job to update it periodically. I’ve set up to do that every 3 minutes. It updates my &lt;a href=&quot;https://drive.dwarak.in/index.php/login&quot;&gt;NextCloud server&lt;/a&gt; and &lt;a href=&quot;https://hcl.dwarak.in/&quot;&gt;Laptop’s monitoring stack&lt;/a&gt; DNS. Cloudflare’s API limit is &lt;a href=&quot;https://support.cloudflare.com/hc/en-us/articles/200171456-How-many-API-calls-can-I-make-&quot;&gt;1200 calls for 5 minutes&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;more-inspiration&quot;&gt;More inspiration&lt;/h3&gt;

&lt;p&gt;If you have the power and urge to do more with your server(s), here are some inspirations.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://manor.space/&quot;&gt;manor.space&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Kickball/awesome-selfhosted&quot;&gt;A list of self-hosted things&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://lobste.rs/s/yxswhm/what_are_you_self_hosting&quot;&gt;Lobsters thread on self-hosted items&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me know what you’ve done with yours!&lt;/p&gt;
</description>
				<pubDate>Sun, 26 Feb 2017 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2017/02/26/Stuff-To-Do-With-Your-Own-Server/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2017/02/26/Stuff-To-Do-With-Your-Own-Server/</guid>
			</item>
		
			<item>
				<title>Few Book Lists To Keep Yourself Busy <s>in 2017</s> ever!</title>
				<description>&lt;p&gt;Despite some bad experiences, 2016 has been a beautiful year - for having realized that books can be a great way to have fun, learn stuff, gain exposure and grow! Over the past 12 months, I might have bookmarked close to a 100 books, but never actually got the time to finish many. Most of them picked from the lists I found on social media. Here are few of those lists that piqued my interest - in a variety of subjects. I hope to complete a few this year and I guess you’ll be equally interested in doing that too!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.geekwire.com/2016/ten-top-books-geeks-read-2017/&quot;&gt;From startups to spaceships: Ten top books for geeks to read in 2017&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.geekwire.com/2016/holiday-gift-guide-science-books/&quot;&gt;Holiday guide to science books about life, the universe and everything&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.ycombinator.com/ycs-winter-reading-list&quot;&gt;YC’s Winter Reading List&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.brainpickings.org/2015/07/21/sam-harris-reading-list/&quot;&gt;Neuroscientist Sam Harris Selects 12 Books Everyone Should Read&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.gatesnotes.com/About-Bill-Gates/Best-Books-2016&quot;&gt;Bill Gates’ Favorite Books of 2016&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://ramiro.org/vis/hn-most-linked-books-unique-users/&quot;&gt;Top 29 books mentioned in Hacker News comments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.pastemagazine.com/articles/2016/10/the-30-best-young-adult-books-of-all-time.html&quot;&gt;The 30 Best Young Adult Books of All Time&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/mozilla-internet-citizen/get-your-geek-on-with-our-summer-book-list-47d648b602e6&quot;&gt;Mozilla’s Geek Book List&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.smh.com.au/business/markets/21-books-warren-buffett-thinks-you-should-read-20161103-gshv25.html&quot;&gt;21 books Warren Buffett thinks you should read&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;update---march-17-2018&quot;&gt;Update - March 17, 2018&lt;/h3&gt;

&lt;p&gt;Over two years, I was able to take up very little in book reading. Not sure if I feel happy or sad at this moment. Nonetheless, I managed to collect more book lists. Some of them with some really great content.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://lobste.rs/s/i9s39q/best_books_you_have_read_2017&quot;&gt;Lobsters’ thread on 2017’s best books&lt;/a&gt;. If you find it tedious to go over, a compilation of the same in my blog &lt;a href=&quot;/2018/01/01/Best-Books-Of-2017/&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.theguardian.com/books/2017/dec/31/the-100-best-nonfiction-books-of-all-time-the-full-list&quot;&gt;100 best Nonfiction books of all time&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.xojane.com/newagey/30-self-help-books-that-permanently-changed-my-life&quot;&gt;30 Self-Help Books That Permanently Changed My Life&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sivers.org/book&quot;&gt;Derek Siver’s book list&lt;/a&gt; - Really recommend going over this list if you haven’t already. Accompanied by book notes, books in his list will help your mind see a new spectrum of things.&lt;/li&gt;
&lt;/ol&gt;
</description>
				<pubDate>Wed, 28 Dec 2016 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2016/12/28/Few-Book-Lists-To-Keep-Yourself-Busy-In-2017/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2016/12/28/Few-Book-Lists-To-Keep-Yourself-Busy-In-2017/</guid>
			</item>
		
			<item>
				<title>Get Push Notified For Your SSH Logins</title>
				<description>&lt;p&gt;Those of you who have/provide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; access to your instances - bare metal or hosted know how important it is to get notified of any suspicious logins into your machines. Checking &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; logs or email alerts is neither time-sensitive nor efficient.&lt;/p&gt;

&lt;p&gt;Here we’ll look into implementing a simple and zero-effort notification service for SSH logins via &lt;a href=&quot;https://www.pushbullet.com/&quot;&gt;PushBullet&lt;/a&gt;.
&lt;!--break--&gt;&lt;/p&gt;

&lt;h3 id=&quot;basics&quot;&gt;Basics&lt;/h3&gt;

&lt;p&gt;For the ones who aren’t quite familiar with PushBullet, it is meant to provide a easy way to integrate your apps and services to deliver push notifications across all your devices -  Browsers and Mobile devices via REST APIs. Though the primary intent is only that, over the years it has become much more than that - mirroring device notifications, sharing files across devices and the like.&lt;/p&gt;

&lt;h3 id=&quot;plan&quot;&gt;Plan&lt;/h3&gt;

&lt;p&gt;Our idea is simple - call the API through the shell to push notifications. There seemed like two ways to do the same. One is creating a channel - which supposedly can be subscribed by many people. Frankly, I haven’t tried to do that, yet. Looks like it is good for teams. The other is, very straightforward - creating an APP by creating an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ACCESS_TOKEN&lt;/code&gt; and subsequently using that token to send notifications.
We’ll try the simpler second option.&lt;/p&gt;

&lt;h4 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h4&gt;

&lt;p&gt;I’m assuming that you,&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; configured. If not, &lt;a href=&quot;https://www.digitalocean.com/community/tutorials/ssh-essentials-working-with-ssh-servers-clients-and-keys&quot;&gt;follow the documentation here&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Are familiar with editing shell configs (dotfiles).&lt;/li&gt;
  &lt;li&gt;Use a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*nix&lt;/code&gt; based machine.&lt;/li&gt;
  &lt;li&gt;Have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt; shell. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; is similar for the purpose of this exercise - with just variations in config files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;steps&quot;&gt;Steps&lt;/h3&gt;

&lt;h4 id=&quot;writing-the-pushbullet-function&quot;&gt;Writing the PushBullet function&lt;/h4&gt;

&lt;p&gt;First step will be to write the function to call the PushBullet API, which your shell will invoke to push the data. You want it to be ‘shell-agnostic’. So, let’s put it up in a file and source it from the shell config. Let’s assume the file’s name is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell.rc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The contents of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell.rc&lt;/code&gt; would then be:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pushb&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
curl &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--header&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Access-Token: &apos;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PUSH_BULLET_ACCESS_TOKEN&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
     &lt;span class=&quot;nt&quot;&gt;--header&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Content-Type: application/json&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
     &lt;span class=&quot;nt&quot;&gt;--data-binary&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{&quot;body&quot;:&quot;&apos;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$2&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&quot;,&quot;title&quot;:&quot;&apos;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&quot;,&quot;type&quot;:&quot;note&quot;}&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
     &lt;span class=&quot;nt&quot;&gt;--request&lt;/span&gt; POST&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
     https://api.pushbullet.com/v2/pushes &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Three things here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$PUSH_BULLET_ACCESS_TOKEN&lt;/code&gt; is your PushBullet API Access Token.
You can &lt;a href=&quot;https://www.pushbullet.com/#settings/account&quot;&gt;get one for yourself here&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$1&lt;/code&gt; is your push alert title.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$2&lt;/code&gt; is the body of your push notification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s an example.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/ssh-push-notifications/ssh-alert.png&quot; alt=&quot;ssh-alert&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;generating-the-ssh-connection-metadata&quot;&gt;Generating the SSH connection metadata&lt;/h4&gt;

&lt;p&gt;Now that we have the function to do what we want, how do we generate the data for us to pass into the function? For clarity, I’m talking about the finding the time, IP address, port and all the other details you may want.&lt;/p&gt;

&lt;p&gt;Here’s the snippet to do the same.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;SSH_PORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$SSH_CONNECTION&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $2}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;SSH_IP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$SSH_CONNECTION&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;SSH_TIME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TZ&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Asia/Kolkata&apos;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;LOGIN_MESSAGE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;New SSH login from &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;SSH_IP&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; via port &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;SSH_PORT&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; at &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;SSH_TIME&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
pushb &lt;span class=&quot;s2&quot;&gt;&quot;SSH Login Alert&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$LOGIN_MESSAGE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$SSH_CONNECTION&lt;/code&gt; gives all the data you need to gather about the current &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; session. We simply &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awk&lt;/code&gt; to get the data we want. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Asia/Kolkata&lt;/code&gt; has been used to get the system time in IST. You can choose whatever is applicable for your use-case.&lt;/p&gt;

&lt;p&gt;Now that you have the snippet, where would you put this? This again would have to be shell-agnostic. So, let’s put that in a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;login.rc&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;configuring-your-shell&quot;&gt;Configuring your shell&lt;/h4&gt;

&lt;p&gt;That’s it. We have the function and the script to pass data to it.&lt;/p&gt;

&lt;p&gt;Just to be on the same page, we have two files with us:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell.rc&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;login.rc&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next step would be to source these files in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt; shell config. Pay attention here, since we’ll briefly diverge into shell basics. There are two types of shells - Login shell and a Non-login shell. I myself don’t know much more than the fact that - when you typically &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; into your machine with an account, you get into &lt;strong&gt;login&lt;/strong&gt; shell. But, you can &lt;strong&gt;choose to use a non-login shell&lt;/strong&gt; when you have physical access to the same machine. Let’s not go any further than this. I’d encourage you to research on shells - well, its a note for myself to do that. So, that’s that and going back to our topic, when you &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; into your machine, you get into a login shell.&lt;/p&gt;

&lt;p&gt;Point is to invoke the script everytime &lt;strong&gt;only when you get into a login shell and not otherwise&lt;/strong&gt;. How do you do that? With regard to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt;, only login shells invoke the scripts in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zlogin&lt;/code&gt;. And every shell, login or non-login look for custom configs in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; file. And the order it happens is this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zlogin&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For more information on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zsh&lt;/code&gt; config file startup order, &lt;a href=&quot;http://zsh.sourceforge.net/Intro/intro_3.html&quot;&gt;you read here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, source your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell.rc&lt;/code&gt; file in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; file&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; ~/dotfiles/shell.rc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;login.rc&lt;/code&gt; file in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zlogin&lt;/code&gt; file.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; ~/dotfiles/login.rc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That is, assuming you have both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell.rc&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;login.rc&lt;/code&gt; within &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/dotfiles/&lt;/code&gt; folder. If you’re planning to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt; shell, you need to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bashrc&lt;/code&gt; for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.zshrc&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bash_profile&lt;/code&gt; for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zlogin&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And kaboom! Now you have a working PushBullet notification system for your SSH logins.&lt;/p&gt;

&lt;h3 id=&quot;my-dotfiles&quot;&gt;My Dotfiles&lt;/h3&gt;

&lt;p&gt;For a working copy of the same and much more features, clone my &lt;a href=&quot;https://github.com/dtsdwarak/dotfiles&quot;&gt;dotfiles&lt;/a&gt; repo. PRs most welcome! &amp;lt;3&lt;/p&gt;
</description>
				<pubDate>Thu, 04 Aug 2016 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2016/08/04/Get-Push-Notified-For-Your-SSH-Logins/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2016/08/04/Get-Push-Notified-For-Your-SSH-Logins/</guid>
			</item>
		
			<item>
				<title>The Escapade With Virtual Machines</title>
				<description>&lt;p&gt;Virtualization is a very fancy jargon to use. It is more like “Big Data” in that, not many know what it really means, how and where to actually use it, but nevertheless try their best to keep a frightfully serious face and throw shit at us for hours. My definition of virtualization didn’t go beyond “installing Virtualbox” for more than a good 6-7 years until a couple of weeks back. And things did seem pretty simple the way I saw it - “Running an operating system inside another operating system”. It is that simple, yes, except its not with what’s under the hood. &lt;br /&gt;
&lt;!--break--&gt;&lt;/p&gt;

&lt;p&gt;Oh! So, is that all the fuss is about? OS inside another OS? No. That is so 2000s. There’s so much more to VMs than just trying to play with Ubuntu inside a Windows machine. VMs are a way by which…Hang on. On a second thought, I think it’d only make sense for us to start from the get go – from where it started.&lt;/p&gt;

&lt;h3 id=&quot;what-is-it&quot;&gt;What is it?&lt;/h3&gt;

&lt;p&gt;I guess by now you have an idea, perhaps vaguely atleast, about virtualization and what its trying to achieve. To elaborate a little more on that, virtualization is to provide a virtual hardware/compute architecture (that doesn’t exist as a separate complete unit), to the layer of software running on top of it.&lt;/p&gt;

&lt;p&gt;Well, that is exactly what emulation does right? If not, then what is emulation and what is virtualization? How do these two differ?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/virtualization/confusion.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;emulation-vs-virtualization&quot;&gt;Emulation vs Virtualization&lt;/h3&gt;

&lt;p&gt;Emulation is about trying to make a particular system mimic or imitate another system. Take for example the use of Android Studio to write applications for your phone’s ARM architecture. You test your app with Android Studio and then push it to your phone. The underlying hardware architecture in your PC though is x86. What we are doing here is &lt;strong&gt;emulation&lt;/strong&gt;. Converting instructions meant for a particular architecture (ARM) to a compatible instruction set of the underlying architecture(x86) over which the software is run.&lt;/p&gt;

&lt;p&gt;Take another example. You might’ve mounted your ISO or any other disk image files you have as a disk drive in your PC. (viz., Daemon Tools). Do we actually have that disk drive in our hardware stack? No. So, what we are doing here is, taking the image drive’s read/write operations performed by the software using it and converting it into the corresponding file read/write instructions on ISO image’s contents.&lt;/p&gt;

&lt;p&gt;In both the cases we just saw, we were trying to show the operating system/software that we have a kind of hardware when we actually did not have one. So, emulation is helping us mimic an architecture different from the one that is down below in the actual hardware stack. This is possible by converting the instructions to be executed into the corresponding instructions for the hardware present. Thus, execution of “original instructions” do not take place in actual hardware and thus you cannot get native performance with emulation.&lt;/p&gt;

&lt;h5 id=&quot;simulation&quot;&gt;Simulation?!&lt;/h5&gt;

&lt;p&gt;Now please don’t confuse this with simulation. Simulation is more about making something appear more close to the one its replicating but cannot be used as a substitute to the original. For e.g., with MATLAB and Simulink you can simulate the behavior of aerospace components but you can never replace them for actual components. Emulation is about making something work like another, trying to replicate the original’s behavior, and can be used as a substitute to the original. e.g. Android emulator etc which can actually be used as a replacement to an actual phone. &lt;a href=&quot;http://stackoverflow.com/a/9579323&quot; title=&quot;Simulation vs Emulation&quot;&gt;Read more here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Take a moment’s breath. You are under a deluge of information. Let things sink in.&lt;/p&gt;

&lt;p&gt;Right, cool. So what is virtualization then? Virtualization is more about logically separating or consolidating the existing hardware into separate environments by &lt;a href=&quot;http://stackoverflow.com/a/6045177&quot; title=&quot;Thanks to this StackOverFlow answer&quot;&gt;creating virtual barriers&lt;/a&gt;, in turn giving us a view of (generally smaller and) complete machines. The prime difference between virtualization and emulation is that, the underlying architecture in virtualization is mostly the same as the one virtualized. These separate virtual environments are separated by virtual barriers, but they run in the same physical environment.&lt;/p&gt;

&lt;p&gt;It is a misconception that virtualization is always about giving smaller device environments than the original host environment. In processor virtualization, that may usually be the case. Yes. But, in storage virtualization though, several multiple physical devices are &lt;a href=&quot;http://www.computerworld.com/article/2551154/virtualization/emulation-or-virtualization-.html&quot;&gt;regarded as a single logical&lt;/a&gt; unit by the server.&lt;/p&gt;

&lt;p&gt;And since the execution of instructions take place in actual hardware, we can expect a near-native performance. So, performance wise, virtualization is better than emulation.&lt;/p&gt;

&lt;h3 id=&quot;where-and-how-are-these-things-used&quot;&gt;Where and how are these things used?&lt;/h3&gt;

&lt;p&gt;So now that you understand what emulation and virtualization is, in most cases, you’ll see both these concepts play side-by-side.&lt;/p&gt;

&lt;p&gt;Where emulation is useful:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;When you want to replicate a hardware you don’t have.&lt;/li&gt;
  &lt;li&gt;Running a software meant for another hardware.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where virtualization is used:&lt;/p&gt;

&lt;p&gt;There are a lot of uses of implementing server virtualization in your architecture when operating at an enterprise-scale. They go on and on. I don’t want to put ‘em all up here. You can read more about the &lt;a href=&quot;http://www.infoworld.com/article/2621446/server-virtualization/server-virtualization-top-10-benefits-of-server-virtualization.html&quot;&gt;benefits of virtualization&lt;/a&gt;. In short, we get complete utilization of existing hardware resources.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This is way too much data for a mortal to grasp in one go. Read once or twice, if you think it’ll help.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;some-terminology&quot;&gt;Some Terminology&lt;/h3&gt;

&lt;p&gt;Now that we know the benefits of virtualization, before we get to know how they get implemented in actual, it is essential you become familiar with some terminology.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Host - The machine on top of which we perform virtualization.&lt;/li&gt;
  &lt;li&gt;Guest - The one that is virtualized.&lt;/li&gt;
  &lt;li&gt;Hypervisor - Also called the Virtual Machine Manager, it is the middleware that sits between the underlying hardware(and software) layer which manages the virtual machine instances.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’ve used &lt;a href=&quot;https://www.virtualbox.org/&quot;&gt;Virtualbox&lt;/a&gt; or &lt;a href=&quot;http://www.vmware.com/in/products/vsphere&quot;&gt;VMWare vSphere&lt;/a&gt; before, they are examples of hypervisor.&lt;/p&gt;

&lt;p&gt;There are two kinds of hypervisors available – Type 1 and Type 2.&lt;/p&gt;

&lt;p&gt;Type 1 hypervisors are the kind that act directly on top of the host hardware. Type 2 act on top of host hardware + host operating system. Thus, the examples we looked before are Type 2 hypervisors. &lt;a href=&quot;http://www.xenproject.org/&quot;&gt;Xen&lt;/a&gt; is an example of Type 1 hypervisor. Pictures below will put things in perspective.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/virtualization/type1.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;img-caption&quot;&gt;Type 1 Hypervisor&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/virtualization/type2.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;img-caption&quot;&gt;Type 2 Hypervisor&lt;/div&gt;&lt;/p&gt;

&lt;h3 id=&quot;open-source-virtualization&quot;&gt;Open Source Virtualization&lt;/h3&gt;

&lt;p&gt;Assuming you are interested in virtualization, few of the best virtualization providers in industry are open source and the best options available for you are either kvm-qemu or Xen.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.linux-kvm.org/page/Main_Page&quot;&gt;KVM&lt;/a&gt; is called the kernel virtual machine and is a module that comes built into your linux kernel. &lt;a href=&quot;http://wiki.qemu.org/Main_Page&quot;&gt;Qemu&lt;/a&gt;, short for Quick Emulator is another virtualization/emulation provider. They are examples of Type 2 hypervisors. KVM is best to go with when you are trying to virtualize the same architecture as the host. Qemu, when you want to run a different architecture than the one you have as a host. When you want to use KVM, you’ll still need Qemu to emulate your machine’s hardware.&lt;/p&gt;

&lt;p&gt;I’ve not worked with Xen but that is the most dominant virtualization provider in the current time.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;Virtualization is a really exciting domain and has enough scope for a foreseeable future. This post was more like an introduction in virtualization. More practical stuff later! If you happen to find any mistakes, please let me know in the comments section below.&lt;/p&gt;
</description>
				<pubDate>Wed, 04 Nov 2015 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2015/11/04/The-Escapade-With-Virtual-Machines/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2015/11/04/The-Escapade-With-Virtual-Machines/</guid>
			</item>
		
			<item>
				<title>Notes from CPP4C Programmers Course - Part I</title>
				<description>&lt;p&gt;Not until a few months ago, I had great confidence in my C++ programming skills. Back in school days, I saw no reason to use a compiler to check for errors and I’d pride myself for that. Years went by and one day, long after I had distanced myself from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#include&lt;/code&gt;, I was trying to solve a simple problem. And I sucked. Sucked bigtime. Sucked so badly, I didn’t even know you could declare arrays with variables for size. I was a little taken aback.
&lt;!--break--&gt;&lt;/p&gt;

&lt;p&gt;On top of it was the realization that you could have functions in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;structures&lt;/code&gt;. Shock in my face didn’t have words in any language known to man.&lt;/p&gt;

&lt;p&gt;My logical abilities had gotten pretty bad. I should try to improve them. But, being bad in C++ had seemed the most worrisome problem. And I set out to look for options to get back my ways with language. That was when I stumbled upon Ira Pohl’s course in Coursera - &lt;a href=&quot;https://www.coursera.org/course/cplusplus4c&quot;&gt;CPP for C Programmers&lt;/a&gt;. Though I knew some C++ and I never really started out with C as against the intended audience, this course as I see now is more of a ‘What-CPP-Is-Really-Capable-Of’ kind that helps people who come from any background, whatsoever.&lt;/p&gt;

&lt;p&gt;Below are my notes, that are not “complete” by any means. But, I point out certain salient features of the language that most of us usually tend to miss. And since this course addresses too many things at once, I am thinking of doing this part by part.&lt;/p&gt;

&lt;p&gt;The post is fairly long and I suggest you slap your cheeks to make sure you really get your focus back. Come, let’s jump right in!&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#typecasting-in-c&quot;&gt;TypeCasting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#staticasserts-in-c&quot;&gt;Static Asserts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;typecasting-in-c&quot;&gt;TypeCasting in C++&lt;/h3&gt;

&lt;p&gt;For the ones who come with a classic C background, your idea of typcasting may have only been like this.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Apart from the &lt;em&gt;c-like&lt;/em&gt; syntax as seen above, there is another &lt;em&gt;functional&lt;/em&gt; typecasting that goes like this.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There is not much difference between either methods. It is totally up to the user to choose his/her preferred way although many would &lt;a href=&quot;http://stackoverflow.com/a/3487099&quot;&gt;prefer to use the latter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sure, it works if you know what you are doing. But the methods above are so powerful that you can typecast literally any type to another type. Consider this example.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;//wrong_type_casting.cpp&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This would perfectly compile to an executable. Only that the output here may be some junk or in somecases, may create some runtime error.&lt;/p&gt;

&lt;p&gt;The problem again is the kind of typecasting we perform. C++ allows for more safer methods to implement the same.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dynamic_cast&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reinterpret_cast&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;const_cast&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The syntax for each of the casts is&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;type1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;variable&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anytypeof_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;variable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;reinterpret_cast&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reinterpret_cast&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The most dumbass typecast ever. It doesn’t check which is pointing to what. You could even typecast an integer pointer to a class pointer that you have defined. It is absolutely dangerous at all levels and its highly recommended that you avoid it.&lt;/p&gt;

&lt;p&gt;For example, the same example above can be achieved via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reinterpret_cast&lt;/code&gt; as&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;reinterpret_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;static_cast&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;Now, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; is a little better than the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reinterpret_cast&lt;/code&gt; in that, it checks during compile time to see if the values in the LHS and the RHS both match to the same value. The same example above would have been impossible with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To really understand what and what is not possible with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;, let’s start with something simple.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.34&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//int b=a;&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//float b=a;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The above code would be possible with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;. In general, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; allows for conversions that can happen implicitly.&lt;/p&gt;

&lt;p&gt;Now consider the code below.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;2.34&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We have changed nothing except that we declare the variables dynamically. The above code would compile and execute. But the output would not be what we expect. Implementing the same with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; would not let us compile the code at all.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;2.34&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This code above does not get compiled at all, thus throwing an error.&lt;/p&gt;

&lt;p&gt;From what we observe, the problem is with pointer conversion. One type of pointer cannot be converted to another type. But, don’t bury that thought deep down. Let’s explore a little more before we jump into making any conclusion.&lt;/p&gt;

&lt;p&gt;Again, consider the following code.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Though totally senseless, this would compile perfectly in C++. Let’s attempt the same with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This code throws an error.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;static_cast.cpp:14:26: error: invalid static_cast from type ‘A*’ to type ‘B*’
  B* b = static_cast&amp;lt;B*&amp;gt;(a);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let’s change it a bit making &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;B&lt;/code&gt; a derivative of class &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It works!&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Can you see that we are trying to typecast a baseclass pointer into a derived class pointer?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But, hang on! Let us try to do just the opposite : &lt;strong&gt;Typecast a derived class pointer to a base class&lt;/strong&gt;.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Works again!&lt;/p&gt;

&lt;p&gt;What it means is that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; for pointers works only if the destination and the source pointer types have a subtype relation to one another - be it fundamental data types like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int, float, double&lt;/code&gt; etc or user defined data types.&lt;/p&gt;

&lt;p&gt;Thus, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; can perform both pointer upcasts (&lt;em&gt;pointer-to-base from pointer-to-derived&lt;/em&gt;) and downcasts (&lt;em&gt;pointer-to-derived from pointer-to-base&lt;/em&gt;).&lt;/p&gt;

&lt;h4 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;The conclusion we derive with regard to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; is that:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Non pointer typecast&lt;/strong&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; allows for any kind of implicit conversion.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Remember&lt;/strong&gt; - For user defined classes, the source and destination datatypes must have a relationship to be able to perform an implicit conversion.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Ponter typecasts&lt;/strong&gt;: The source and destination pointers should have a relationship.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;problem-with-static_cast&quot;&gt;Problem with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;Although this seems better than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reinterpret_cast&lt;/code&gt;, the problem with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt; is that it does not check if the object being converted is a “complete” object of the destination type. It is &lt;a href=&quot;http://www.cplusplus.com/doc/tutorial/typecasting/#static_cast&quot; title=&quot;Reference from CPlusPlus.com&quot;&gt;solely the responsibility of the programmer&lt;/a&gt; to make sure that the conversion is safe.&lt;/p&gt;

&lt;p&gt;Consider the code below.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This code would compile OK. But the output is definitely not &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.&amp;lt;something&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;How do we handle such problems? There comes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dynamic_cast&lt;/code&gt; into picture.&lt;/p&gt;

&lt;h3 id=&quot;dynamic_cast&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dynamic_cast&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;Now, before we get to the complex parts of this typecasting technique, let us analyze this from the very basics.&lt;/p&gt;

&lt;p&gt;Look at the code below.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.78&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;dynamic_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.78&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;dynamic_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Both of the conversions above would be impossible to do with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dynamic_cast&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, over to pointer type experiments.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;virtual&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// We are making the class A polymorphic.&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Base pointer for Base object&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Base pointer for Derived object&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;dynamic_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//Pointer downcast&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Failed for Base object to Derived pointer&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;dynamic_cast&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//Pointer downcast&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Failed for Derived object to Derived pointer&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Observe the output below.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ g++ dynamic_cast.cpp
$ ./a.out
Failed for Base object to Derived pointer
$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;conclusion-1&quot;&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;The thing is here is that, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dynamic_cast&lt;/code&gt; compiles even if it is not able to give us the result we want. But, it fails during runtime –&amp;gt; &lt;strong&gt;More safer&lt;/strong&gt; than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_cast&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And it allows for pointer downcast of polymorphic classes (&lt;em&gt;Base class pointer to Derived class pointer&lt;/em&gt;) &lt;strong&gt;only if&lt;/strong&gt; the pointed object is a valid object of the target type.&lt;/p&gt;

&lt;h3 id=&quot;static_asserts-in-c&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_asserts&lt;/code&gt; in C++&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_assert&lt;/code&gt; is used to declare conditions(assertions) without which program compilation simply won’t happen. The usage of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_assert&lt;/code&gt; may not be glaringly obvious at the first glance.&lt;/p&gt;

&lt;p&gt;But, we’ll try to find out what its for.&lt;/p&gt;

&lt;p&gt;The syntax of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_assert&lt;/code&gt; is,&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;static_assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;constant_expression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;error_message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let’s take up a dumb example for starters.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;static_assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Value has to be greater than 10&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The output of the program above will be,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ g++ --std=c++11 static_assert.cpp &amp;amp;&amp;amp; ./a.out
static_assert.cpp: In function ‘int main()’:
static_assert.cpp:6:2: error: static assertion failed: Value has to be greater than 10
  static_assert(a&amp;gt;10,&quot;Value has to be greater than 10&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The same can be used within a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;class&lt;/code&gt; definition as well.&lt;/p&gt;

&lt;p&gt;So, as we can see, we can give custom assert conditions for verification at compile time. But, what good is it if we can only check for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;const&lt;/code&gt; expressions? When and how do we actually put this to good use?&lt;/p&gt;

&lt;h4 id=&quot;use-case-1-to-check-your-runtime-environment&quot;&gt;Use Case 1: To check your runtime environment&lt;/h4&gt;

&lt;p&gt;Imagine you have built a C++ codebase that should work only when &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int&lt;/code&gt; values take up 4 bytes. You can setup an assertion as below.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;# include &amp;lt;iostream&amp;gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;static_assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;sizeof&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Integer size != 4 bytes&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;use-case-2-to-check-up-datatypes-when-you-work-with-templates&quot;&gt;Use Case 2: To check up datatypes when you work with templates&lt;/h4&gt;

&lt;p&gt;Imagine that for some reason, you only want to print integer values. The assertion for same can be provided like this.&lt;/p&gt;

&lt;div class=&quot;language-cpp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;type_traits&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;array&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;int_display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;static_assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;is_integral&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Not an integer value&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;2.33&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;int_display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;int_display&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here, the value is checked with constructs provided by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;type_traits&lt;/code&gt; header. The output of this example will again be,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ g++ -std=c++11 template_static_assert.cpp
template_static_assert.cpp: In instantiation of ‘void int_display(T) [with T = float]’:
template_static_assert.cpp:15:15:   required from here
template_static_assert.cpp:8:2: error: static assertion failed: Not an integer value
  static_assert(is_integral&amp;lt;T&amp;gt;::value,&quot;Not an integer value&quot;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;These are two use cases that I could think of for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;static_asserts&lt;/code&gt;.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;There are many more awesome stuff in the course. But more on that, next time! Let me know if something’s not what it should be in the comments section below.&lt;/p&gt;
</description>
				<pubDate>Mon, 24 Aug 2015 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2015/08/24/Notes-from-CPP4C-Programmers-Course-Part-I/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2015/08/24/Notes-from-CPP4C-Programmers-Course-Part-I/</guid>
			</item>
		
			<item>
				<title>Best Tech Podcasts On Web</title>
				<description>&lt;p&gt;Podcasts have invariably started to become a part of our daily diet for news and information. And filtering out on what to listen can become quite a task if the options you have become way too many, which is very typical today. Below are the list of few podcasts that help you get the most of what is out there.
&lt;!--break--&gt;&lt;/p&gt;

&lt;h3 id=&quot;bad-voltage&quot;&gt;&lt;a href=&quot;http://www.badvoltage.org/&quot;&gt;Bad Voltage&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/bad-voltage.jpg&quot; alt=&quot;badvoltage&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Excellent choice if you are into open source. I’ve been following &lt;a href=&quot;http://lunduke.com/&quot;&gt;Bryan Lunduke&lt;/a&gt; since the days when he was a part of &lt;a href=&quot;#linux-action-showhttpwwwjupiterbroadcastingcomtaglinux-action-show&quot;&gt;Linux Action Show&lt;/a&gt;. And it was only for him that I did follow this podcast initially. And trust me, its amazing!&lt;/p&gt;

&lt;h3 id=&quot;changelog&quot;&gt;&lt;a href=&quot;https://changelog.com/&quot;&gt;Changelog&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/changelog.png&quot; alt=&quot;changelog&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Changelog is again for fanatics of Open Source. It brings people from a variety of popular OSS projects for interview on each of its episode. Don’t miss out on the weekly newsletter as well.&lt;/p&gt;

&lt;h3 id=&quot;linux-action-show&quot;&gt;&lt;del&gt;&lt;a href=&quot;http://www.jupiterbroadcasting.com/tag/linux-action-show/&quot;&gt;Linux Action Show&lt;/a&gt;&lt;/del&gt;&lt;/h3&gt;

&lt;p&gt;&lt;del&gt;The BEST podcast that caters to people who belong to any stratum of technical know-how. PERIOD. &lt;a href=&quot;https://twitter.com/chrislas&quot;&gt;Chris&lt;/a&gt; is a terrific person and the way he carries the energy will just suffice to keep you engrossed throughout. I do miss &lt;a href=&quot;http://www.matthartley.com/&quot;&gt;Matt&lt;/a&gt; now that he’s left. But, anyway this is one show I’ve been following closely ever since I’ve known a thing or two about podcasts. You may also want to check out some of the other podcasts with &lt;a href=&quot;http://www.jupiterbroadcasting.com/&quot;&gt;Jupiter Broadcasting&lt;/a&gt; and &lt;a href=&quot;https://twit.tv/&quot;&gt;TWIT&lt;/a&gt;.&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The show is off air.&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;hacker-public-radio&quot;&gt;&lt;a href=&quot;http://hackerpublicradio.org/&quot;&gt;Hacker Public Radio&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/hpr.png&quot; alt=&quot;Linux Action Show&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Don’t go by the name, the content is primarily entry-level. Most of the time, it’ll talk about something in Linux, some best practices or an interview.&lt;/p&gt;

&lt;h3 id=&quot;hak5&quot;&gt;&lt;a href=&quot;http://hak5.org/&quot;&gt;Hak5&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/hak5.png&quot; alt=&quot;Hak5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This podcast is totally geeky inside-out and may not arouse interest with new kids on the block. But, its seriously good and I’d suggest anybody watch it just to catch up with what is what.&lt;/p&gt;

&lt;h3 id=&quot;turing-incomplete&quot;&gt;&lt;del&gt;&lt;a href=&quot;http://turing.cool/&quot;&gt;Turing Incomplete&lt;/a&gt;&lt;/del&gt;&lt;/h3&gt;

&lt;p&gt;&lt;del&gt;I’ve just started following this podcast. So far so good. But, I cannot comment on that, just yet.&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The show is off air too.&lt;/strong&gt;&lt;/p&gt;

&lt;h1 id=&quot;update&quot;&gt;UPDATE:&lt;/h1&gt;

&lt;p&gt;Here’s a &lt;a href=&quot;https://gpodder.net/user/dtsdwarak/subscriptions&quot;&gt;list of all the podcasts&lt;/a&gt; I listen to, on a regular basis.&lt;/p&gt;

&lt;p&gt;And &lt;a href=&quot;#turing-incompletehttpturingcool&quot;&gt;Turing InComplete&lt;/a&gt; has been an amazing podcast. Though not frequent, it has been very informative.&lt;/p&gt;

&lt;h3 id=&quot;software-engineering-daily&quot;&gt;&lt;a href=&quot;http://softwareengineeringdaily.com/&quot;&gt;Software Engineering Daily&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;A daily audio podcast where people from a range of domains are interviewed. A1 stuff for all the curious minds.&lt;/p&gt;

&lt;h3 id=&quot;new-shows&quot;&gt;New shows&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://signalsandthreads.com/&quot;&gt;Signals and Threads&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://oxide.computer/podcasts&quot;&gt;On the Metal&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(Referred from Linode’s Blog post - &lt;a href=&quot;https://blog.linode.com/2019/07/11/our-favorite-content-channels-for-developers/&quot;&gt;Our Favorite Content Channels for Developers&lt;/a&gt;)&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/user/schafer5/videos&quot;&gt;Corey Schafer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/user/sentdex/videos&quot;&gt;sentdex&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCrv269YwJzuZL3dH5PCgxUw/featured&quot;&gt;CodeParade&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCO1cgjhGzsSYb1rsB4bFe4Q/featured&quot;&gt;Fun Fun Function&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;More podcasts available in the blog post link above.&lt;/p&gt;
</description>
				<pubDate>Mon, 13 Jul 2015 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2015/07/13/Best-Podcasts-On-Web/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2015/07/13/Best-Podcasts-On-Web/</guid>
			</item>
		
			<item>
				<title>Open Weekends - A Weekend well spent</title>
				<description>&lt;p&gt;You know what? This post seriously deserves a better title. I know it sounds quirky, but I couldn’t manage to jog my mind up to bring out a better one. Well, anyway, going by what it says, I’ll have to agree that Open Weekends was indeed a great thing that happened in the recent times for me, Mozilla and of course, for most other people here in Chennai. &lt;!--break--&gt; Frankly, a couple of months back everything was just a thought. Well, hey, no. Not even a thought. An ‘Ambition’ may be? Hmmm… Yeah, you could say that. So, there it is, ambition – to do something for the city, that’s known to have a great geek culture.&lt;/p&gt;

&lt;p&gt;So, how did this happen? Before we begin talking that, let me tell you, we’re not doing this the usual way – this guy came, the other one spoke that, he clapped, she thanked, yadda yadda yadda… – Dude! Everyone knows what happened. It’s there in the agenda. What really matters and should matter to each one of us is the reason why everything happened the way it did. For what its worth, I believe in this – When you tell others something, its really important for you to communicate what you did, why you did and how you did. People simply call it – the ‘takeaway factor’ –What you take or learn out of something you did or see happen, that inspires others to do things with a better vision and motives. It becomes particularly significant in cases like our communities where most of the learning comes from within ourselves.&lt;/p&gt;

&lt;p&gt;I really have this habit of drifting away once I start talking :D So yeah. It was February. I had just returned after attending GNUnify in Pune. From the very beginning I was thrilled about the very idea of different communities coming together to do something. After all, community collaboration and sharing is what that defines the concept of open source and sharing, right? The moment I was invited to attend the conference, believe me, Pune didn’t excite me. Rather what piqued my interest was my intention to see how these conferences happen. I mean like, I wanted to see if meetups like these did really have the potential to bring out successful partnerships among the various communities in India.&lt;/p&gt;

&lt;p&gt;And trust me, learning took up a whole new curve those two days. Sharing of practices, ideas and the methods –that’s what happened there. And me being a Chennai fanboy, each time when something was told or discussed about Pune being a great city and the opportunity it provided, I would think, “Why not do this at Chennai? Why not here?” - Just like how your parent would think when your neighbor’s son scored better than you in exams. :P I didn’t know what the problems would be in organizing such an event here. Honestly, I couldn’t think of any reason otherwise and just wanted to do it sometime soon and thought, may be I’d wait for the right moment to host one.&lt;/p&gt;

&lt;p&gt;So well, I had returned from Pune and was busy with college and my other priorities back home ;) And there comes Karthik and Naresh into the story –The guys who bugged me to host a MozCafe here. They had like, been telling me to organize a get-together for about a month and I failed to do each time – had too many things in mind. Finally, somehow, like about a month after GNUnify, we managed to host an informal meetup of sorts here in Chennai. We didn’t have much time to plan ahead on things but wanted to do with something cheap but, out of the box –Marina Beach! Yes… Myself and few other fellows here met at the city’s own paradise – the Marina beach. Meeting with us was Wikimedia India’s executive council member, Bala Jeyaraman or Bala anna as how we’d call him. [fondly, of course, as people used to write ;) ]&lt;/p&gt;

&lt;p&gt;Among the many topics we spoke that day, this “A GNUnify in Chennai” was one. He was so supportive of the idea. And was okay in doing one right on! “Why not do this sometime in May?” he said, we have ample time to plan and execute things. Everyone agreed. And thus became Open Weekends a reality!&lt;/p&gt;

&lt;p&gt;Organizing an event like this is so much fun. You get to say hi, talk and shake hands with many people you might not even have heard about earlier. You develop your circle far and beyond. Personally, as an organizer, this is what I’d always look out for, whenever I do or get myself involved in something. So, as soon as it was decided that Open Weekends was happening, I wrote a one page agenda – in English – with a language that’s plain and simple – and no mumbo jumbos – putting forth why I thought this had to be done in Chennai. I had sent it to my guys here and they agreed too.&lt;/p&gt;

&lt;p&gt;Next was promotions. We had no ideas on what to do, how to do and the rest. We just wanted to see if there were any takers or people who were interested to participate in this mission. We extensively used Facebook, the Linux user groups’, Wikipedia’s and Mozilla India’s lists. Most of them who came forward to reply, were very appreciative of what we had planned to do. And some people had doubts and once you spoke to them, they were okay as well. That’s how Atul Jha from the Open Stack community and Shrinivasan from the Chennai wing of Indian Linux Users Group had come forward to participate in Open Weekends. I really thank them for their support towards organizing this event.&lt;/p&gt;

&lt;p&gt;For about a month and a half, it was all like this. Talking to people, writing emails, posting updates, tweeting – just the online stuff. And then once we had the list of people interested in participating – a tentative list – from which we had called for the ones who wanted to speak at the event. The whole idea of doing this event was providing opportunity for everyone, not just the guys we know who could speak well. Well, mind you! You’re making a calculative risk here – of putting the participants who come to the event to sleep. :D But you know! At times, its worth taking. You see new talent emerge. So, I made that choice – calling for people who wanted to speak at the event. And that’s how we had roughly about five speakers that also included our very own Soumya Deb – Well, I needed at least one guy as a backup who could wake the people up in case everyone had slept, right? :P&lt;/p&gt;

&lt;p&gt;So, the plan was ‘just talking’ the first day and hackathon the second day. Yeah. We also had a hackathon. We didn’t want to restrict the guys on just a thing or two. Mainly because, we didn’t or won’t know what the participants might be knowing about or be interested in. So, we generalized it as ‘Mozilla hackathon’ – Do whatever you feel like doing – Build Firefox addons, hack Thunderbird, make apps for Firefox OS or just whatever you feel like. Along with it was the Mediawiki hackathon handled by YuviPanda – thus giving all a wide variety of choice to choose from. And I was so confident that every guy or girl who comes there will atleast know any one of the above. Acquiring venue was no big deal as well. Thanks to ThoughtWorks and Railsfactory for their timely help. Original plan was to host it at ThoughtWorks but unfortunately, the venue had to be shifted to Railsfactory for a few reasons.&lt;/p&gt;

&lt;p&gt;So, rest is all the same. Event had proceeded exactly as expected. One thing, I was not very sure about was the participant count. I thought may be we’d have about 20 to 25. But, never in my wildest of wildest dreams, did I think of a count like 40. Sometimes, it brought me both shock and surprise to find that even old Wikipedia contributors like Sengai Podhuvan had turned up for the event.&lt;/p&gt;

&lt;p&gt;Anyway, that was my take on Open Weekends. The list goes on and on and on! So, let me just put , “thanks to all who made it happen!”. I knew this event would be fun – meeting friends, talking tech, learning new things – and everything that we wanted to do couldn’t have happened in a better way. And this is definitely a great start for Chennai :)&lt;/p&gt;

</description>
				<pubDate>Thu, 30 May 2013 00:00:00 +0000</pubDate>
				<link>https://blog.dwarak.in/2013/05/30/Open-Weekends-A-Weekend-Well-Spent/</link>
				<guid isPermaLink="true">https://blog.dwarak.in/2013/05/30/Open-Weekends-A-Weekend-Well-Spent/</guid>
			</item>
		
	</channel>
</rss>
