<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">Pithy Notes</title>
<generator uri="https://github.com/jekyll/jekyll">Jekyll</generator>
<link rel="self" type="application/atom+xml" href="https://www.diyd2.in/feed.xml" />
<link rel="alternate" type="text/html" href="https://www.diyd2.in" />
<updated>2026-09-03T16:09:31+00:00</updated>
<id>https://www.diyd2.in/</id>
<author>
  <name>Sudhan</name>
  <uri>https://www.diyd2.in/</uri>
  <email>sudhan@diyd2.in</email>
</author>


<entry>
  <title type="html"><![CDATA[The Key role of Memory Layer in AI-Assisted SDLC]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/memory-layer-ai-sdlc/" />
  <id>https://www.diyd2.in/articles/memory-layer-ai-sdlc</id>
  <published>2026-09-03T00:00:00+00:00</published>
  <updated>2026-09-03T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;For the last several months I have run my development workflow through AI coding agents. We are talking about 100s of thousands of lines in Java/C++/Python/Shell etc. This involves a platform modernization at a scale where not just code, but the terminology, the architecture, design decisions etc. changed over time.&lt;/p&gt;

&lt;p&gt;I can unequivocally say (now that we are in the final sprint of changes), that a key success factor in the effort was persistent memory.&lt;/p&gt;

&lt;p&gt;During this journey, I have built my own memory layer. &lt;a href=&quot;https://www.npmjs.com/package/pi-graphiti&quot;&gt;pi-graphiti&lt;/a&gt;, a knowledge-graph extension for the Pi coding agent backed by a Graphiti MCP server. A flat-file memory extension that manages scoped notes and harvested procedures. A self-hosted Graphiti and FalkorDB stack. This stores factual information and handles the ‘time element’ for those facts.&lt;/p&gt;

&lt;p&gt;In addition to this graph backed memory, I also have a ‘hermes’ style memory with a background harvester that analyzes and cleans up memory periodically. I think these two - together have done wonders. The naming is a nod to &lt;a href=&quot;https://hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers&quot;&gt;Hermes Agent’s memory providers&lt;/a&gt;, which is a good survey of this design space - flat built-in notes that are always on, plus exactly one pluggable external store behind them, spanning graph, vector, and local SQLite backends.&lt;/p&gt;

&lt;p&gt;A parallel experiment on mem0 with Qdrant for vectors and Memgraph for the graph, mostly to check that the design is transferable to different backends did not work out. What I take away from all of it: prompt engineering without context accumulation (smart) is of no-use. Model capability is fixed on any given day, but how much of my own hard-won operational knowledge the model can reach is something I control, and that part compounds.&lt;/p&gt;

&lt;h2 id=&quot;four-different-problems-wearing-one-name&quot;&gt;Four different problems wearing one name&lt;/h2&gt;

&lt;p&gt;The first thing you learn building this is that “memory” covers four fairly different problems. Working memory is the context window: fast, expensive, gone at session end. That is why bulk material like command output and fetched documentation goes into a searchable index and only a small derived answer enters the conversation.&lt;/p&gt;

&lt;p&gt;Episodic memory is the raw record of what happened, and in the graph setup it is literally called an episode: a snapshot pushed every few turns, again before context compaction, and again on shutdown, with a disk spool so a dead server delays writes instead of losing them.&lt;/p&gt;

&lt;p&gt;Semantic memory is what gets distilled out of those episodes into entities and facts, the durable “X depends on Y, Z is now the default” layer. Procedural memory is the one most people skip and the one that has paid best for me. Any task that took real trial and error ends by being harvested into a skill file with trigger conditions, ordered steps, pitfalls, and verification steps. I have around seventy of those, they load on demand when a task matches, and the second occurrence of a hard problem now costs a fraction of the first.&lt;/p&gt;

&lt;p&gt;Here is how the tiers fit together in the loop:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/memory-tiers.png&quot; alt=&quot;Memory tiers in an agent SDLC loop&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;scope-and-category-are-what-make-retrieval-work&quot;&gt;Scope and category are what make retrieval work&lt;/h2&gt;

&lt;p&gt;Undifferentiated memory turns into noise quickly. So every write picks a scope: a per-project bucket, a global bucket for cross-project environment facts, and a user bucket for identity and standing preferences. Every durable lesson also picks a category: preference, correction, convention, insight, failure, tool-quirk. That vocabulary is what makes retrieval selective.&lt;/p&gt;

&lt;p&gt;When a build breaks I search failures and tool-quirks instead of dredging the whole store. In practice the negative entries are useful. “This filesystem is enormous, never recurse from the root.” “That upstream-bug theory was wrong, the cause was our own parameter names.” “Do not push a config change whose image is not built yet, sync is automatic and self-healing.” Each one is a real outage or a wasted afternoon that cannot repeat. Corrections are valuable enough that I wired a detector for them, so the moment the user pushes back on the agent, a curation pass fires immediately. That is the highest-signal moment in the loop and it is easy to lose.&lt;/p&gt;

&lt;h2 id=&quot;the-part-naive-implementations-get-wrong-is-time&quot;&gt;The part naive implementations get wrong is time&lt;/h2&gt;

&lt;p&gt;Facts are true at a point in time. Branch names of record change, default ports move, a service starts publishing to a different registry etc. In fact our new platform was referred to briefly as the ‘new platform’ (!) and subsequently called ‘v3’ and now we have v3 (dev, stg, prod etc.). So, our skills/memory need to account for this. A theory about a bug gets replaced by the actual root cause. An append-only store will hand the agent last quarter’s truth with full confidence, and that sends work down a dead path rather than prompting a fresh look. This is why I ended up on a temporal knowledge graph rather than a plain vector store. Relationships carry value for some time intervals. So a new assertion can invalidate the old edge instead of sitting next to it as a contradiction, and “when did this change” stays answerable.&lt;/p&gt;

&lt;p&gt;And one more thing - forgetting has to be built in :) Google for what happens when someone is ‘unable to forget’. Real systems need pruning, supersession, and expiry: file-backed sources that flag themselves stale when the underlying file’s hash changes, consolidation passes that collapse a sprawling project note down to “the detail lives in the repo docs, query the graph for raw facts,” age-based expiry that routes to a dead-letter file, and scoped purge so I can wipe one session or one project without touching the rest.&lt;/p&gt;

&lt;p&gt;Two rules I settled on the hard way. Never delete quietly; leave a trace of what was dropped and why. And prefer supersession over deletion, because “this held until date X” is often the fact you actually need.&lt;/p&gt;

&lt;p&gt;On balance, I think my setup has resulted in faster time-to-resolution of tasks, but sometimes at the cost of more tokens. While earlier, I used to start the session by trying to be ‘very clear with my requirements’, as the system is evolving, I now start most of my conversations with stuff like ‘Do you remember the X edge-case we discussed ideas about? Can we revisit that?’ and Boom! - I get a clear timeline of what happened, why we paused something etc.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;p&gt;Memory and Context is worth treating as an engineering surface. Record failures as carefully as successes, timestamp what you assert, prune deliberately, and make “harvest what I just learned” an actual step in the loop.&lt;/p&gt;

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

&lt;p&gt;The graph-memory piece described here is published, if you want to try it or read the implementation:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/pi-graphiti&quot;&gt;pi-graphiti on npm&lt;/a&gt; - persistent knowledge graph for the Pi coding agent via Graphiti MCP. Ambient recall, automatic episode writes on session events, project/global scoping, and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/graph&lt;/code&gt; command. Install with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pi install npm:pi-graphiti&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.getzep.com/graphiti&quot;&gt;Graphiti documentation&lt;/a&gt; - the temporal knowledge graph engine it builds on. You need a running Graphiti MCP server (FalkorDB or Neo4j backend); &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/graph setup&lt;/code&gt; will provision a local Docker stack for you.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://hermes-agent.nousresearch.com/docs/user-guide/features/memory-providers&quot;&gt;Hermes Agent - Memory Providers&lt;/a&gt; - worth reading for the comparison table alone: nine providers across cloud, self-hosted, and local storage, with the trade-offs of each retrieval strategy laid out side by side. It also documents the pattern I ended up agreeing with - built-in flat memory stays always-on and the external store is additive, not a replacement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Earlier articles in this series, on the trade-offs that led here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.diyd2.in/articles/code-execution-mcp/&quot;&gt;Code-Execution MCP - Validating Savings&lt;/a&gt; - why bulk output belongs in an index instead of the context window.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.diyd2.in/articles/illusion-of-competence/&quot;&gt;The Illusion of Competence&lt;/a&gt; - what goes wrong when an agent sounds confident without grounding.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.diyd2.in/articles/coding-agents-pitfall/&quot;&gt;AI can generate code 10x faster, But will that help?&lt;/a&gt; - the throughput-versus-correctness problem that makes memory worth building.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/memory-layer-ai-sdlc/&quot;&gt;The Key role of Memory Layer in AI-Assisted SDLC&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on September 03, 2026.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Code-Execution MCP - Validating Savings]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/code-execution-mcp/" />
  <id>https://www.diyd2.in/articles/code-execution-mcp</id>
  <published>2025-11-28T00:00:00+00:00</published>
  <updated>2025-11-28T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;p&gt;Most recent language models have become very adept at generating and using code. In a recent blog, Anthropic suggested a technique they call ‘Code Execution with MCP’, as a more efficient way to use Tokens/context.
If you are not familiar with their post, here is the link : &lt;a href=&quot;https://www.anthropic.com/engineering/code-execution-with-mcp&quot;&gt;Code execution with MCP: building more efficient AI agents \ Anthropic&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, I share how I went about valiating the idea. Finally confirming that this 
is a useful technique only under certain conditions/trade-offs: large number of MCP servers installed, robust code-execution sandbox, complicated tasks that require multi-step MCP calls etc. I think we may save token-costs at the risk of more requests &amp;amp; time (depends on the task relationship to MCP tools)&lt;/p&gt;

&lt;h2 id=&quot;can-we-really-save-so-many-tokens-with-what-other-trade-off&quot;&gt;Can we really save so many tokens? With what other trade-off?&lt;/h2&gt;

&lt;p&gt;The basic premise is to avoid sending &lt;em&gt;all&lt;/em&gt; the tools/MCPs available at the client side to the LLM to allow it to pick what to use. This not only uses up a lot of context to list the tools, but it also results in context bloat when we have a multi-step task and we store and process intermediate results back and forth between tool invocations and we have them polluting the history as well.&lt;/p&gt;

&lt;p&gt;What was startling was the amount of savings they mentioned - in the order of 90+% (validate). I wanted to try this out for myself.&lt;/p&gt;

&lt;p&gt;As any good engineer would do, I set out to find out ‘someone else’ who has already solved it and just test it out. The blog itself mentions ‘Cloudflare Code Mode’ as an example. It turns out, what Cloudflare described in &lt;em&gt;their&lt;/em&gt; blog was implemented with their own SDK. See: &lt;a href=&quot;https://blog.cloudflare.com/code-mode/&quot;&gt;Code Mode: the better way to use MCP&lt;/a&gt; ; To make matters worse, it was for Typescript (so was the blog written by Anthropic). While familiar with Typescript, I rather fancied some Python implementation to allow me to use the approach in my own code.&lt;/p&gt;

&lt;p&gt;Bit of googling, led me to &lt;a href=&quot;https://jangwook.net/en/blog/en/mcp-code-execution-practical-implementation/&quot;&gt;MCP Code Execution in Practice: Improving Claude Code Project Structure&lt;/a&gt; (&lt;a href=&quot;https://www.linkedin.com/feed/#&quot;&gt;JANGWOOK KIM&lt;/a&gt;) - once again describing some implementation (not in public domain) and written in Typescript.&lt;/p&gt;

