Unwavering Focus

I came across Dandapani when tim ferriss mentioned him in one of his podcasts. Then I looked up his website (very easy to remember URL, from tim's podcast, at least for someone like myself of Indian origin)

On his blog, there is a youtube video of his TED Talk from TEDxReno called "Unwavering Focus". I try to summarize the points here.

  • We are told to concentrate (from childhood) yet no one teaches us how.
  • We are distracted all the time (13-16 hours x 7 days a week) So we become good at "being distracted" (Whatever you practice, makes you good at that)
  • Are "internet and smartphones" distractors ? (yes and no)
    • "Monks with Macs" (and iPhones)
      • When he became monk, he had to give up everything. All "new" monks are given certain attire, set of beads and a "MacBook Pro"
      • "Is it ok for monks to use email ?" "Off course, as long as there are no attachments" :)
  • Awareness and Mind
    • Awareness is like "glowing orb" that moves
    • Mind is vast plain with various area like anger, jealousy, food, sex, science, art.
    • Wherever the "orb" goes, that part of illuminated, (and you become aware)
    • Art of awareness is to keep the "ball of light/orb" on one thing.
    • "Mind" doesn't wander, awareness does.
  • Concentration means "Keep the awareness on one thing for an extended period of time"
  • Look for opportunities in daily life
  • In order to teach children to concentrate, parents need to learn it first.

Getting started with go

[This post was originally written in March 2016, but published only later]

This is not a "How" to get started with Go post. This post chronicles my attempts, and reasons to get started with go.


I am fascinated with the hugo static site generator tool. I am in a process to migrate one of my blogs to hugo (But it is too soon.)

While reading thru the hugo documentation, I came across hugo-gallery. But unlike hugo itself, hugo-gallery is available only as source code. [1]

Since I have been considering (but putting off) installing go locally, this seemed like a good excuse to do so.

Installing via brew

Official document does not mention/recommend brew install, but brew is such a nice tool, I almost do not want to install any mac software without it.

Since I chose the path different from what is officially recommended, there was an opportunity to "learn" I wanted to install go tour locally, but it won't work. But I wasn't the first or only one to have this problem. Also it is usually "shoot first, read documentation" attitude that causes the problem.

All I had to do was set the GOPATH variable. (and go get the gotour.)

BTW, one more deviation from the documentation, the way to invoke is not go tool tour as the official document recommends. (But after so many years, I know that usually documents grow "out dated" after a while.)

Anyway, I was able to run the go tour as ./gotour after that.

[1] Update: hugo-gallery is now available as a binary release here

Retain the contents of emacs *scratch* buffer across restarts

I have used many editors (chiefly vim) and IDEs (pycharm) My colleagues use sublime text so I gave it a try, but always switched back to either pycharm for python coding, and vim for everything else (until I came across spacemacs, and now that is my main editor for last few months. I still use vim occasionally, on remote server etc.)

Back to sublime text ..

One of the thing I liked about sublime text was that I could just open a new window, start typing and even after I quit/restart sublime, my contents would be there.

So even log after I stopped using sublime for coding, I continued using it mainly for this purpose alone.

I have several such "windows" from few months ago, and I found what I wanted there (Since I started using space/emacs, I have started using org-capture for such things, but I still find myself using sublime for creating persistent scratch buffers)

It never occurred to me to look for similar functionality in emacs (kinda highlights my noob status, since an experienced emacs user knows that nothing is impossible with emacs) and then I came across this reddit thread.


Installing it is a simple matter of adding it to dotspacemacs-additional-packages, and then SPC f e R

At first, I got file-error since package list was stale. Restarting spacemacs fixed that (turns out I could have easily done M-x package-refresh-contents)

Then I had to add (persistent-scratch-setup-default) to my dotspacemacs/user-config, and that's it.

I now have scratch buffer that will retain its contents across restarts.

parting thoughts

I still think this is not same as what sublime text does.

