-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.xml
More file actions
127 lines (127 loc) · 21.8 KB
/
index.xml
File metadata and controls
127 lines (127 loc) · 21.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>The Janus List</title><link>https://sinhak.dev/</link><description>Recent content on The Janus List</description><generator>Hugo</generator><language>en-us</language><copyright>© Kushagra Sinha</copyright><lastBuildDate>Sat, 10 Oct 2020 19:03:13 +0200</lastBuildDate><atom:link href="https://sinhak.dev/index.xml" rel="self" type="application/rss+xml"/><item><title>The Reliable Engineer</title><link>https://sinhak.dev/posts/the-reliable-engineer/</link><pubDate>Sat, 10 Oct 2020 19:03:13 +0200</pubDate><guid>https://sinhak.dev/posts/the-reliable-engineer/</guid><description><h2 id="what-is-_reliability_">What is <em>Reliability</em>?</h2>
<p>One of the lenses through which I view my job is as a <em>service</em> that I provide
to my <em>immediate</em> manager. This is different from any additional obligations
that I may have to my employer.<br>
From this lens, I want to provide such a quality of service where my manager is
able to assign a task to me, and <em><strong>forget about it</strong></em>.<br>
The extent to which I can meet this bar, is <em>reliability</em>.</p></description></item><item><title>Const References to Temporary Objects</title><link>https://sinhak.dev/posts/const-reference-to-temporary-objects/</link><pubDate>Sun, 02 Sep 2018 18:24:40 +0200</pubDate><guid>https://sinhak.dev/posts/const-reference-to-temporary-objects/</guid><description><p>Consider the following code snippet:</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 1</span><span><span style="color:#8ec07c">#include</span> <span style="color:#8ec07c;font-style:italic">&lt;iostream&gt;</span><span style="color:#8ec07c">
</span></span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 2</span><span><span style="color:#8ec07c"></span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 3</span><span><span style="color:#fabd2f">int</span> <span style="color:#fabd2f">GetInt</span>() {
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 4</span><span> <span style="color:#fabd2f">int</span> x <span style="color:#fe8019">=</span> <span style="color:#d3869b">1</span>;
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 5</span><span> <span style="color:#fe8019">return</span> x;
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 6</span><span>}
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 7</span><span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 8</span><span><span style="color:#fabd2f">int</span> <span style="color:#fabd2f">main</span>() {
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59"> 9</span><span> <span style="color:#fe8019">const</span> <span style="color:#fabd2f">int</span><span style="color:#fe8019">&amp;</span> x <span style="color:#fe8019">=</span> GetInt();
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">10</span><span> std<span style="color:#fe8019">::</span>cout <span style="color:#fe8019">&lt;&lt;</span> x <span style="color:#fe8019">&lt;&lt;</span> std<span style="color:#fe8019">::</span>endl;
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">11</span><span> <span style="color:#fe8019">return</span> <span style="color:#d3869b">0</span>;
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">12</span><span>}
</span></span></code></pre></div><p>In particular, pay attention to line #9. Is it guaranteed to be safe?</p></description></item><item><title>About Me</title><link>https://sinhak.dev/about/</link><pubDate>Sun, 02 Sep 2018 03:25:39 +0200</pubDate><guid>https://sinhak.dev/about/</guid><description><p>Hi! I am Kushagra Sinha.</p>
<p>I am a Software Engineer working on Chrome OS, at Google, in the beautiful
German city of Munich.</p>
<p>I have been working in the software industry since 2013. Past jobs have included
Web 2.0 startups and a fin-tech startup. I am fluent in C++, Java and Python.</p>
<p>You can mail me at kush @ this domain.</p></description></item><item><title>Pelican Setup</title><link>https://sinhak.dev/posts/pelican-setup/</link><pubDate>Thu, 24 Aug 2017 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/pelican-setup/</guid><description><p>Install Pelican:</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">1</span><span>sudo -H pip install pelican Markdown typogrify
</span></span></code></pre></div><p>Install Pelican themes</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">1</span><span>git clone --recursive https://github.com/getpelican/pelican-themes
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">2</span><span>sudo /usr/local/bin/pelican-themes --install pelican-themes/Flex
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">3</span><span>sudo chmod <span style="color:#d3869b">755</span> /usr/local/lib/python2.7/dist-packages/pelican/themes/Flex
</span></span></code></pre></div><p>Install Pelican plugins</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">1</span><span>git clone --recursive https://github.com/getpelican/pelican-plugins
</span></span></code></pre></div><p>Fetch blog sources</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">1</span><span>git clone git@github.com:j4nu5/j4nu5.github.io.git
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">2</span><span><span style="color:#fabd2f">cd</span> j4nu5.github.io.git
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">3</span><span>git fetch
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">4</span><span>git checkout <span style="color:#fabd2f">source</span>
</span></span></code></pre></div><p>Setup for development</p></description></item><item><title>USACO setup</title><link>https://sinhak.dev/posts/usaco-setup/</link><pubDate>Mon, 28 Mar 2016 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/usaco-setup/</guid><description><p><a href="http://www.usaco.org/">USACO</a> is fun. Though it is fairly easy to get up
and running on the platform, there remain a few repetitive steps during
problem solving that can be automated. Here is a brief summary of my
automation steps:</p>
<ol>
<li>Use a template. Here is mine. Save it as <em>template.cpp</em>:
<script src="https://gist.github.com/j4nu5/d2b23dcdc20c9de48715.js?file=usaco_template.cpp"></script>
</li>
<li>Save this script as <em>solve.sh</em> in the same directory as above:
<script src="https://gist.github.com/j4nu5/55005626c282e056b753.js?file=usaco_solve.sh"></script>
</li>
<li>All done!
Whenever you&rsquo;re ready to begin coding a solution, simply execute
<code>./solve.sh PROBLEM_NAME</code></li>
</ol>
<p>All the best!</p></description></item><item><title>Hello USACO</title><link>https://sinhak.dev/posts/hello_usaco/</link><pubDate>Sun, 27 Mar 2016 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/hello_usaco/</guid><description><p>I love competitive programming. I love the anticipation while I wait with my
fingers crossed after submitting a solution. And the rush that follows after
getting an &lsquo;AC&rsquo;.</p>
<p>After stagnating near the 60-70th percentile for eons, I have decided to
dedicate focused practice time for competitive programming. The next series
of blog posts will track my journey through <a href="http://www.usaco.org/">USACO</a>.</p>
<p>All the best to me!</p></description></item><item><title>Facebook Hacker Cup 2015 Qualification Round Solutions</title><link>https://sinhak.dev/posts/facebook-hackercup-2015-qualifications/</link><pubDate>Mon, 12 Jan 2015 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/facebook-hackercup-2015-qualifications/</guid><description><p>Facebook recently organized the qualification round of Hacker Cup 2015. They
posed some interesting problems and anyone who could get at least one problem
right can move to the next round.</p>
<p>I managed to get a rank of 217, with a perfect score of 100. I have posted my
solutions below with a little bit of commentary. You can access the problems
<a href="https://www.facebook.com/hackercup/problems.php?round=742632349177460">here</a>.</p>
<h2 id="cooking-the-books-15-points">Cooking the Books (15 points)</h2>
<p>This was the easiest question. Since the constraints were so small, it suffices
to use brute force and try all possible swaps. Care has to be taken however to
make sure that a number never starts with 0.</p></description></item><item><title>Generating Power Set</title><link>https://sinhak.dev/posts/generating-power-set/</link><pubDate>Mon, 05 Jan 2015 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/generating-power-set/</guid><description><p>Iterating over all possible subsets of a set is a problem that can arise not
only in competitive programming but also in day-to-day programming. While the
total number of possible subsets is quite huge (<em>2^n</em> where <em>n</em> is the
cardinality of the input set), often we want an algorithm that systematically
considers all subsets for small values of <em>n</em>.</p>
<p>A <a href="http://en.wikipedia.org/wiki/Power_set">power set</a> is a set of all subsets
of a given input set. Often we may want to simply iterate over all members of
the power set, but sometimes (if we have enough memory) we may need the power
set itself. In the following post, I have attempted to present some algorithms
(with C++11 implementations) that solve both kinds of problems (simple
iteration and complete power set construction).</p></description></item><item><title>Implementing Service Oriented Architecture using Http is a horrible idea</title><link>https://sinhak.dev/posts/soa-using-http-considered-harmful/</link><pubDate>Sun, 16 Nov 2014 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/soa-using-http-considered-harmful/</guid><description><p><a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">Service Oriented Architecture</a>
is a commonly used design pattern in distributed and enterprise applications.
It involves the creation and use of independent <em>services</em> that work together
to produce the desired result. The most important benefits, of course, are
separation of concerns and the ability to scale each service independent of
others, leading to a clean, modular design.</p>
<p>A common problem faced during the design of a SOA system is the choice of
communication protocol. Ideally we want our services to communicate with each
other with minimum communication overhead. This involves:</p></description></item><item><title>The toughest interview question</title><link>https://sinhak.dev/posts/the-toughest-interview-question/</link><pubDate>Tue, 29 Jul 2014 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/the-toughest-interview-question/</guid><description><p>What is the output of the following C code snippet?</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-c" data-lang="c"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">1</span><span><span style="color:#fabd2f">int</span> n <span style="color:#fe8019">=</span> <span style="color:#d3869b">1</span>;
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">2</span><span><span style="color:#fabd2f">printf</span>(<span style="color:#b8bb26">&#34;%d %d %d</span><span style="color:#b8bb26">\n</span><span style="color:#b8bb26">&#34;</span>, n<span style="color:#fe8019">++</span>, <span style="color:#fe8019">++</span>n, n<span style="color:#fe8019">++</span> <span style="color:#fe8019">+</span> <span style="color:#fe8019">++</span>n);
</span></span></code></pre></div><p>This is a tricky question. Any attempt to answer this question requires either
a deep understanding of your compiler&rsquo;s parser or a complete ignorance of C.
Even if you fall under the first category and know the ins and outs of your
favorite compiler, how do you know which is your <em>interviewer&rsquo;s</em> favorite
compiler?</p></description></item><item><title>In search of the perfect blogging platform</title><link>https://sinhak.dev/posts/in-search-of-the-perfect-blogging-platform/</link><pubDate>Wed, 23 Jul 2014 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/in-search-of-the-perfect-blogging-platform/</guid><description><p>What makes a good blogging platform?</p>
<p>Leaving the tech details, feature lists and other bells and whistles
aside, a good blogging platform&rsquo;s primary aim is twofold:</p>
<ol>
<li>Make blogging enjoyable. Entice the blogger into writing more articles.</li>
<li>Make reading enjoyable. The output of the blogging platform should be easy
to consume. A good support for themes and customization is a must.</li>
</ol>
<p>I had been using <a href="https://github.com/rigoneri/syte">Syte</a> as my homepage.
<a href="https://www.tumblr.com/">Tumblr</a> was the underlying blogging platform and
the whole thing was hosted on <a href="https://www.heroku.com/">Heroku</a>. As it turns
out, all three of my aforementioned choices were sub-optimal as far as my
blogging requirements were considered.</p></description></item><item><title>Abstract Classes and Factory Design Pattern in Python</title><link>https://sinhak.dev/posts/abstract-classes-and-factory-design-pattern-in-python/</link><pubDate>Thu, 19 Dec 2013 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/abstract-classes-and-factory-design-pattern-in-python/</guid><description><p><a href="http://en.wikipedia.org/wiki/Class_(computer_programming)#Abstract_and_concrete">Abstract Classes</a>
are one of the most useful and important concepts in Object Oriented
Programming. I&rsquo;ll attempt to illustrate their usefulness, and their usage in
Python 2.7 with the following (seemingly contrived) example:</p>
<p>Let us say, you want/have to implement posting updates on Facebook using
Python. Your code might look something like this:</p>
<div class="highlight"><pre tabindex="0" style="color:#ebdbb2;background-color:#282828;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">1</span><span><span style="color:#928374;font-style:italic"># Attempt 0: Bad code.</span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">2</span><span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">3</span><span><span style="color:#fe8019">def</span> <span style="color:#fabd2f">facebook_share_init</span>(<span style="color:#fe8019">*</span>args, <span style="color:#fe8019">**</span>kwargs):
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">4</span><span> <span style="color:#928374;font-style:italic"># Initialize OAuth with facebook</span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">5</span><span> <span style="color:#928374;font-style:italic"># ...</span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">6</span><span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">7</span><span><span style="color:#fe8019">def</span> <span style="color:#fabd2f">share_on_facebook</span>(<span style="color:#fe8019">*</span>args, <span style="color:#fe8019">**</span>kwargs):
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">8</span><span> <span style="color:#928374;font-style:italic"># Post to Facebook</span>
</span></span><span style="display:flex;"><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#756d59">9</span><span> <span style="color:#928374;font-style:italic"># ...</span>
</span></span></code></pre></div><p>It works and everyone is happy. Then one day, you decide to support posting
tweets in your application. You add the following:</p></description></item><item><title>New Year Resolutions and Nostalgia</title><link>https://sinhak.dev/posts/new-year-resolutions-and-nostalgia/</link><pubDate>Tue, 01 Jan 2013 00:00:00 +0000</pubDate><guid>https://sinhak.dev/posts/new-year-resolutions-and-nostalgia/</guid><description><p>I was going through this <a href="http://mitadmissions.org/blogs/entry/50_things">link</a>
today when I could not help but feel an overwhelming sense of sadness and
incompleteness.</p>
<p>I will be graduating in May, 2013 from the Indian Institute of Technology,
Varanasi. The best 4 years of my life already behind me. As I was going
through this list, I found a lot of things I wish I could have done, many
others I wish I had done in a better fashion and many still that I have to do.</p></description></item></channel></rss>