&lt;p&gt;Looks like, I have to write some code after all :(&lt;/p&gt;

&lt;h2 id=&quot;the-code-design&quot;&gt;The Code design&lt;/h2&gt;

&lt;p&gt;The key building blocks of a basic implementation would be:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Pick any Agentic framework : I chose Pydantic AI&lt;/li&gt;
  &lt;li&gt;Provide it with a mechanism to search file system : This is essentially part of a delicate System Prompt&lt;/li&gt;
  &lt;li&gt;Provide it with a mechanism to execute code (Python in our case) : System Prompt also includes instruction on how to use the execute_code function&lt;/li&gt;
  &lt;li&gt;Provide it access to a bunch of MCPs : I selected few simple ones - including the filesystem and time operations&lt;/li&gt;
  &lt;li&gt;Finally, a Task that is worthy of all this complexity !!! - Count the number of files in a folder and could only .py and the number of lines in all the files, then save the results into a file with the ‘current datetime as a suffix’&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-implementation-details&quot;&gt;The Implementation details&lt;/h2&gt;

&lt;p&gt;The actual sample implementation is in pydantic_main.py - which just demonstrates the bare minimum to use such an agent with ‘code execution’ capabilities.&lt;/p&gt;

&lt;p&gt;Then there is the token_savings_demo.py code, that demonstrates using plain MCP vs code-execution MCP. It prints the savings and lot of intermediate contents for debug purposes. For the relatively trivial task given to the Agent, it showed a savings of between 50-90% token savings.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;The code, as of today, does the bare minimum to help understand the flow. There are potentially many enhancements that we can do. For e.g. the ‘search_tools’ tool mentioned in the Anthropic article (maybe doign some smart search), add the ability to persistent code that resulted in successful outcomes (remembered Skills), security aspects of a Sandbox etc.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;some-key-observations&quot;&gt;Some key observations:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;At the expense of context/token savings, the whole task becomes ‘chatty’ with the LLM - there are more back-n-forth to ‘discover’ servers and tools&lt;/li&gt;
  &lt;li&gt;For all this to make sense, we need a complex-enough task, that can be decomposed into smaller steps and those steps can in-turn be represented within a single block of code.&lt;/li&gt;
  &lt;li&gt;There should enough number of MCP servers configured on the client application that would have taken up token - with the new approach that won’t need to be sent to the LLM at once.&lt;/li&gt;
  &lt;li&gt;This requires quite a bit of scaffolding - for .e.g to generate the MCP Server access ‘wrappers’ that will be used in the generated code. Similarly, a way to pass intermediate code execution values across code invocations till a task is completed (multiple code execution steps)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All said and done, it was an interesting weekend trying to get this working. Hope this helps you understand how ‘small and incremental’ changes can make a big difference in cost/effciency
The code I wrote is available in the repo here: &lt;a href=&quot;https://github.com/p2c2e/pydantic_mcp_code_execution&quot;&gt;pydantic_mcp_code_execution&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/code-execution-mcp/&quot;&gt;Code-Execution MCP - Validating Savings&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on November 28, 2025.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[The Illusion of Competence]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/illusion-of-competence/" />
  <id>https://www.diyd2.in/articles/illusion-of-competence</id>
  <published>2025-10-31T00:00:00+00:00</published>
  <updated>2025-10-31T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Technologists Needs More Than AI Proficiency&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Over the past five years, a combination of AI and Covid-era learning
gaps, has resulted in a dramatic shift in how young engineers learn and
build. AI copilots now write functions, explain code, generate APIs, fix
bugs, produce documentation, and design entire architectures in minutes.&lt;/p&gt;

&lt;p&gt;It’s intoxicating.&lt;br /&gt;
A new developer can produce working software faster than any generation
in history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But, we are creating a generation of developers who can build things
that _may_ work, without understanding why they work — or when they
will fail.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Or in simpler words: They have been imparted ‘knowledge’ without the
foundation to gain ‘experience’&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Managers quietly share the same concerns:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Engineers who can code, but can’t debug.&lt;/li&gt;
  &lt;li&gt;Builders who can assemble components, but not explain tradeoffs.&lt;/li&gt;
  &lt;li&gt;Programmers who trust AI answers even when the answers are wrong.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not their fault. They never had to learn slowly. Organizations have an obligation to help them.&lt;/p&gt;

&lt;h2 id=&quot;the-compass-the-original-ai-problem&quot;&gt;The Compass: The Original “AI Problem”&lt;/h2&gt;

&lt;p&gt;Seven centuries ago, sailors faced a similar trap.&lt;/p&gt;

&lt;p&gt;When the magnetic compass spread across Europe in the 1200s, it felt
like magic.&lt;br /&gt;
No stars required. No experience needed. Just follow the needle, and
you’ll arrive safely.&lt;/p&gt;

&lt;p&gt;Except — the needle didn’t point to true north.&lt;br /&gt;
It pointed to &lt;em&gt;magnetic&lt;/em&gt; north, which shifts by geography and time.&lt;/p&gt;

&lt;p&gt;Early navigators didn’t know this.&lt;br /&gt;
They trusted the tool, not the science.&lt;/p&gt;

&lt;p&gt;So ships left port confidently…&lt;br /&gt;
and drifted degree-by-degree into storms, reefs, hunger, and
disappearance.&lt;/p&gt;

&lt;p&gt;The compass wasn’t the enemy.&lt;br /&gt;
&lt;strong&gt;Blind reliance was.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It took centuries — and William Gilbert’s &lt;em&gt;De Magnete&lt;/em&gt; in 1600 — for
humans to realize the Earth itself was a magnet, and that variation had
to be calculated, corrected, and taught.&lt;/p&gt;

&lt;p&gt;Only when sailors understood the tool&lt;br /&gt;
did the tool become safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Knowledge was knowing how to use the compass.&lt;br /&gt;
Experience was knowing when the compass could get them killed.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;ai-is-todays-compass&quot;&gt;AI Is Today’s Compass&lt;/h2&gt;

&lt;p&gt;AI points us forward — fast, confidently, convincingly.&lt;br /&gt;
But a correct-looking answer is not a correct answer.&lt;br /&gt;
A working prototype is not a durable system.&lt;/p&gt;

&lt;p&gt;If we allow students and early-career developers to trust every output,
bypass fundamentals, avoid learning what breaks and why, &lt;em&gt;then we are
sending ships to sea without navigators&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;we-need-more-than-tool-training&quot;&gt;We Need More Than Tool Training&lt;/h2&gt;

&lt;p&gt;It’s not enough to teach young engineers how to use AI.&lt;br /&gt;
We must teach them how to &lt;strong&gt;challenge it&lt;/strong&gt;, &lt;strong&gt;validate it&lt;/strong&gt;, and
&lt;strong&gt;override it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means a structured way to build using engineering intuition,
independent reasoning, skepticism and healthy dose of craft knowledge&lt;/p&gt;

&lt;h2 id=&quot;a-practical-solution-the-dual-track-engineer-program&quot;&gt;A Practical Solution: The “Dual-Track Engineer” Program&lt;/h2&gt;

&lt;p&gt;A repeatable model for universities and companies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Track A: Assisted&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Students build systems &lt;strong&gt;with AI tools&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Plan → Code → Test → Deploy with AI support&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Optimize speed and outcome&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Learn prompt engineering and tool capabilities&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Track B: Unassisted&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then they rebuild critical parts &lt;strong&gt;without AI&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Write core logic by hand and Solve bugs without LLM help&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Challenge themselves to review LLM code and suggestions to improve
outcomes&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Design architectures independently&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Explain performance and reliability choices&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Bridge: Tool Reconciliation Report&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For every module, they answer:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;What did the AI produce?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;What was wrong or suboptimal?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;What did you change, and why?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;What did you learn that the tool could not explain?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Could you do it without the tool? If not, what’s missing in your
knowledge?&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This framework develops judgment, craftsmanship, architectural thinking,
and the ability to spot failure before it happens.&lt;/p&gt;

&lt;h2 id=&quot;organizations-need-to-drive-this-change&quot;&gt;Organizations need to drive this change&lt;/h2&gt;

&lt;p&gt;Sailors became true navigators only when they understood the compass
deeply enough to doubt it. Tomorrow’s engineers need that same mindset.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Learn the fundamentals.&lt;/li&gt;
  &lt;li&gt;Question the output.&lt;/li&gt;
  &lt;li&gt;Understand the why, not just the what.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AI is a powerful compass.&lt;br /&gt;
But the world still needs navigators.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Knowledge is knowing what works.&lt;br /&gt;
Experience is knowing what doesn’t.&lt;br /&gt;
And technology moves forward only when we have both.&lt;/strong&gt;&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Read about the &lt;a href=&quot;https://arstechnica.com/science/2019/07/apollo-triumph/&quot;&gt;story of Apollo-11&lt;/a&gt; and how Neil Armstrong took control when the ‘automated’ systems failed&lt;/em&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/illusion-of-competence/&quot;&gt;The Illusion of Competence&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on October 31, 2025.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[AI can generate code 10x faster, But will that help?]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/coding-agents-pitfall/" />
  <id>https://www.diyd2.in/articles/coding-agents-pitfall</id>
  <published>2025-10-20T00:00:00+00:00</published>
  <updated>2025-10-20T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;p&gt;In the last two years, AI-assisted development has gone from novelty to mainstream. Tools that generate code, write tests, refactor, document, and even propose architectural changes are now widely accessible. The promise sounds irresistible: software development will become 10× faster. But will that actually help companies move 10× faster — or could it backfire?&lt;/p&gt;

&lt;p&gt;Using the lens of Theory of Constraints (TOC) and Critical Chain Project Management, this article argues that accelerating a single part of the software development lifecycle (SDLC) does not automatically accelerate the system. In fact, it may do the opposite.&lt;/p&gt;

&lt;p&gt;And there’s a more uncomfortable truth: Even if AI generates code 10× faster, it has not translated into 10× business value. Not even close. More code is not the same as more impact.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Suggested Read: Theory of constraints - Wikipedia (and the books referred there)&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-promise-10-faster-development&quot;&gt;The promise: 10× faster development&lt;/h2&gt;
&lt;p&gt;Nearly every engineering leader has heard the pitch:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Code generation is instant, even documentation taken care of!&lt;/li&gt;
  &lt;li&gt;Bugs are autocorrected&lt;/li&gt;
  &lt;li&gt;Tests are written for you&lt;/li&gt;
  &lt;li&gt;Developers spend less time on boilerplate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In theory, this means developers build more features, ship faster, and accelerate innovation cycles. On paper, that sounds transformative.&lt;/p&gt;

&lt;p&gt;But in the real world, coding speed has never been the sole bottleneck.&lt;/p&gt;

&lt;h2 id=&quot;the-theory-of-constraints-systems-dont-get-faster-by-accelerating-one-part&quot;&gt;The Theory of Constraints: systems don’t get faster by accelerating one part&lt;/h2&gt;
&lt;p&gt;TOC teaches a simple idea:&lt;/p&gt;

&lt;p&gt;A system is only as fast as its slowest step.&lt;/p&gt;

&lt;p&gt;In SDLC, coding is only one step. Even if AI turns this step into near-zero time, the rest of the chain still exists. For e.g., below are some key stages and the challenges that they bring.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Requirements clarity : No — still human-driven, ambiguous, political&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Security review : No — still manual, compliance heavy&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Integration with other systems : No — requires coordination, human decisions, your team being faster doesn’t mean others can keep up&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;User impact, training : No — users can’t absorb features at AI speed&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Regulatory/Law reviews : Certainly not&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Ops &amp;amp; monitoring : More change = more complexity&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If one part of the pipeline accelerates while the rest remains the same, the constraint simply moves.&lt;/p&gt;

&lt;p&gt;Critical Chain thinking even warns that accelerating upstream work without matching downstream capacity can be damaging:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;reviews get overloaded&lt;/li&gt;
  &lt;li&gt;integration queues grow&lt;/li&gt;
  &lt;li&gt;bugs slip through&lt;/li&gt;
  &lt;li&gt;deployment teams burn out&lt;/li&gt;
  &lt;li&gt;support teams get blindsided&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like making cars 10× faster but keeping the same number of lanes and traffic signals — the road gets congested, not efficient.&lt;/p&gt;

&lt;h2 id=&quot;so-why-isnt-10-coding-delivering-10-value&quot;&gt;So why isn’t 10× coding delivering 10× value?&lt;/h2&gt;
&lt;p&gt;Because value is created when software is adopted, not when it is written.&lt;/p&gt;

&lt;p&gt;Let’s break it down.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;New features disrupt business flows
Shipping faster isn’t always better. If each release changes workflows, pricing logic, user journeys, dashboards or data structures, the business side can’t absorb the pace.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;Sales needs new messaging&lt;/li&gt;
  &lt;li&gt;Support needs new documentation&lt;/li&gt;
  &lt;li&gt;Legal approves new customer-facing behaviour&lt;/li&gt;
  &lt;li&gt;Customers need training or migration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can ship 10 features in a week — but if the business can only handle one a month, the “extra” code provides zero value.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Integration complexity multiplies
Most enterprise applications do not live alone — they live in a web of:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;billing systems&lt;/li&gt;
  &lt;li&gt;auth services&lt;/li&gt;
  &lt;li&gt;APIs&lt;/li&gt;
  &lt;li&gt;vendors&lt;/li&gt;
  &lt;li&gt;data warehouses&lt;/li&gt;
  &lt;li&gt;mobile clients&lt;/li&gt;
  &lt;li&gt;legacy modules&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every new change has blast radius. When code volume increases faster than integration planning, the system becomes fragile.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Operations becomes the new bottleneck
Faster dev → faster deploy → faster incidents. Modern cloud systems are always-on, highly-distributed and sensitive to churn. Ops teams must:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;monitor more releases&lt;/li&gt;
  &lt;li&gt;triage more alerts&lt;/li&gt;
  &lt;li&gt;rollback faster&lt;/li&gt;
  &lt;li&gt;maintain uptime SLAs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If dev speed doubles but ops capacity does not, quality drops and risk increases.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Technical debt compounds faster
AI can generate code quickly — but not all of it is maintainable, elegant or future-proof.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Several studies and enterprise reports show:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Low-quality or duplicated code increases defect count&lt;/li&gt;
  &lt;li&gt;Refactoring AI-generated outputs later is expensive&lt;/li&gt;
  &lt;li&gt;Debt interest reduces future velocity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t get 10× value if you accumulate 10× debt.&lt;/p&gt;

&lt;h2 id=&quot;research-coding-is-faster-value-is-not&quot;&gt;Research: coding is faster, value is not&lt;/h2&gt;
&lt;p&gt;Recent industry findings support this:&lt;/p&gt;

&lt;p&gt;Atlassian reported developers saved 10+ hours per week using AI tools — but organizational overhead (coordination, unclear requirements, inter-team dependencies) nullified much of this gain.
A study on software quality found low-quality code produced 15× more bugs, and fixing issues in such code took 124% longer, erasing initial development speed.
Technical debt causes developers to waste 23% of their time on rework — speeding up code generation without improving code quality simply makes this worse.&lt;/p&gt;

&lt;h2 id=&quot;conclusion-speed-is-real-value-is-not--yet&quot;&gt;Conclusion: speed is real, value is not — yet.&lt;/h2&gt;

&lt;p&gt;The real question: can the organization absorb the speed?
Before celebrating “10× faster development,” companies should ask:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Do our architecture reviews scale?&lt;/li&gt;
  &lt;li&gt;Do security, compliance and legal gates scale?&lt;/li&gt;
  &lt;li&gt;Can QA validate 10× more change?&lt;/li&gt;
  &lt;li&gt;Can we train customers and support staff that fast?&lt;/li&gt;
  &lt;li&gt;Will users actually benefit from that many new features?&lt;/li&gt;
  &lt;li&gt;Are we creating more instability than value?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any answer is “no,” then accelerated coding just creates inventory, waste, and operational chaos.&lt;/p&gt;

&lt;h3 id=&quot;do-we-even-need-that-pace-of-change&quot;&gt;Do we even need that pace of change?&lt;/h3&gt;
&lt;p&gt;Not every business benefits from hyperspeed. In many industries, stability, predictability and compliance are more valuable than frenetic innovation.&lt;/p&gt;

&lt;p&gt;In many real-world platforms, the limiter is not development — it is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Risk, Regulation, Market readiness, Integration maturity, Inter-team coordination&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;

  &lt;p&gt;In such environments, even 2× improvement in stability is worth more than 10× faster coding.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So what should leaders actually do?&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Apply value-stream mapping
Identify the true bottleneck: requirements → architecture → dev → QA → security → deploy → user adoption If coding becomes fast, shift investment into the next constraint.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Measure value, not velocity
Release fewer features, but more valuable ones. Business impact &amp;gt; code volume.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Build quality gates early
If AI code is fast but sloppy, the debt kills the gain.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Align the ecosystem
Automation for: testing, documentation, compliance checks, infrastructure provisioning&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without this, AI just floods the pipeline.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Consider cadence and absorption
Users don’t want a new UI every week. Support teams can’t re-learn product logic every sprint. Legal teams won’t accelerate because GitHub Copilot typed faster.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;AI can absolutely accelerate coding — in some tasks, 10× is real. But 10× code does not equal 10× business value, because:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;software value is realised only when deployed, adopted and stable&lt;/li&gt;
  &lt;li&gt;every system has bottlenecks beyond code&lt;/li&gt;
  &lt;li&gt;rushing creates fragility and debt&lt;/li&gt;
  &lt;li&gt;organizations, users and operations cannot absorb infinite change&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The smartest companies in the next decade will not be the ones generating code the fastest, but the ones that align velocity with the rest of their ecosystem — ensuring that every line of code translates to real, measurable value.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The question should not be: How fast can we build?&lt;/p&gt;

  &lt;p&gt;The real question is: Can we build fast in a way the business, ecosystem and users can absorb — and does each change actually deliver value?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Until that answer is yes, AI-accelerated coding alone is not the breakthrough. It’s just the first step.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;em&gt;This article was originally published on LinkedIn &lt;a href=&quot;https://www.linkedin.com/pulse/ai-can-generate-code-10x-faster-help-sudharsan-sudhan-rangarajan-i6tkc/&quot;&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/coding-agents-pitfall/&quot;&gt;AI can generate code 10x faster, But will that help?&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on October 20, 2025.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Rabbithole from TinyML to Arduino to USB ISP Firmware flashing]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/usb-isp-avr-firmware/" />
  <id>https://www.diyd2.in/blog/usb-isp-avr-firmware</id>
  <published>2022-11-06T00:00:00+00:00</published>
  <updated>2022-11-06T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;h1 id=&quot;introduction---getting-usb-isp-programmer-clones-to-work-on-macos&quot;&gt;Introduction - Getting USB ISP Programmer (clones) to work on MacOS&lt;/h1&gt;

&lt;p&gt;What started as an attempt to do a bit TinyML led to a day long exercise in getting a USB-ISP V2.0 programmer to work. These are cheap programmer boards used to flash programs to ATmega, ATtiny microcontrollers from Atmel. These micro-controllers usually very easy to use since most folks use them via Boards like Arduino UNO, Nano, Pro Micro and the like that have USB-to-Serial built-in.&lt;/p&gt;

&lt;p&gt;If you need to program the chips and use the bare minimum components, you will have to move away from the Arduino boards to the bare-essentials.&lt;/p&gt;

&lt;p&gt;BUT, to do that, you will need to somehow flash firmware to the chips. Enter: USB-ISP Programmers.&lt;/p&gt;

&lt;p&gt;I bought a very cheap one for around 4 USD only to find out that it does not work (on Mac Monterey atleast). 
Rather than return the device, I tried to figure it out and benefited from the lessons from many folks who had already made the journey.&lt;/p&gt;

&lt;p&gt;To save time for others:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Summarized the symptoms&lt;/li&gt;
  &lt;li&gt;Modified and compiled the source code&lt;/li&gt;
  &lt;li&gt;Written a small Readme section for folks to follow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can check out the repository at https://github.com/p2c2e/usbasp.2011-05-28-zhifengsoft-USB-ISP-Clone.git&lt;/p&gt;

&lt;p&gt;Device that I bought: https://robocraze.com/products/usb-isp-programmer-version-2-0
Image: &lt;img src=&quot;https://cdn.shopify.com/s/files/1/0262/6564/9240/products/HatchnHack_Makerspace_HNH_Cart_Components-46_72fc1b49-2b22-429e-bd43-a8e6d2adb7b3_800x.jpg?v=1648799456&quot; alt=&quot;How the device looks like&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/usb-isp-avr-firmware/&quot;&gt;Rabbithole from TinyML to Arduino to USB ISP Firmware flashing&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on November 06, 2022.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Setting up a second disk in TrueNAS mirror mode]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/truenas-mirror/" />
  <id>https://www.diyd2.in/articles/truenas-mirror</id>
  <published>2022-02-12T00:00:00+00:00</published>
  <updated>2022-02-12T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;h2 id=&quot;the-context&quot;&gt;The Context&lt;/h2&gt;
&lt;p&gt;Recently I decided to replace my old custom-build desktop with a newer setup. You may wonder, who uses a desktop anymore? I have been using mine to install licensed software that would be used by everyone in the house (like Adobe, Ableton Live etc.) as well as a local backup of important files. Usually I keep a desktop ‘alive’ by upgrading components over-time and on-average they are with me for 5-10 years each.&lt;/p&gt;

&lt;p&gt;Old-setup - Intel Core i3, Gigabyte MB, SSD boot + 2x 4TB Seagate HDDs, 8GB RAM&lt;/p&gt;

&lt;p&gt;New-setup - AMD Ryzen 7 5800x, MSI MB with 6x SATA, 16G NVMe, SSD Boot, Old HDDs, 16GB RAM&lt;/p&gt;

&lt;p&gt;First hurdle to cross : Was the migration of the Windows 10 Pro license from the old SSD to the newer/larger SSD. Thankfully, this was done with no issues. I ensured that the older system license was Digitally activated AND linked to my MS account. Then I created a Restore USB for safety. I had an older copy of Seagate Disktools and I used it to clone the SSD to the newer SSD. 
On using the cloned Disk to boot, I was impressed how resilient Windows 10 was. With a different MB, CPU and monitor, it managed to boot and subsequently download all the newer drivers etc. As expected, Windows 10 reported that it wasn’t able to activate windows on the new machine. I used “Change Product Key” and re-entered my key from the earlier machine - and voila - it worked!&lt;/p&gt;

&lt;h2 id=&quot;the-core-of-this-post---what-do-i-do-with-the-older-machine&quot;&gt;The core of this post - What do I do with the older machine?&lt;/h2&gt;

&lt;p&gt;I decided to try my hand at setting up a local NAS system. Any 4 drive NAS enclosure (without disk) was costing 50,000 INR or more. Hence this was worth a shot.
After some research, I decided on a few things:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Software : There was FreeNAS, TrueNAS and Unraid. Found out that FreeNAS is now TrueNAS Core - and still Free. Unraid is very easy to setup but limited in config options. Settled on &lt;a href=&quot;https://www.truenas.com/download-truenas-core/&quot;&gt;TrueNAS Core&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Hardware : I wanted to understand how to handle upgrade/degrades of disks. So, started by installing TrueNAS on the older SSD + ONE HDD of smaller size (2TB)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With 1 HDD, there is not much safety and as part of the initial setup, that a single disk ‘stripe’ was risky and I had to select “Force”. This gave me the 1.8Tb of storage. No redundancy. After setting up the share and testing on a Mac, I decided to add another disk.&lt;/p&gt;

&lt;h2 id=&quot;adding-the-second-disk---of-a-differenthigher-capacity&quot;&gt;Adding the Second Disk - of a different/higher capacity&lt;/h2&gt;

&lt;p&gt;Adding a second disk - I had a choice of striping - and hence still do redundancy (since I would get larger storage + more speed, but data spread over both drives) OR do a mirror.
I decided to go the Mirror route. After much head-banging I found that there is no way in the WebUI to add a Second Disk to an existing pool with Mirror mode. Hence we needed to get into the shell to do stuff. See here for interesting info on &lt;a href=&quot;https://icesquare.com/wordpress/zfs-performance-mirror-vs-raidz-vs-raidz2-vs-raidz3-vs-striped/&quot;&gt;performance impact of the choices&lt;/a&gt;. Mirroring limits the storage space to the min size amongst all the disks AND slows down performance - but has high reliability.&lt;/p&gt;

&lt;p&gt;Steps to setup a Second Disk with Mirroring in an existing Pool&lt;/p&gt;

&lt;p&gt;Basically, there are 4 steps&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Physically install the new drive&lt;/li&gt;
  &lt;li&gt;Wipe the drive from the WebUI&lt;/li&gt;
  &lt;li&gt;Partition the drive as appropriate&lt;/li&gt;
  &lt;li&gt;Attach the new partitions to the existing ZFS pool and wait for Resilvering to complete (hopefully successful)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I am pasting the 3rd and 4th steps below, in the hopes that it will help others.&lt;/p&gt;

&lt;p&gt;In my setup, &lt;em&gt;ada0&lt;/em&gt; was the first HDD, &lt;em&gt;ada1&lt;/em&gt; was the Boot SSD and the newly added drive was &lt;em&gt;ada2&lt;/em&gt;.  &lt;em&gt;pool01&lt;/em&gt; is the name of the storage/data pool with the single ada0 drive - it had two partition - swap and the actual data. I realized that I don’t need the swap&lt;/p&gt;

&lt;p&gt;(3)&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;root@truenas[~]#gpart add -i 1 -t freebsd-zfs /dev/ada2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(If you want a swap partition as well.. you would do two steps: - subsequent commands will have to reference the right ada2p?&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;gpart add -i 1 -b 128 -t freebsd-swap -s 2g /dev/ada2 # 2G for swap
gpart add -i 2 -t freebsd-zfs /dev/ada2 # For data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;)&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;root@truenas[~]# glabel status
                                      Name  Status  Components
gptid/45ae1680-8a9b-11ec-b2ce-408d5ceadf9f     N/A  ada0p2 
gptid/890e9a43-8ac7-11ec-8bb9-408d5ceadf9f     N/A  ada1p1
gptid/45a1f4c3-8a9b-11ec-b2ce-408d5ceadf9f     N/A  ada0p1
gptid/785eca5d-8bc9-11ec-8e07-408d5ceadf9f     N/A  ada2p1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(4)&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;root@truenas[~]# zpool attach pool01 /dev/gptid/45ae1680-8a9b-11ec-b2ce-408d5ceadf9f /dev/gptid/785eca5d-8bc9-11ec-8e07-408d5ceadf9f
root@truenas[~]# zpool status
  pool: boot-pool
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        boot-pool   ONLINE       0     0     0
          ada1p2    ONLINE       0     0     0

errors: No known data errors

 pool: pool01
 state: ONLINE
  scan: resilvered 1.22G in 00:00:11 with 0 errors on Fri Feb 11 22:39:06 2022
config:

        NAME                                            STATE     READ WRITE CKSUM
        pool01                                          ONLINE       0     0     0
          mirror-0                                      ONLINE       0     0     0
            gptid/45ae1680-8a9b-11ec-b2ce-408d5ceadf9f  ONLINE       0     0     0
            gptid/785eca5d-8bc9-11ec-8e07-408d5ceadf9f  ONLINE       0     0     0

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice the “scan:” line above in the status. It shows “resilvered” - i.e. the data has been mirrored. Also, you can see the mirror-0 in the pool. It is also worth noting that the first drive was 2TB and the second drive was 4TB. Since it is setup for mirroring, the capacity is the lowest of all the drives - in our case, it is 2TB. As part of testing, I had 1.22G worth of data, which is mentioend in the scan line.&lt;/p&gt;

&lt;h2 id=&quot;adding-a-third-drive---just-for-kicks&quot;&gt;Adding a third drive - just for kicks&lt;/h2&gt;

&lt;p&gt;I was curious to see if I can add an external drive to the setup. I have a few 1TB Passport USB drives lying around. I tried the above flow to get it added to the same pool01.
As is to be expected, I could not attach the drive to the pool, since it is smaller than the smallest drive currently in the pool. i.e. We can mirror all the existing data (though I had not used the storage space yet).&lt;/p&gt;

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

&lt;p&gt;I want to randomly pull out/unplug the drives to see how the UI responds and whether I am able to import and enable disks etc. This has to be done for both the Mirror setup as well as - I would like to try atleast the RAIDZ1 and RAIDZ2. For this, I plan to get a few more 4TB HDDs. Let us see…&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/truenas-mirror/&quot;&gt;Setting up a second disk in TrueNAS mirror mode&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on February 12, 2022.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[3D Printing : Octoprint woes]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/octoprint-resend/" />
  <id>https://www.diyd2.in/articles/octoprint-resend</id>
  <published>2022-01-01T00:00:00+00:00</published>
  <updated>2022-01-01T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;&lt;img src=&quot;/images/adiyogi_pic.jpg&quot; alt=&quot;Adiyogi Lithophane&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Every once in a while, I get carried away with a new hobby. The latest one in the series is 3D printing. I have been looking at this space since 2015 and neither the cost nor the interest level were enough for me to take the plunge. Then things changed in Dec-2021. What triggered this is when a small plastic part broke that required a replacement of the entire product + my search for a right-size enclosure of a DIY power supply.&lt;/p&gt;

&lt;p&gt;I bought an Ender-3-Max. One of the many mods that I have chosen to do is install and run an Octoprint server on a Raspberry PI 3B+ ; If you are into 3D Printing this is a definite upgrade/mod you want to do - it will pay dividends within days. See &lt;a href=&quot;https://octoprint.org/&quot;&gt;Octoprint Site&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;The point of this post is a bit different. Many (esp. low cost) printers when connected to a Raspberry PI suffer from a ‘backpower’ issues. That is, power to the motherboard / display on the printer if fed from RPi (in addition to the regular/proper power supply). This has potential to damage both the Pi as well as the printer.&lt;/p&gt;

&lt;p&gt;One way this manifests itself is through the high amount of “Resend”s that the RPi needs to do since the messages get garbled. I used to have as much as 10% or more resends - at some point, Octoprint issues warnings about this.&lt;/p&gt;

&lt;p&gt;I was hoping for a simple software fix of disabling USB power output from RPi - Alas, it looks like the support for addressing individual USB ports varies greatly between different Pi models. Folks have suggested all kinds of hardware solutions including ‘duct-taping’ the 5V power ping in the USB plug to powering the Raspberry from the power supply of the printer (this last idea does not solve the problem of backpowering - but instaead make sure the supply shared the same GND).&lt;/p&gt;

&lt;p&gt;After many tries, what worked for me were two changes:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Cut the Power and GND wires of a perfectly good USB cable and use it for connecting the RPi to the printer PLUS&lt;/li&gt;
  &lt;li&gt;If the USB cable has a metal shield (good ones do), connect the shielding back - you will see three solders in picture below.. red/white that are disconnected are the power and ground&lt;/li&gt;
  &lt;li&gt;Add a RFI Suppressor on the power cable feeding into the RPi&lt;/li&gt;
  &lt;li&gt;Just to be safe, run the power cable for the RPi about a foot away from the motherboard + display section of the printer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/octoprint_usb_wire.jpg&quot; alt=&quot;USB rewire&quot; /&gt;&lt;/p&gt;

&lt;p&gt;For what cables to cut in USB - See &lt;a href=&quot;https://en.wikipedia.org/wiki/USB&quot;&gt;Wikipedia&lt;/a&gt; - the pinout diagrams on the right of the page. Essentially, you need to keep the center two (D+/-) cables intact and cut the two that on the outer edges.&lt;/p&gt;

&lt;p&gt;Result: Voila - Almost no resends during even long prints…
&lt;img src=&quot;/images/octoprint-resend-screen.png&quot; alt=&quot;Low Resends&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Since the last month I have had the printer, I have made multiple mods that I will try to share my lessons from:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Installed a CRTouch Automatic Bed Level sensor&lt;/li&gt;
  &lt;li&gt;Upgraded the latest Marlin firmware (Steps are @ &lt;a href=&quot;https://github.com/p2c2e/Ender3Max-CRTouch&quot;&gt;GitHub&lt;/a&gt;) 
Will share more details on these experiments and more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Useful links:
&lt;a href=&quot;https://www.creality.com/goods-detail/creality-ender-3-max-3d-printer&quot;&gt;Ender 3 Max&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://octoprint.org/&quot;&gt;Octoprint&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;https://marlinfw.org/meta/download/&quot;&gt;Marlin&lt;/a&gt;&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/octoprint-resend/&quot;&gt;3D Printing : Octoprint woes&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on January 01, 2022.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[PITA - Pain in the Arms + Wrists, Fingers - RSI / Carpal Tunnel]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/pita/" />
  <id>https://www.diyd2.in/articles/pita</id>
  <published>2020-11-28T00:00:00+00:00</published>
  <updated>2020-11-28T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;If you are like me, you have been furiously (for whatever reason) typing away much of your life - resulting in pain in the arms, wrist or fingers (Think RSI and Carpal Tunnel etc.). Whether you are a programmer or a “busy” emailer, you will encounter this issue at some point.&lt;/p&gt;

&lt;p&gt;I have tried all remedies - addressing internal (hand, wrist posture, breaks) as well as external (standup desks, ‘ergonomic’ keyboards, mechanical long-travel keyboards, vertical/horizontal/handheld mice) etc. with limited success. This includes being one of the first testers of &lt;a href=&quot;https://twiddler.tekgear.com/&quot;&gt;Twiddler in late 90s&lt;/a&gt; and flirting with the &lt;a href=&quot;https://en.wikipedia.org/wiki/Dvorak_keyboard_layout&quot;&gt;Dvorak layout&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While posture and the like do help - if you are consistent/diligent, it is much easier to buy/install things than change behaviour :)&lt;/p&gt;

&lt;p&gt;One of the things I have considered is voice dictation software - this is suitable for typing plain English as well as handling most of the app/window management - but falls way short of what is needed for programming. There is also the social impact of being seen saying things like ‘var a colon bool equals …’ and so on.&lt;/p&gt;

&lt;p&gt;I shudder to think - if someone who is physically able - is finding working in a tech job so hard, how much harder it would be for someone who is visually, physically impaired..&lt;/p&gt;

&lt;p&gt;Anyways, one of the findings has been that I get forearm issues with use of mice (esp. if they are small for the hand). And I have taken some steps to avoid using them - and thus avoid movement of the hand b/w keyboards and mouse.&lt;/p&gt;

&lt;p&gt;If you are using a Mac AND you are a productivity fanatic / have ergonomics issues - you may want to consider the below tips.&lt;/p&gt;

&lt;p&gt;Master Shortcuts:
&lt;a href=&quot;https://shortcutworld.com/&quot;&gt;Shortcut World&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://blog.jetbrains.com/idea/2020/03/top-15-intellij-idea-shortcuts/&quot;&gt;Top Intellij Shortcuts&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;https://www.shortcutfoo.com/&quot;&gt;Shortcut Foo&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Useful software:&lt;br /&gt;
&lt;a href=&quot;https://rectangleapp.com/&quot;&gt;Rectangle&lt;/a&gt; - Keyboard friendly Window manager &lt;br /&gt;
&lt;a href=&quot;https://shortcatapp.com/&quot;&gt;Shortcat&lt;/a&gt; - Any visible input button / control on any app &lt;br /&gt;
&lt;a href=&quot;https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb?hl=en&quot;&gt;Vimium (Chrome)&lt;/a&gt; - using Vim like commands to navigate chrome webpages&lt;br /&gt;
&lt;a href=&quot;https://www.alfredapp.com/&quot;&gt;Alfred&lt;/a&gt; - spotlight replacement with broader search&lt;br /&gt;
&lt;a href=&quot;https://mediaatelier.com/CheatSheet/&quot;&gt;CheatSheet&lt;/a&gt; - Find out what keyboard shortcuts are available on any app by holding down Cmd for an extra sec…&lt;br /&gt;
And if you are user of &lt;a href=&quot;https://shortcutworld.com/IntelliJ-IDEA/mac/IntelliJ_Shortcuts&quot;&gt;IntelliJ IDE user&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;https://otter.ai/&quot;&gt;Otter Transcription&lt;/a&gt; - STT transcription app&lt;/p&gt;

&lt;p&gt;While these tips may not completely solve your PITA, I hope it makes some difference.&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/pita/&quot;&gt;PITA - Pain in the Arms + Wrists, Fingers - RSI / Carpal Tunnel&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on November 28, 2020.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Utility to convert between Freemind (.mm) and MindMeister (.mind) formats]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/freemind-mindmeister/" />
  <id>https://www.diyd2.in/articles/freemind-mindmeister</id>
  <published>2019-01-04T00:00:00+00:00</published>
  <updated>2019-01-04T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;I used to be a subscriber for &lt;a href=&quot;http://mindmeister.com&quot;&gt;MindMeister&lt;/a&gt; Pro (strongly recommend it, if you can afford it). In addition to the cloud storage part of it, the mindmaps look cleaner/slicker than what you would get in FreeMind + there is the Presentation Mode that I love.&lt;/p&gt;

&lt;p&gt;As I alluded earlier, I no longer subscribe to MindMeister. Which means, I am out of luck with the already created mind maps + my ability to edit/view mindmaps shared by others.&lt;/p&gt;

&lt;p&gt;The Free version of MindMeister still allows you to export to it’s own format (.mind)&lt;/p&gt;

&lt;p&gt;Yesterday, I wrote a small piece of GoLang code to convert bi-directionally between .mind &amp;lt;&amp;gt; .mm (&lt;a href=&quot;http://freemind.sourceforge.net/wiki/index.php/Main_Page&quot;&gt;Freemind&lt;/a&gt; format).&lt;/p&gt;

&lt;p&gt;Keep in mind:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;There is data loss during conversion. Only the raw mindmap details - relationships and the text move over&lt;/li&gt;
  &lt;li&gt;Embedded images, links to media etc. will be lost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Usage:&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;mind2mm -h 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(for help information)&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;mind2mm -in &amp;lt;filename.mind&amp;gt; -out &amp;lt;filename.mm&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(converts from .mind to .mm format)&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;mind2mm -j2m=false -in &amp;lt;filename.mm&amp;gt; -out &amp;lt;filename.mind&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(converts from .mm to .mind format)&lt;/p&gt;

&lt;p&gt;Code is &lt;a href=&quot;https://github.com/p2c2e/mindmeister-to-freemind&quot;&gt;in GitHub&lt;/a&gt;
Links to binaries:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/assets/files/mind2mm.exe&quot;&gt;Windows binary&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/assets/files/mind2mm&quot;&gt;MacOS Binary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/freemind-mindmeister/&quot;&gt;Utility to convert between Freemind (.mm) and MindMeister (.mind) formats&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on January 04, 2019.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[People insights using a Graph Database]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/graphdb-hr-analytics/" />
  <id>https://www.diyd2.in/blog/graphdb-hr-analytics</id>
  <published>2017-09-20T00:00:00+00:00</published>
  <updated>2017-09-20T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;

&lt;p&gt;As part of ongoing efforts towards learning (Sharpen the Saw!), I have been playing around with Graph Databases and Machine Learning
in the context of HR / People development.&lt;/p&gt;

&lt;p&gt;In case of Graph Databases, I picked Neo4J to do some experiments - partly because it is quite easy to setup, is free etc.&lt;/p&gt;

&lt;p&gt;Sources / types of data include:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;People records (Joining, Total Expr, Promotions, Titles, City)&lt;/li&gt;
  &lt;li&gt;Skill data (raw skills information, grouping, certifications, social endorsements)&lt;/li&gt;
  &lt;li&gt;Team data (name, members, skills required in general)&lt;/li&gt;
  &lt;li&gt;Performance data - ratings, feedback, coding behaviours&lt;/li&gt;
  &lt;li&gt;Internal Knowledge management / Expert Forums - to seek out skills&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;rough-schema&quot;&gt;Rough Schema&lt;/h1&gt;

&lt;p&gt;Here is roughly how the relationship are setup - for lack of a Schema.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/graph_schema.png?=250x&quot; alt=&quot;Rough Schema&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;the-interesting-part&quot;&gt;The Interesting part:&lt;/h1&gt;
&lt;p&gt;Obviously, I am doing this for the insights. Here are a some interesting questions I was able to answer:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Find all Junior managers managing teams remotely - they may need support to be successful&lt;/li&gt;
  &lt;li&gt;If a Person knows “X” Technology, what are technologies are they likely to knows&lt;/li&gt;
  &lt;li&gt;Which people know “X” technology, but are part of teams that don’t require that skill? Sub-optimal use&lt;/li&gt;
  &lt;li&gt;Find employees “similar” to a given person - This helps in mitigating key-person risk, succession planning&lt;/li&gt;
  &lt;li&gt;Find the “Best Fit” team for a given person&lt;/li&gt;
  &lt;li&gt;Given open-positions in the organization, who can be tapped internally? Job mobility.&lt;/li&gt;
  &lt;li&gt;What are some pre-requisites for a Certification?&lt;/li&gt;
  &lt;li&gt;If I want to work in Team X or for a particular function (say: business analysis), what certifications are useful?&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;is-this-really-easy-to-implement&quot;&gt;Is this really easy to implement?&lt;/h1&gt;

&lt;p&gt;If I can whip up some code to quickly answer these questions, why is it that larger organiztions are not using such approaches already?&lt;/p&gt;

&lt;p&gt;Answer is simple - This is not a technology problem. Getting quality data requires connecting disparate systems that hold useful information. And for the most part, they are unreliable and “point-in-time”.&lt;/p&gt;

&lt;p&gt;Sometimes, it is possible to infer information - For example: what skills are expected in a particular team? We could get this from the team management or infer from the most common skills in the team.&lt;/p&gt;

&lt;h1 id=&quot;some-ideas-for-implementation&quot;&gt;Some ideas for implementation&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Using internal and external social platforms to capture and validate skills and endorsements&lt;/li&gt;
  &lt;li&gt;Gamification to collect and cleanse data&lt;/li&gt;
  &lt;li&gt;Make these insights part and parcel of day to day team and individual activities, feedback sessions, internal mobility, hiring, learning etc.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/graphdb-hr-analytics/&quot;&gt;People insights using a Graph Database&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on September 20, 2017.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[CGIT web viewer for Git - Using Docker/Alpine/Lighttpd ]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/cgit-lighttpd-docker/" />
  <id>https://www.diyd2.in/blog/cgit-lighttpd-docker</id>
  <published>2016-08-08T00:00:00+00:00</published>
  <updated>2016-08-08T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;p&gt;When cloning and trying out public Git repos, I tend to keep them all under one root folder (git_public). While navigating and viewing files is a bit cumbersome, it is even more so if we want to view contents from different branches etc.&lt;/p&gt;

&lt;p&gt;I had earlier suggested and implemented cgit in one of my work stints (more than 5+ years back). Since it is a light-weight solution, I decided to try it again on my laptop.&lt;/p&gt;

&lt;p&gt;The code and the Docker image for this blog post illustrates a couple of things of technnical interest.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;How to create a lightweight image using Alpine as the base image&lt;/li&gt;
  &lt;li&gt;How to make docker images useful with minimal tinkering - by remapping ports. data-volumes and config files&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The entire repo is located on &lt;a href=&quot;https://github.com/p2c2e/docker-lighttpd-cgit&quot;&gt;github.com&lt;/a&gt;. The ready-to-use docker image is at &lt;a href=&quot;https://hub.docker.com/r/sudhan/lighttpd-cgit/&quot;&gt;Docker Hub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The usage instructions for the ‘sudhan/lighttpd-cgit’ image are available on the README. Try it out and let me know.&lt;/p&gt;

&lt;p&gt;Cgit repo is hosted on itself at &lt;a href=&quot;https://git.zx2c4.com/cgit/about/&quot;&gt;https://git.zx2c4.com/cgit/about/&lt;/a&gt;. It will give you a fair idea of what to expect.
&lt;img src=&quot;/images/Cgit Viewer Example.png&quot; alt=&quot;Cgit website&quot; /&gt;&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/cgit-lighttpd-docker/&quot;&gt;CGIT web viewer for Git - Using Docker/Alpine/Lighttpd &lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on August 08, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Userscripts in the browser]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/userscripts/" />
  <id>https://www.diyd2.in/blog/userscripts</id>
  <published>2016-07-29T00:00:00+00:00</published>
  <updated>2016-07-29T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;p&gt;Recently, someone asked me why and when I learnt Javascript. In fact, one of the things I have been using Javascript for a long time is something called ‘userscripts’. I realize that many folks still haven’t heard about this cool utility - hence this post.&lt;/p&gt;

&lt;h1 id=&quot;firefox-to-chrome---greasemonkey-to-tampermonkey&quot;&gt;Firefox to Chrome - GreaseMonkey to TamperMonkey&lt;/h1&gt;

&lt;p&gt;For the past few years, I have whole heartedly adopted Chrome as my main browser. Prior to that, I was a Firefox fanboy primarily due to the extensions.&lt;/p&gt;

&lt;p&gt;One particular extension that I used frequently was “&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/&quot;&gt;GreaseMonkey&lt;/a&gt;”. Until I found that an equivalent for that called &lt;a href=&quot;http://tampermonkey.net/&quot;&gt;TamperMonkey&lt;/a&gt; was available on Chrome, I was reluctant to switch-over.&lt;/p&gt;

&lt;p&gt;For those who have not heard of GreaseMonkey, it is addon that allows you to run your own Javascript code within the context of any page from the net. This allows you to modify the page contents and post/pre process to your heart’s content. There are thousands of free user contributed scripts available online. So, the question then is, why would anyone want to modify webpages that they normally browse.&lt;/p&gt;

&lt;p&gt;Here are 3 examples where I used GM scripts:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Generate QIF (Quicken Interchange Format) of my bank account statements&lt;/li&gt;
  &lt;li&gt;Enable sections of page / form-elements that are otherwise locked down&lt;/li&gt;
  &lt;li&gt;Add new informational links between sites.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I am sharing more details and code below for those who might want to learn more.&lt;/p&gt;

&lt;p&gt;NOTE: For those wanting to run some simple processing of webpages, the ideal solution would be ‘bookmarklets’.&lt;/p&gt;

&lt;p&gt;For the userscripts cited below, visit my &lt;a href=&quot;https://github.com/p2c2e/tampermonkey-scripts&quot;&gt;github.com repo here&lt;/a&gt;. The README in the repo allows you to install the scripts. You will need to have either GreaseMonkey or TamperMonkey depending on the browser you use. Users of other browsers: Sorry!&lt;/p&gt;

&lt;h1 id=&quot;qif-bank-details&quot;&gt;QIF bank details&lt;/h1&gt;

&lt;p&gt;The userscripts scrape the online banking page when we are visiting and adds a textarea to the bottom of the page with the QIF formatted details. This can be copied to a file and imported into a compatible accounting system.&lt;/p&gt;

&lt;p&gt;In my case, I used to use GnuCash for a long time. With multiple bank accounts and Credit card statements, this came in very handy. This use case was also the reason I started delving into jQuery.&lt;/p&gt;

&lt;p&gt;If you have accounts with ICICI or Standard Chartered, you can use the scripts in my github repo as-is.&lt;/p&gt;

&lt;h1 id=&quot;enhancing-pages-with-additional-information&quot;&gt;Enhancing pages with additional information&lt;/h1&gt;

&lt;p&gt;FlipKart is a popular Amazon alternative marketplace based in India. On occasion, the prices of books on Flipkart could be lower. When browsing through their bookstore, I invariably want to read the reviews and the price and Amazon.&lt;/p&gt;

&lt;p&gt;To allow this, I have a user script that scans the page for ISBN-like numbers and adds a link to Amazon website.
The code is available on github. For illustration, I am including the code below. It scans the page for 10 digit numbers that are present within specific elements (to avoid clobbering numbers in scripts etc). It then replaces each occurence with a link to the amazon search page with the given ISBN.&lt;/p&gt;

&lt;p&gt;You can install the script by clicking &lt;a href=&quot;https://github.com/p2c2e/tampermonkey-scripts/raw/master/LinkISBN.user.js&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-javascript 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;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&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;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;isbnRegex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\b([&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;0-9&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]{10,10})\b&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/ig&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;allowedParents&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;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;abbr&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;acronym&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;applet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;bdo&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;big&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;blockquote&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;caption&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;cite&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;del&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;dfn&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;dt&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;em&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;fieldset&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;font&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;h4&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;h5&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;h6&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;iframe&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ins&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;kdb&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;samp&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;small&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;strike&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;sup&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;td&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tt&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;xpath&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;//text()[(parent::&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;allowedParents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; or parent::&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&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;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;candidates&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;xpath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;XPathResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;UNORDERED_NODE_SNAPSHOT_TYPE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;amznPrefix&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;http://www.amazon.com/gp/search/ref=sr_adv_b/?field-isbn=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cand&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&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;nx&quot;&gt;cand&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;candidates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;snapshotItem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&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;p&quot;&gt;{&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;nx&quot;&gt;isbnRegex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;cand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nodeValue&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;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;span&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nodeValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

            &lt;span class=&quot;nx&quot;&gt;cand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;parentNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;replaceChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

            &lt;span class=&quot;nx&quot;&gt;isbnRegex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;lastIndex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;lastLastIndex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&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;nx&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;isbnRegex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;source&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;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createTextNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;substring&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;lastLastIndex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)));&lt;/span&gt;

                &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;amznPrefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createTextNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]));&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

                &lt;span class=&quot;nx&quot;&gt;lastLastIndex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;isbnRegex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;lastIndex&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;nx&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createTextNode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;substring&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;lastLastIndex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)));&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;normalize&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;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;&lt;a href=&quot;https://www.diyd2.in/blog/userscripts/&quot;&gt;Userscripts in the browser&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on July 29, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Technical Trading - Part 1 - Tools]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/trading-1/" />
  <id>https://www.diyd2.in/blog/trading-1</id>
  <published>2016-07-19T00:00:00+00:00</published>
  <updated>2016-07-19T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;p&gt;Due to the nature of my work, I haven’t been able to trade in the stock market much for the 5 years or so. I have been a long-term