The reddit thread also mentions open-junk-file (which is exactly my use case, since I don't care about the filename or its location, just the contents) but open-junk-file creates files using timestamp.

Plus, using single scratch buffer is not same as ability to use as many scratch buffers as needed. I guess I can always have one giant *scratch* buffer, divided using org-mode headings

But then why not simply use org-capture ? That is what it is meant for, isn't it ?

Oh, well …

Sending email via emacs

I have been meaning to setup emacs for email in general, but due to the size of my existing mailbox, setting up offlineimap (or mbsync for that matter) is a daunting task. I am sure I'll do that one day. But for now, I wanted to start small, or as Sacha Chua says "baby steps"

So I decided to setup sending an email first, and then slowly move to using programs like mu4e to read/search my emails.

I referenced this page to get started. But it did not work as-is.

I had to add a line (see below) to get SMTP server using ssl Also, the line starting smtpmail-auth-credentials didn't work.

Luckily, after adding the ssl line, I got interactive prompt asking for username and password. This was saved into a ~/.authinfo file. unfortunately the password is stored in plain-text. I know there are ways to encrypt it using gpg, just that I haven't explored it yet.

Here is the relevant part of my config

(setq smtpmail-smtp-server "smtp.example.com")
(setq smtpmail-stream-type  'ssl)
(setq smtpmail-smtp-service 465)
(setq send-mail-function 'smtpmail-send-it)
(setq message-send-mail-function 'smtpmail-send-it)

This was the minimal setup without using any additional tools. Everything came built-in.


✔ DONE Fix the default "From" prompt.

CLOSED: 2016-03-20

This was achieved using the following configuration.

(setq user-full-name "Mandar Vaze")
(setq smtpmail-local-domain "example.com")
(setq user-mail-address (concat "mandar.vaze@" smtpmail-local-domain))

✔ DONE encrypt the password

CLOSED: 2016-03-21

emacs has ability to auto encrypt and decrypt files with .gpg extension. EasyPG is part of Emacs 23+, but did not work for me on OSX.

Found a solution here.

brew install gpg

I did not have to fiddle with PATH though.

I already had a .authinfo created by gnus I just saved it as .authinfo.gpg. I followed the prompts and was easily able to encrypt the file on the disk.

When I sent an email, I was asked for the passphrase (as expected) that was all.

✔ DONE Read emails via emacs

CLOSED: 2016-03-21

This deserves a separate post in itself. There is so much explore/learn (for me) and using gnus in itself may take up good part of it, cause it is unlike other email clients I have used.

But quick summary of what worked for me:

;; http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-using-gnus-to.html
(setq gnus-select-method '(nnimap "domain"
			  (nnimap-address "imap.example.com")
			  (nnimap-server-port 993)
			  (nnimap-stream ssl)))

I also had to add a new entry in the .authinfo.gpg for imap.example.com because the machine name is different as well as the port number.

The very first attempt failed, because I failed to notice that I was being asked a passphrase for my .authinfo.gpg file. But one that is provided, it worked well.

Off course, I did not have anything unread, so I was presented with a empty screen. So I went to the web version of the email, and marked a few threads as unread. and now I was presented with INBOX

Navigating is a bit awkward. But to be honest, at this point I was happy that emails showed up.

It will be a while before I can start "using" emacs as a mail client. There is so much to do :

  • offline IMAP
  • setting up better mail client like mu4e
  • integrating with bbdb for contacts integration
  • ability to read HTML emails

(ya)snippet for header in org-mode blog post

I don't know how much sense does the title make. But I didn't know how else to express, plus (I) didn't want to wait to figure out the title

As mentioned earlier, I am using nikola for this blog, and posts are in org-mode as much as possible.

For every post in nikola, I need to add meta data information like title, slug, date etc.

Initially I created first one by hand, and copy pasted from older posts.

Then I decided to automate it using powerful yasnippet

Creating a new snippet was easy I just invoked M-x yas-new-snippet and followed the prompts.

I created it only for org-mode though. I think it will be useful for posts in ReST as well (I just need to remove #+BEGIN_COMMENT and +END_COMMENT

Here is the (a simple) snippet file :

# -*- mode: snippet -*-
# name: begin and end comment block for blog posts in org mode
# key: bc
# --

.. title:
.. slug:
.. date:
.. category: misc
.. tags:
.. type: text

emacs stored the file at ~/.emacs.d/private/snippets/org-mode/blog_headers

Inline Code block in ReST

I have been using org-mode for my blog posts lately. It provides all the mark-up I need. Some days ago, I needed to cross-link to one of my posts. nikola (the python based static site generator used to power this blog) has a option just for that. (Refer to this)

I tried to be smart, and used equivalent org notation, but it didn't work.

So I converted that post to ReST. (Aside: ReST is lot more powerful especially with reStructuredText extensions. But I may not need these, most of the times, and org mode suffices.)

Now here is the problem.

I am used to org notation (inside of two equal-to signs) at times. org-nikola plugin converts it to <code> HTML block, which I like. But nikola itself converts equivalent ``this`` notation in ReST to pre. HTML <code> blocks look better (due to syntax highlighting) than pre blocks.

ReST has :code: notation, used for multi-line code block, but I couldn't (till now) find a way to use code block inline.

But finally I found this

TL;DR: use something like this: :code:`some text`

writing about ReST in orgmode is confusing. I ended up using ReST style of links instead of org style

Flesch kincaid grade level score : 2.334

Flesch kincaid reading ease score : 93.79

writegood mode for emacs

Today I came across writegood-mode for emacs, on one of the reddit thread. I am not a writer, at least not in "writer of the prose" sense, nor is English my native language, so I thought it would help me improve my English/writing skills.

Installing it in spacemacs was as easy as adding writegood-mode in dotspacemacs-additional-packages and running SPC f e R

In order to test it, I used it on one of my older prose blog post. (I thought it made sense to run it on a non-technical writeup, although I plan to use it everywhere, including this post itself)

writegood-mode pointed out some usages of passive voice (I was going to initially write this as "a few passive voice usage were pointed out", but quickly re-thought the sentence to use active voice, and avoid weasel word few)

At first, I didn't know what the squiggly lines meant. There was no apparent help provided. this page provided generic help. As an engineer, I used the "elimination logic". I knew none of these were weasel words, nor were they duplicates, so the errors must be about passive voice.

Honestly, I didn't know what it meant (or how to fix it)

Quick googling turned up this useful page

I have not (yet) set a global key to invoke writegood-mode. I am using M-x writegood-mode for now.

writegood-mode provides two more features, besides pointing out errors. There is a grade, and reading ease. When invoked, they both reported a number. Without comparative data, I have no idea whether my scores are good/average or just bad. here is some information about the F-K scores.

Scores for this writeup :

Flesch Kincaid grade level score : 4.09 Flesch Kincaid reading ease score : 84.83

Edit: 2016-03-14:

Added url for the Flesch Kincaid scores

Mutation Tracking in SQLAlchemy

Mutation means change.

Mutation Tracking means ability to detect the change.

The term seemed very complex (to me) at first. But it isn't.

SQLAlchemy ORM depends on the ability to detect the change in the object so that it can commit it to the DB on session.commit()

It is important to understand that if the change is not detected, calling session.commit() won't help. (I think) It internally checks to see if anything is changed. If not, it is (equivalent of) a no-op.

This becomes very important, if you come across bugs like "why is my JSON field changes not reflected in the DB".

For simple data types, the change detection is built-in. But for data types like ARRAY or JSON which contain a lot of data within themselves, such a tracking is not built-in.

If you want the ORM to detect such changes, you will to tell it. The changed (and other) events must be propagated manually.

In case of JSON, one can use MutableDict to do that. For ARRAY look at this .

Read the official SQLAlchemy documentation about Mutation Tracking here.

Emacs for Writers : Part 2

Refer to Part 1 here

Here are various other tricks Jay talks about, in his presentation.


Makes pretty bullets in org-mode. spacemacs already comes with this package. No additional work needed. Off course, you can customize the bullets to your liking, but I am pretty happy with the defaults.

notmuch for emails

Jay doesn't show notmuch but makes a comment about it. I looked at it, but I think my use case is bit different. I would rather have something like mutt , than something just searches and outsources sending and receiving to other programs or libraries.


This is like a autohotkey program some of you might have used. As a writer, Jay uses it extensively. He shows his abbrevs_defs file, which is huge. Jay used abbreviation bq to insert #+BEGIN_QUOTE and +END_QUOTE pair. may be it was a snippet (yasnippet ??) I couldn't make out.


Jay says that if someone wants to move away from MS Word (he is very unhappy with MS Word as a "writer's tool" (Hence the need to combine workflowy with scrivener, refer to previous Part 1) he would recommend this program to them rather than uphill learning curve of Emacs. I looked at it, but the program doesn't seem to be updated in at least couple of years. Plus there is a deft mode in emacs, which I think is similar

fountain mode

Jay shows a screen play. Apparently fountain-mode is a standard (text-based) file format, understood by others tools as well.

poetry mode

counts number of syllables in the line, shows words rhyme. with the word under cursor I was blown away to see the demo.

Setting the title of the window

Out of the box, my Emacs window has a boring title like Emacs instead of the filename (Turns out I had not noticed that.) Seems like there is a variable for "fix" that.

I couldn't catch the details from the video, so I asked him about it, and he was kind enough to respond

buffer stack

Shows the demo of how to move thru the relevant buffers/file. He has configured it such that buffers like *Messages* are not part of the stack

config files in org-mode

So that they can be well documented/shared. This can be done via org-babel, although being a beginner, I am yet to do that myself.

Closing remarks

I want to Thank Jay for this presentation, and thoughtbot for sharing this video with us.

It is inspiring to see a "non programmer" use emacs so "ably". As a non-programmer, he brings in a unique point of view.

It is also comforting (for a emacs beginner like myself) that if a non-programmer can make so many customizations, solely depending on the kindness of the emacs community at large, then deciding to learn emacs after being a vim user for 20 years ain't bad choice.

Why did you speak ?

I came across this parable in the book, I am currently reading. It is a Marathi translation of Biography of J. P. Vaswani "Guru of None, Disciple of All"


In one of the incarnation, Buddha was a prince, who did not speak. Everyone assumed he "could" not speak.

Years passed.

Once the prince was traveling thru the forest. He heard two birds "talk". A hunter heard the sound, and immediately killed one of the birds.

The prince asked the bird "Why did you speak ?"

Hunter told everyone that he heard the prince talk.

Already sad King became angry, and decided to "hang" the hunter to his death.

Prince asked the Hunter "Why did you speak ?"

Everyone heard him, and the king released the hunter.


If the bird had not spoken, he would be safe. and the same goes for the hunter too.

Dada Vaswani goes on to explain that we "talk a lot". We should divert the energy (that we waste) inside.

edit: 2016-03-10 Thu 01:01

After using writegood mode, converted passive voice to active voice.

Google Analytics Alternative