investor and hence I did not mind holding on to the stocks from long back.&lt;/p&gt;

&lt;p&gt;Past month or two, I have started dabbling again in stocks - and this time, I decided to do a good measure of short-term
and even speculative/intraday trading. I am happy to say that I am in good profitable territory so far :)&lt;/p&gt;

&lt;h1 id=&quot;in-uncharted-waters&quot;&gt;In UnCharted Waters&lt;/h1&gt;

&lt;p&gt;After a fair bit of prodding from a friend, I decided to base my intra-day activities on Technical Analysis.
I am personally not fully convinced about the ‘logic’ behind many strategies relying solely on technical analysis.
I believe that Technical Charts tell a tale - though belatedly.&lt;/p&gt;

&lt;p&gt;Much of my technical analysis studies have been using freely available (online and offline) charting tools
in conjunction with tools available with the broker trading apps. Unfortunately, none of the free (and very few of the commercial tools) support back-testing strategies. Hence, I started evaluating commercial options.&lt;/p&gt;

&lt;p&gt;In this post, I will describe how to setup Amibroker, a popular (non-free) tool for charting and back-testing. It comes with it’s own Amibroker Function Language (AFL) for programming.&lt;/p&gt;

&lt;p&gt;I plan to document my experience in a series of posts following this one. Where applicable, I will share some code snippets and files as well.&lt;/p&gt;

&lt;h1 id=&quot;the-free-tools&quot;&gt;The Free Tools&lt;/h1&gt;

&lt;p&gt;For those who don’t want to be bothered with installing new software, you can try out the free tools listed here. Obviously, this list is by no means exhaustive.&lt;/p&gt;

&lt;h2 id=&quot;online-tools&quot;&gt;Online Tools&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://economictimes.indiatimes.com/markets&quot;&gt;Economic Times markets&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;site contains robust tools with plenty of indicators. Based on ChartIQ (see apps section)&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://economictimes.indiatimes.com/markets/technical-charts?symbol=NSE%2520INDEX&amp;amp;exchange=NSE&amp;amp;entity=index&amp;amp;periodicity=day&quot;&gt;Here is a link to a sample NSE INDEX chart&lt;/a&gt; with typical
indicators that I like to use&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.moneycontrol.com/technicals/&quot;&gt;MoneyControl&lt;/a&gt; - More than just charting, the site has good news, articles etc.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://techpaisa.com/stock/nifty/&quot;&gt;Techpaisa&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;The site has some good screeners as well as verbal summary of different indicators&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.bigpaisa.com/custom-technical-screener?date=1&amp;amp;exchange=1&amp;amp;stock_index=2&amp;amp;newhigh=All&amp;amp;priceaction=All&amp;amp;gapper=All&amp;amp;close=All&amp;amp;volume=All&amp;amp;volumeaction=All&amp;amp;avgvolumeaction=All&amp;amp;pricecrossover=All&amp;amp;emacrossover=All&amp;amp;macd=All&amp;amp;adx10=All&amp;amp;adx14=All&amp;amp;di10=All&amp;amp;di14=All&amp;amp;psar=All&amp;amp;rsi=3&amp;amp;bband=1&amp;amp;candlestick_patterns_3=All&amp;amp;candlestick_patterns_4=All&amp;amp;candlestick_patterns_2=All&amp;amp;candlestick_patterns_1=All&amp;amp;candlestick_patterns=All&quot;&gt;Bigpaisa&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Above link gives us the list of stocks that are probably overbought + crossing the Upper Bollinger Band&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.marketcalls.in/charts&quot;&gt;MarketCalls&lt;/a&gt; Excellent site in general. You will inevitably end here if decide to get into AFL programming&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;apps&quot;&gt;Apps&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://itunes.apple.com/in/app/technician-real-time-stock/id570491345?mt=8&quot;&gt;Technician / ChartIQ&lt;/a&gt; Free App, easy to use.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://itunes.apple.com/us/app/chartiq-practice-trading-simulator/id517702104?mt=8&quot;&gt;ChartIQ PTS&lt;/a&gt; Also from ChartIQ. This is a very cool app that allows us to practice our TA skills. Well worth the install.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;amibroker---getting-started&quot;&gt;Amibroker - Getting started&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://www.amibroker.com/&quot;&gt;Amibroker&lt;/a&gt; has been around for quite a while. And it has a solid reputation amongst Technicians. It does
cost quite a bit, especially since many of the features are available in the free tools provided by most
brokerage firms. That said, speed and back-testing were two reasons I decided to try this one out.&lt;/p&gt;

&lt;p&gt;You can follow along with some help from files I have &lt;a href=&quot;https://github.com/p2c2e/amibroker-playground&quot;&gt;uploaded to github&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Download the trial version of the app from &lt;a href=&quot;http://www.amibroker.com/download.html&quot;&gt;here&lt;/a&gt;. The trial version does not allow
saving of any data, though settings seem to be preserved.&lt;/li&gt;
  &lt;li&gt;Getting your data
Since I don’t want to spend money for data providers right away &lt;em&gt;and&lt;/em&gt; I am interested in EOD data alone,
I decided to configure Amibroker as follows:
    &lt;ol&gt;
      &lt;li&gt;Create a New Database for our EOD data using File &amp;gt; New &amp;gt; Database
        &lt;ul&gt;
          &lt;li&gt;Choose a suitable new directory (create one) and ensure the settings are ‘local database’ and end-of-day data.&lt;/li&gt;
          &lt;li&gt;Get some data from NSE.
As usual, I used my scripts to download the bhavcopy data from nseindia.com. Since the file contains more than just the equities segment, I filtered out all the ‘non-EQ’ rows from the files.
Keep all these files in a different temporary folder (NOTE: NOT the one you created from within Amibroker). I have uploaded a zip file with csv data in github.&lt;/li&gt;
          &lt;li&gt;Edit the import.types file found at “C:\Program Files\AmiBroker\Formats”
Add a new line as follows:&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ol&gt;

    &lt;p&gt;BhavCopy format (&lt;em&gt;.csv)|&lt;/em&gt;.csv|BhavCopy.format&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;Copy the new BhavCopy.format file from here into “C:\Program Files\AmiBroker\Formats” folder&lt;/li&gt;
      &lt;li&gt;From within Amibroker, Choose File &amp;gt; Import ASCII and select and import all the csv files from Step-3
 &lt;img src=&quot;/images/Import_ASCII.png?=200x&quot; alt=&quot;Import ASCII screen with the CSV files&quot; /&gt;&lt;/li&gt;
      &lt;li&gt;After a few seconds, you will see have all the symbols loaded into Amibroker. You can search and load a specific ticker for charting using F3
 &lt;img src=&quot;/images/amibroker_screen.png?=250x&quot; alt=&quot;Sample screen with default charts for Bajaj Auto&quot; /&gt;&lt;/li&gt;
      &lt;li&gt;Since the trial version of Amibroker does not support saving of the database, you will need to redo the “Import ASCII” step everytime you launch the app.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/trading-1/&quot;&gt;Technical Trading - Part 1 - Tools&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on July 19, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Interesting Stories in Computer Science]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/paradoxes/" />
  <id>https://www.diyd2.in/blog/paradoxes</id>
  <published>2016-07-19T00:00:00+00:00</published>
  <updated>2016-07-19T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;p&gt;When joining college, I decided to do Physics as my Masters major due to my love of Astronomy and Astrophysics. Something about gazing at
the stars and putting ourselves in perspective was always thrilling. It is another matter that the ‘course work’ was not all blue skies!&lt;/p&gt;

&lt;p&gt;Similarly, the reason for taking an active interest in Computer Science was manifold - the instant gratification of seeing your program
obey your instructions, the level playing field that it provides regardless of the discipline of study etc. One of the arcane reasons
is the abundance of myths, anecdotes, pseudo “laws” surrounding computer science. I am listing a few below that you might like:&lt;/p&gt;

&lt;h1 id=&quot;buridans-principle-or-more-fondly-dilemma-of-buridans-ass&quot;&gt;Buridan’s Principle or more fondly, Dilemma of &lt;a href=&quot;https://en.wikipedia.org/wiki/Buridan%27s_ass&quot;&gt;Buridan’s Ass&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The story is about a Donkey that dies of starvation because he is equidistant from both hay and water and cannot make up his mind which
way to go. Though originally used as an analogy by Aristotle, it has since been used to illustrate similar non-sensical and seemingly
intractable problems. See the Wiki link for more history.&lt;/p&gt;

&lt;p&gt;In the context of computers, Leslie Lamport published a report in 1984. &lt;a href=&quot;http://research.microsoft.com/en-us/um/people/lamport/pubs/buridan.pdf&quot;&gt;You can find it here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From my understanding of it, it talks about decision systems taking more than expected time due to ‘indecision points’, where two equally
possible states are making it hard to decide, requiring a need for arbiters.
It has been variously extended to explain thread dead-locks due to resource contention etc.&lt;/p&gt;

&lt;h1 id=&quot;pigeon-hole-principle&quot;&gt;Pigeon hole principle&lt;/h1&gt;
&lt;p&gt;This seemingly innocuous principle states that : If there are say 10 pigeons and 9 pigeon holes (each fits only one pigeon), there will always be 1 pigeon left-over after the pigeons are accommodated.&lt;/p&gt;

&lt;p&gt;This is a principle from Discrete Mathematics. Though not directly relatable to computer science, it is very useful
in proving algorithm bounds, limits on solutions (‘no more than X satisfy some criteria’) etc.&lt;/p&gt;

&lt;p&gt;In the realm of computers, some examples of use include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Sudokus where we can solve some boxes by ruling out others&lt;/li&gt;
  &lt;li&gt;Bounds on compression algorithms etc. : No lossless compression algorithm can reduce the sizes of all n-bit files, because there are 2^n different n-bit files and only 2^(n−1) possible files of length less than n bits. Or in other words, there is always a few files for which any lossless algorithm will likely result in the new file with same / larger size!&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;paxos-another-leslie-lamport-paper-from-microsoft-research&quot;&gt;Paxos (another Leslie Lamport paper from Microsoft Research)&lt;/h1&gt;

&lt;p&gt;Rarely have I come across research papers that read like novellas. “&lt;a href=&quot;http://research.microsoft.com/en-us/um/people/lamport/pubs/lamport-paxos.pdf&quot;&gt;The Part Time Parliament&lt;/a&gt;” is refreshing to read.
Highly recommended for leisure reading as well.&lt;/p&gt;

&lt;p&gt;The Paxos problem and the corresponding algorithm address challenges in building fault-tolerant distributed systems. The story is about legislators that are free to come / leave the parliament at will. But, for some work to get done, there is a minimum quorum required. It is also applicable for work distribution, election of a node for some work etc.&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/paradoxes/&quot;&gt;Interesting Stories in Computer Science&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on July 19, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Minikube - a quick alternative to testing k8s services]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/minikube/" />
  <id>https://www.diyd2.in/blog/minikube</id>
  <published>2016-07-07T00:00:00+00:00</published>
  <updated>2016-07-07T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;p&gt;One of the problems with testing out cloud platforms is, we need to be connected to the net all the time. So, sooner or later, we learn to test using solutions like Vagrant as the cluster provider. Even starting a 2 node cluster takes quite a bit of time using this approach.&lt;/p&gt;

&lt;p&gt;Good news is the recent addition of ‘Minikube’ - a single node cluster to test out simple services, pods and replication controllers. Note that any attempts to scale the services will probably result in ‘fit failure on node (minikubevm): PodFitsHostPorts’ errors due to it being a ‘single-node cluster’.&lt;/p&gt;

&lt;p&gt;The minikube code is on &lt;a href=&quot;https://github.com/kubernetes/minikubehttps://github.com/kubernetes/minikube&quot;&gt;github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Getting started guide for kubernetes is &lt;a href=&quot;http://kubernetes.io/docs/getting-started-guides/minikube/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Definitely worth a try.&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/minikube/&quot;&gt;Minikube - a quick alternative to testing k8s services&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on July 07, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[National Stock Exchange - India chart using ggplot in R]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/nse-india-stock-chart-in-r/" />
  <id>https://www.diyd2.in/articles/nse-india-stock-chart-in-r</id>
  <published>2016-04-29T00:00:00+00:00</published>
  <updated>2016-04-29T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#general-file-format&quot; id=&quot;markdown-toc-general-file-format&quot;&gt;General file format&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#getting-from-daily-stock-details-to-a-timeseries-not-literally&quot; id=&quot;markdown-toc-getting-from-daily-stock-details-to-a-timeseries-not-literally&quot;&gt;Getting from daily stock details to a timeseries (not literally)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-charting-part&quot; id=&quot;markdown-toc-the-charting-part&quot;&gt;The charting part&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As part of my efforts at learning R, I stumbled upon the idea of charting Indian stocks listed on NSE. I already had some piece of code to get the stock information - written as part of pricing my portfolio account within GNUCash. GNUCash has the facility to write our own Perl modules to access different financial data.&lt;/p&gt;

&lt;p&gt;In the case of National Stock Exchange, the historical market data (Open/Close/H/L/Volume etc.) are available freely on their website at &lt;a href=&quot;http://www.nseindia.com/&quot;&gt;www.nseindia.com&lt;/a&gt;. These market figures are called ‘bhav’ (value in Hindi) and the files themselves were called bhavcopy.&lt;/p&gt;

&lt;p&gt;NOTE: If you are interested in following long, I have a few sample csv files and a R-Markdown file with the code on &lt;a href=&quot;https://github.com/p2c2e/nse-bhav-in-r&quot;&gt;github.com&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;general-file-format&quot;&gt;General file format&lt;/h1&gt;

&lt;p&gt;Each file for a given date is available as a zipped csv file. The zip file contain csv files named like cm23OCT2015bhav.csv&lt;/p&gt;

&lt;p&gt;As an example, the contents are like below:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csv&quot; data-lang=&quot;csv&quot;&gt;SYMBOL,SERIES,OPEN,HIGH,LOW,CLOSE,LAST,PREVCLOSE,TOTTRDQTY,TOTTRDVAL,TIMESTAMP,TOTALTRADES,ISIN,
20MICRONS,EQ,34.55,38.3,33.95,35.6,35.55,34.55,27313,965326.6,31-MAR-2015,307,INE144J01027,
3IINFOTECH,EQ,5.95,6.05,5.7,5.8,5.8,5.8,2621260,15490167.55,31-MAR-2015,3119,INE748C01020,
3MINDIA,EQ,8001.05,8150,7900.05,7935.3,7925.9,8034.2,178,1421292.4,31-MAR-2015,83,INE470A01017,
8KMILES,EQ,730,744,702,711.55,708.45,722,71042,51481004.25,31-MAR-2015,3552,INE650K01013,
A2ZINFRA,EQ,15.5,15.9,15.2,15.3,15.4,15.25,156555,2424829,31-MAR-2015,602,INE619I01012,
AARTIDRUGS,EQ,658,665,630,649.95,649.9,654.5,41964,27394744.15,31-MAR-2015,2049,INE767A01016,
AARTIIND,EQ,352,364,343.95,350.8,346.9,349.2,116529,41496490.55,31-MAR-2015,3368,INE769A01020,
AARVEEDEN,EQ,40.8,41.95,40.8,41.1,41.05,40.75,721,29945,31-MAR-2015,18,INE273D01019,&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;getting-from-daily-stock-details-to-a-timeseries-not-literally&quot;&gt;Getting from daily stock details to a timeseries (not literally)&lt;/h1&gt;

&lt;p&gt;To keep things simple, I wrote a small function to load ‘all’ csv files in a given directory and merging the contents into one huge dataframe. The function is shown below:&lt;/p&gt;

&lt;p&gt;I keep this and similar utility functions in ~/.Rprofile&lt;/p&gt;

&lt;p&gt;While checking the TIMESTAMP column in the frame, it is clear that it was loaded as plain text and needs to be converted to a Date. You can check the class of each column using&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csv&quot; data-lang=&quot;csv&quot;&gt;sapply(dataframe, class)&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;the-charting-part&quot;&gt;The charting part&lt;/h1&gt;

&lt;p&gt;Since this is a huge table with all the stock information, I have to filter out the ones corresponding to a given symbol and the plot it.
In my case, I chose to use INFY stock (Infosys Technologies) and entire 2015 data.&lt;/p&gt;

&lt;p&gt;Plotting a line chart shows a surprise drop in share price around mid-year. Turns out that was during a 1:1 bonus stock issue. Atleast, it is not due to a bug in my code!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/INFY_line.png&quot; alt=&quot;INFY - Line Chart&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To make things a bit more glamorous, I tried to plot the candle-chart. This turns out to be a bit more harder.
We need to know the net-trend (up/down) to decide the color. In addition, we need the decide the rectangle for the candle body and then the length of the wicks. Much of the code is to figure out those numbers.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/INFY_candle.png&quot; alt=&quot;INFY - Candle Chart&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Let me know what you think. I am sure it is easier to get this view / info by visiting some popular charting sites. But then, I wouldnt be learning R :)&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/nse-india-stock-chart-in-r/&quot;&gt;National Stock Exchange - India chart using ggplot in R&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on April 29, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Go... Play the game of Life (and Death)]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/go-game/" />
  <id>https://www.diyd2.in/articles/go-game</id>
  <published>2016-03-13T00:00:00+00:00</published>
  <updated>2016-03-13T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;On Saturday, March-12th 2016, history was made when AlphaGo/DeepMind won the series against Lee Sedol 3-0 in a best-of-five series. After losing the 3 straight game, Lee Sedol apologized with characteristic humility for not doing better and meeting the expectations of his fans. After-all, Go is a serious business, especially in China, Japan and Korea where players dedicate themselves from childhood to mastering the game.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/go-game-in-progress.png&quot; alt=&quot;Go Game in Progress&quot; /&gt;&lt;/p&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#interesting-facts-about-go&quot; id=&quot;markdown-toc-interesting-facts-about-go&quot;&gt;Interesting facts about Go&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#parallels-in-my-view-with-real-life&quot; id=&quot;markdown-toc-parallels-in-my-view-with-real-life&quot;&gt;Parallels (in my view) with real-life&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#some-resources-to-get-you-started&quot; id=&quot;markdown-toc-some-resources-to-get-you-started&quot;&gt;Some resources to get you started&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal of this post is to two-fold:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Intrigue You with facts about Go (and maybe you will start playing and enjoying it)&lt;/li&gt;
  &lt;li&gt;Draw parallels between the game and real-life - I find this fascinating.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Go is a two player, turn-based game, played on a grid of 19x19 points. One of the players plays black while the other white. This is where the similarities
with Chess ends.&lt;/p&gt;

&lt;p&gt;It is amazing how few (relatively speaking) know about the game of Go. Variously referred to as Baduk, Weiqi and Go, it is probably one of the oldest 
strategic games. When I listed “Go” as one of my hobbies in 
an introduction questionnaire in my company, the proof reader assumed I had forgotten to complete some sentence! This game deserves better.&lt;/p&gt;

&lt;h1 id=&quot;interesting-facts-about-go&quot;&gt;Interesting facts about Go&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Simplicity: There is only one ‘type’ of game piece and less than a dozen core rules.&lt;/li&gt;
  &lt;li&gt;Complexity: Ironic that I am listing this after “simplicity”. It has been repeatedly mentioned how the number of possible positions in Go are 10^171 whereas the number of atoms in the known Universe is just 10^80. Even the best/fastest computers cannot fully analyze and comprehend what the game will evolve into.&lt;/li&gt;
  &lt;li&gt;Popularity: Though not apparent, there are supposedly close to 60 Million players world-wide, though mostly in China, Korea and Japan. The game makes an appearance regularly in movies and other forums. For e.g. in the movie “A Beautiful Mind”&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;parallels-in-my-view-with-real-life&quot;&gt;Parallels (in my view) with real-life&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Very few rules to learn&lt;/li&gt;
  &lt;li&gt;Success or Failure is not instantaneous. No King to capture/kill.&lt;/li&gt;
  &lt;li&gt;Intuition and Gut feeling: There are many things happening at the same time. Your moves are most likely driven by intuition rather than hard-logic.&lt;/li&gt;
  &lt;li&gt;You win some battles and you lose some. But, you can still hope to win the War (overall game)&lt;/li&gt;
  &lt;li&gt;Patience and perseverance - Games can go on for hours and in earlier days even days - though today’s professional games are time limited.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/images/go-game-picture.jpg&quot; alt=&quot;Japanese Painting depicting two Go players&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;some-resources-to-get-you-started&quot;&gt;Some resources to get you started&lt;/h1&gt;
&lt;p&gt;Watch the tournaments (recordings and the rest of it): &lt;a href=&quot;https://www.youtube.com/channel/UCP7jMXSY2xbc3KCAE0MHQ-A&quot;&gt;DeepMind channel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Websites: &lt;a href=&quot;http://senseis.xmp.net/&quot;&gt;Sensei’s Library&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Go_(game)&quot;&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;iOS app: &lt;a href=&quot;https://itunes.apple.com/us/app/smartgo-player/id314506629?mt=8&quot;&gt;SmartGo Player&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generic Game engine: &lt;a href=&quot;https://www.gnu.org/software/gnugo/download.html&quot;&gt;GnuGO&lt;/a&gt; - Available on many platforms
There are many UI apps that use this engine on different platforms&lt;/p&gt;

&lt;p&gt;Online gaming:
&lt;a href=&quot;http://www.kiseido.com/index.htm&quot;&gt;Kiseido Game Server&lt;/a&gt; 
&lt;a href=&quot;http://pandanet-igs.com/communities/pandanet&quot;&gt;PandaNet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you Enjoy this as much as I do!&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/go-game/&quot;&gt;Go... Play the game of Life (and Death)&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on March 13, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Minimal Docker Jetty - Mysql application]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/docker-jetty-mysql/" />
  <id>https://www.diyd2.in/articles/docker-jetty-mysql</id>
  <published>2016-02-14T00:00:00+00:00</published>
  <updated>2016-02-14T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;I personally find it much easier to learn new things by looking at a working system; as opposed to getting a new system up-and-running. Probably a hang-over from my childhood days dismantling anything that works…&lt;/p&gt;

&lt;p&gt;In this article, I am sharing the quickest way to get a small jsp page connect to mysql instance, both running on docker containers.&lt;/p&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#assumptions&quot; id=&quot;markdown-toc-assumptions&quot;&gt;Assumptions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#get-the-code&quot; id=&quot;markdown-toc-get-the-code&quot;&gt;Get the code&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#setting-up-the-mysql-server-container-instance&quot; id=&quot;markdown-toc-setting-up-the-mysql-server-container-instance&quot;&gt;Setting up the MySQL server container instance&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#setting-up-the-jetty-side&quot; id=&quot;markdown-toc-setting-up-the-jetty-side&quot;&gt;Setting up the jetty side&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#deploy-an-app-and-test-jetty--mysql-connectivity&quot; id=&quot;markdown-toc-deploy-an-app-and-test-jetty--mysql-connectivity&quot;&gt;Deploy an app and test jetty / MySQL connectivity&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-does-the-jetty-server-container-access-the-mysql-server-container&quot; id=&quot;markdown-toc-how-does-the-jetty-server-container-access-the-mysql-server-container&quot;&gt;How does the Jetty server container access the MySQL server container?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#accomplishing-the-container-wiring-through-docker-compose&quot; id=&quot;markdown-toc-accomplishing-the-container-wiring-through-docker-compose&quot;&gt;Accomplishing the container wiring through ‘docker-compose’&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#newbie-tips&quot; id=&quot;markdown-toc-newbie-tips&quot;&gt;Newbie tips&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h1&gt;
&lt;p&gt;For purposes of this article, I am assuming:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;To avoid any confusion, I recommend that you should NOT have mysql (server/client) or jetty on the local system. And local ports 8080, 443, 3306 are available for use.&lt;/li&gt;
  &lt;li&gt;Java, ant build system is available&lt;/li&gt;
  &lt;li&gt;Docker engine is available. In case of Ubuntu, you can &lt;a href=&quot;https://docs.docker.com/engine/installation/linux/ubuntulinux/&quot;&gt;find more information here&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;git is installed&lt;/li&gt;
  &lt;li&gt;You understand that the code is meant to be simple (clear-text passwords, poor error-handling). Do not use it for anything beyond learning …&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;get-the-code&quot;&gt;Get the code&lt;/h1&gt;

&lt;p&gt;Pull the latest bare minimum code (jars, Dockerfiles, jsp) from github&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;git clone https://github.com/p2c2e/min-docker-jetty-mysql.git&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;min-docker-jetty-mysql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ensure there is no other local instance of mysql (port 3306 should be free)
Note that there is no data folder at this point&lt;/p&gt;

&lt;h1 id=&quot;setting-up-the-mysql-server-container-instance&quot;&gt;Setting up the MySQL server container instance&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker pull mysql
./bin/dmysqlserver.sh &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Check if the server is up and running&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker ps &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;mysql-server
docker logs mysql-server&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Look for “mysqld : ready for connections”&lt;/p&gt;

&lt;p&gt;At this point, not only is the mysql-server up, it should also have a new database called ‘TestDB’. You can verify that by running below commands:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;./bin/dmysql.sh &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In the MySQL client prompt, run:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;show databases&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The TestDB database was created for you because there is a ‘init’ sql file in the ./startup folder. The mysql-server container executes all the files in that folder as part of initialization.&lt;/p&gt;

&lt;h1 id=&quot;setting-up-the-jetty-side&quot;&gt;Setting up the jetty side&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker pull jetty&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now launch jetty using the shell/batch script&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;./bin/djetty.sh&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Verify jetty is up by checking the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker ps &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;jetty-server&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Verify if the site is up and running by visiting &lt;a href=&quot;http://localhost:8080/&quot;&gt;the Jetty Root&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since there is no ROOT.war distributed, there should be a context listing page with no apps deployed. Jetty is checking for webapps in the ./webapps folder&lt;/p&gt;

&lt;h1 id=&quot;deploy-an-app-and-test-jetty--mysql-connectivity&quot;&gt;Deploy an app and test jetty / MySQL connectivity&lt;/h1&gt;

&lt;p&gt;Now deploy a bare-minimum webpp consisting of a index.jsp connecting to a DB and dropping/creating/listing the table row count.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;ant &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This should create and copy over a ‘war’ file to the ./webapps/ folder&lt;/p&gt;

&lt;p&gt;Check if the war was successfully deployed using :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker logs jetty-server&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now visit: &lt;a href=&quot;http://localhost:8080/java-mysql-1.0/&quot;&gt;http://localhost:8080/java-mysql-1.0/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It should display a page like below:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/simple-jetty-page.png&quot; alt=&quot;Minimal Jetty MySQL Docker Homepage&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;how-does-the-jetty-server-container-access-the-mysql-server-container&quot;&gt;How does the Jetty server container access the MySQL server container?&lt;/h1&gt;

&lt;p&gt;Legacy Links -&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The primary way by which containers expose their services is through ports. The docker engine can expose pre-defined ports automaticaly or we can do that explicitly using the -p to:from options&lt;/li&gt;
  &lt;li&gt;For one container to talk to another, the simplest way is to a) expose the mysqld port to the outside world and b) share the mysql servers IP to the jetty-server. This is done via –link option (see the ./bin/djetty.sh)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Though the wiring of the two containers were done in the shell scripts, we can ‘compose’ the two containers together so that the dependencies are clearer.&lt;/p&gt;

&lt;h1 id=&quot;accomplishing-the-container-wiring-through-docker-compose&quot;&gt;Accomplishing the container wiring through ‘docker-compose’&lt;/h1&gt;

&lt;p&gt;First verify that docker-compose is installed properly. Use &lt;a href=&quot;https://docs.docker.com/compose/install/&quot;&gt;this link&lt;/a&gt; to get you set-up.&lt;/p&gt;

&lt;p&gt;Let us kill the existing containers before we can try out the docker-compose version of the application.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker &lt;span class=&quot;nb&quot;&gt;kill &lt;/span&gt;jetty-server mysql-server 
docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;docker ps &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;exited&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ensure you are in the root of the clone repository (root directory should contain the docker-compose.yml file). Now, run the docker-compose version of the application using:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker-compose up &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If you used the non-daemon version, you will clearly see when the system is ready to accept requests. You can shutdown the servers by Ctrl-D.&lt;/p&gt;

&lt;p&gt;Alternatively (if you want to run everything as a daemon)…&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker-compose up &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In this case, you would need to shutdown the servers using&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker-compose down&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After about 20 seconds, you will be able to visit &lt;a href=&quot;http://localhost:8080/java-mysql-1.0/&quot;&gt;http://localhost:8080/java-mysql-1.0/&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;newbie-tips&quot;&gt;Newbie tips&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;When building images using ‘docker build’, there are many occasions where there are intermediate images that might be left behind. Use ‘docker rmi &lt;imageid&gt;&apos; to remove them&lt;/imageid&gt;&lt;/li&gt;
  &lt;li&gt;When you build and tag a new image - if there is an image already exists with that name, it gets untagged. Importantly, the image still remains in the cache. You will need to manually remove them&lt;/li&gt;
  &lt;li&gt;Containers that have exited (normally or due to getting killed), continue to remain on disk. If not cleaned up, they continue to take up significant space. Remove them using ‘docker rm &lt;containerid&gt;&apos;&lt;/containerid&gt;&lt;/li&gt;
  &lt;li&gt;alias the following command to make things easier. The command removes any containers that are lingering after they have exited:&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;docker ps &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;exited&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;You can copy-over/run the d*.sh scripts in the repo and use it for generically&lt;br /&gt;
 If you run the dmysqlserver.sh from any directory, it initializes a brand new instance of mysql and stores the data in the ./data folder. It also creates a ‘startup’ folder where we can store any bootstrap / db-dumps to initialize the database
 Using the djetty.sh from any directory, it creates / uses the webapps/ subfolder to deploy apps
 Due to port and container name conflicts, you can only run one instance of jetty, mysql-server at any one time&lt;/li&gt;
&lt;/ol&gt;


    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/docker-jetty-mysql/&quot;&gt;Minimal Docker Jetty - Mysql application&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on February 14, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[A decent developer laptop running on Linux]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/blog/dell-install-linux-mint/" />
  <id>https://www.diyd2.in/blog/dell-install-linux-mint</id>
  <published>2016-02-09T00:00:00+00:00</published>
  <updated>2016-02-09T00:00:00+00:00</updated>
  <author>
    <name>Sudhan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudhan@diyd2.in</email>
  </author>
  <content type="html">
    &lt;p&gt;After a &lt;em&gt;long&lt;/em&gt; hiatus, I recently decided to follow developments on the technology front. Most of my recent work had not given me either the time nor the need to do this.&lt;/p&gt;

&lt;p&gt;For starters, I figured I would not want to mess with our family’s shared desktop and buy myself a new laptop (What better excuse could I come up with?).&lt;/p&gt;

&lt;p&gt;Choice of laptops:&lt;/p&gt;

&lt;h2 id=&quot;basic-specifications&quot;&gt;Basic specifications&lt;/h2&gt;
&lt;p&gt;i5+, 8G+, 500G+ - without Windows preferably (to keep the costs low). No point paying for Windows and then installing Linux anyway.&lt;/p&gt;

&lt;h2 id=&quot;brands-considered&quot;&gt;Brands considered&lt;/h2&gt;

&lt;p&gt;Dell, Asus, Lenovo, Acer&lt;/p&gt;

&lt;p&gt;These brands were listed on ease of availability in India/locally, cost, non-windows options and finally my prioir experience with them.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Acer&lt;/b&gt;: We could get an i7 at the cost of i5 from the rest of the brands. Cons: Lack of availability and pre-sales response - imagine what would happen after getting stuck with them!&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Lenovo&lt;/b&gt;: Pros: I still think of them as ThinkPad. Cons: Cost and the feedback on build quality + service in recent times&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Asus&lt;/b&gt;: Pros: Hardware and in some cases, the build Cons: Availability in India + servicing (my most recent laptop was an Asus bought in US and I had issues trying to upgrde the RAM)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Dell&lt;/b&gt;: Pros: Prior exp (my desktop is 8 yrs old - it was bleeding edge when I bought it. Now, other thn the motherboard everything is changed. It still keeps chugging on…) Cons: Cost - Compared to Acers of the world. Though they technically have Ubuntu versions in the line-up, none are available easily (really sad to see this).&lt;/p&gt;

&lt;h2 id=&quot;decision&quot;&gt;Decision:&lt;/h2&gt;

&lt;p&gt;Went with the Dell due to sweet spot of price, availability and prior experience.
Dell 5558 - i5 - 15in - 1TB - non-touch/non-HD version w/ Windows 8.1&lt;/p&gt;

&lt;h2 id=&quot;prepping-the-machine&quot;&gt;Prepping the machine:&lt;/h2&gt;

&lt;p&gt;Since I had paid the Windows tax, I might as well ensure that I can use it if required. So, first step was to complete the install and activate 8.1&lt;/p&gt;

&lt;p&gt;Next: Upgrade to Windows 10 while the free-upgrade offer exists
I wanted to note down the Serial details in case I needed to reinstall. Here are some tips:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The serials listed by various tools might all be slightly different&lt;/em&gt;. Not sure what is the ‘correct’ one. I made note of everything once in 8.1 and then once again in Window 10.&lt;/p&gt;

&lt;p&gt;From what I understand once Windows 10 is activted using “Digital Entitlement”, we can re-install Window 10 anytime in the future by just clicking “Skip” in the serial screen. Once the system boots up, it will connect to MS servers and reactivate based on some set of system parameters.&lt;/p&gt;

&lt;h2 id=&quot;choice-of-linux-flavors&quot;&gt;Choice of Linux flavors:&lt;/h2&gt;

&lt;p&gt;I have always been partial to Fedora - I have been using some flavor of RedHat on my personal machines since 1998 (when the my other main option of interest was Slackware - that will give you some perspective)&lt;/p&gt;

&lt;p&gt;Finally decided to go with one of either Fedora or Linux Mint. While Fedora would have given me bleeding edge stuff and helped me with tinkering, I want to tke this opp to learn something new. With yum given way to dnf, I might as well learn apt-get/aptitude!
Linux Mint Cinnamon was the choice&lt;/p&gt;

&lt;h2 id=&quot;install-mint-on-5558&quot;&gt;Install Mint on 5558&lt;/h2&gt;

&lt;p&gt;After a flawless install (custom layout), I found the machine was not booting up! Something about not being able to find a bootable partition. After racking my brain about active/primry partition, layout etc. I decided to peek into the BIOS settings.&lt;/p&gt;

&lt;p&gt;Dell ships with Windows w/ UEFI enabled. I suspected that some kind of security check was causing the issues. 
Changed BIOS settings as followws and installed / booted without issues:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Disable UEFI and enable Legacy Mode for accessing the disks&lt;/li&gt;
  &lt;li&gt;Ubuntu that ships on Dell supposedy has tweaks to get things working. So, it is not same as the one we would download from the ubuntu/mint sites.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Back in the days - I remember grappling nVidia (free/non-free) driver issues all the time. I had to have custom patches to get things to work. Pleasantly surprised to see the screen at full resolution off the bat!&lt;/p&gt;

&lt;h2 id=&quot;teething-issues&quot;&gt;Teething issues:&lt;/h2&gt;
&lt;p&gt;I have been noticing that ‘suspend’ seems to work, ‘resume’ works only occasionally. On resumption, the screen displays the last view (whether it was the lock screen or desktop) and there is no cursor, any screen refreshes.&lt;/p&gt;

&lt;p&gt;Based on a hunch and some googling, I have since changed the &lt;em&gt;Administration -&amp;gt; Login Window -&amp;gt; Options -&amp;gt; Default Session&lt;/em&gt; to have “Cinnamon (Software Rendering)”. I have since not seen issues for the past couple of resumes.
IF you try the last tip, you should logout and log-back into the system after the change.&lt;/p&gt;

&lt;h2 id=&quot;cool-parts&quot;&gt;Cool parts:&lt;/h2&gt;
&lt;p&gt;Around 2006 is when I last had a primary Linux machine. THere was lot of discussion on &lt;a href=&quot;https://en.wikipedia.org/wiki/Cgroups&quot;&gt;cgroups&lt;/a&gt; at the time when I was with qemu, kvm and virtual box. I did not quite understand what the use case was.
Glad to note that I was wrong. The whole &lt;a href=&quot;http://www.docker.com&quot;&gt;docker&lt;/a&gt; ecosystem would not be possible without cgroups. Will jot down notes on how to set things in layman terms&lt;/p&gt;

&lt;h2 id=&quot;finding-your-windows-serial-number&quot;&gt;Finding your Windows serial number:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;If you have a Certified Windows sticker on your machine, you are good to go1&lt;/li&gt;
  &lt;li&gt;If not, you may want to try one of these tools: Speccy, Belarc Advisor ; Many of the tools “feel” shady.&lt;/li&gt;
  &lt;li&gt;There are some ‘generic’ serial numbers that are floating around. Not sure what they are meant for.&lt;/li&gt;
  &lt;li&gt;My serial number reported by tools before/after the Windows 10 upgrade were different.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/blog/dell-install-linux-mint/&quot;&gt;A decent developer laptop running on Linux&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on February 09, 2016.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[There is magic in the files...]]></title>
  <link rel="alternate" type="text/html" href="https://www.diyd2.in/articles/magic-in-files/" />
  <id>https://www.diyd2.in/articles/magic-in-files</id>
  <published>2016-02-01T00:00:00+00:00</published>
  <updated>2016-02-01T00:00:00+00:00</updated>
  <author>
    <name>Sudharsan Rangarajan</name>
    <uri>https://www.diyd2.in</uri>
    <email>sudharsan.rangarajan@gmail.com</email>
  </author>
  <content type="html">
    &lt;p&gt;Back in olden days, we used to use a command called “file” in *nix and related systems. While the upstart OS2, DOS and Windows operating systems encouraged file extensions by design, *nix always let the user decide what to name each file. A file name ending with “.exe” need not mean it can/cannot be executed. Given the more heterogenous environments and files being copied back-n-forth with total disregard, we had to check whether the file is really what it seems to be… To take a trivial case, text files copied back and forth between DOS and *nix…&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;$ file README
README: ASCII Text

$ file OTHERFILE.TXT
OTHERFILE.TXT: ASCII text, with CRLF line terminators
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The file command was magical. It could not only tell you a file contains text, but whether it is shell script of a particular type etc. If it was an executable/binary, how it was linked, what target architecture it was meant for etc.&lt;/p&gt;

&lt;p&gt;What made the command so smart? Turns out that among other things it uses the concept of “Magic Numbers”. This is a frequently used technique that involves adding a header section to a file or block to identify the type of the file/data. By reading the first few bytes, if not a bit more, we can guess what a file is meant to contain.&lt;/p&gt;

&lt;p&gt;So, imagine my surprise when reading up on “BitCoin” and the underlying block-chains. As the name suggests, BitCoin and other crypto currencies that rely on distributed ledger mechanisms, use ‘blocks’ of data. And lo and behold, the first 4 bytes of each block is always “0xD9B4BEF9”. Does that mean anything?&lt;/p&gt;

&lt;p&gt;In the early days, the magic numbers were selected by geeks to represent something meaningful to them. Here is a sampling …&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;BitCoin Block&lt;/td&gt;
      &lt;td&gt;0xD9 B4 BE F9&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Java .class files&lt;/td&gt;
      &lt;td&gt;0xCA FE BA BE&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;NxtSTEP - Motorola&lt;/td&gt;
      &lt;td&gt;0xFE ED FA CE&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;NxtSTEP - Intel&lt;/td&gt;
      &lt;td&gt;0xCA FE BA BE (Nxt Obj-C bears similarity to Java - and common folks)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;PalmOS calendar arch&lt;/td&gt;
      &lt;td&gt;0xBE BA FE CA (oddly reverse ordering of Java)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Hist. Uninitialized mem&lt;/td&gt;
      &lt;td&gt;0xDE AD BE EF&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;iOS Crash files&lt;/td&gt;
      &lt;td&gt;0xDE AD FA 11&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Nintendo ‘Normal’ boot code&lt;/td&gt;
      &lt;td&gt;0xD1 5E A5 E*&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Even now-a-days, I occasionlly have to check the leading part of some files when I encounter a corrupt PDF (maybe it is a zip/rar or a postscript file…).&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.diyd2.in/articles/magic-in-files/&quot;&gt;There is magic in the files...&lt;/a&gt; was originally published by Sudhan at &lt;a href=&quot;https://www.diyd2.in&quot;&gt;Pithy Notes&lt;/a&gt; on February 01, 2016.&lt;/p&gt;
  </content>
</entry>

</feed>