Emacs for Writers : Part 1

Youtube Video of Jay Dixit's presentation.


I came across this video (I think) from Sacha Chua's weekly Emacs news (But I am not certain, may be it was a tweet.) Personally, I prefer to refer to the presentation (PPT/PDF) that goes with such video, assuming it contains written notes that viewer can refer to later.

But I could not find the notes/presentation that go along with this. Since the video contains a lot of gems, I decided to make my own notes (and in process help some other emacs-noobs like myself)

Please note that there are lot of "visuals", so it is useful to watch the video. At least the second half hour is "demo" mode, so there couldn't be any notes.

Comment your articles

The way programmers write code comments, which are meant for themselves (or other developers) Similarly, writers also need to comment their articles (Who knew) These are Notes-for-self, but do not show up in the exported format. Trick is simple, start a line with a #, and the line is considered as as comment. Check the source org file of this article and see a comment right below this sentence.

Off course for multi-line comment, one can use well known #+BEGIN_COMMENT and #+END_COMMENT blocks.

If you want to comment out an entire subtree, use C-c ;. Such subtree is not exported.

workflowy meets scrivener

Jay opens up with how he liked both these products separately, but wanted combination of these

Outline to the left, contents on the right controlled by keyboard as much as possible without using mouse a lot

He showed two "tricks" (I couldn't hear them properly, but here is how I was able to get such a functionality)

Split the window

Split the window to the right (assuming you started with single window) In spacemacs you can do this by SPC w V

Now you have the same buffer in two windows. You edit in one windows, but the changes are visible in other window immediately.

That is not exactly what you (or Jay) want. He wanted outline in one (left) window and contents in the right. So we ..

Separate the buffers

Go the window on your left, and clone-indirect-buffer-other-window Now you can see the outline in the left pane, and edit in the right pane. The left pane can remain "folded". It doesn't update unless you add a node.

Continue to Part 2 (Coming soon)

Using ForeignKey in Abstract Base Class (SQLAlchemy)

I was creating an abstract base class containing FK, like this :

class MyBase(Base):
  name = Column(String(30))
  fk1 = Column(Integer, ForeignKey('table1.id'))

but kept getting the error :

Columns with foreign keys to other columns must be declared as @declared_attr callables on declarative mixin classes.

Reading thru the docs was not helpful because the example used for @declared_attr is somewhat different

this SO answer helped.

Essentially use it as :

class MyBase(Base):
  name = Column(String(30))

  def fk1(cls):
      return Column(Integer, ForeignKey('table1.id'))

KeePass on the Web (KeeWeb)

Why is this interesting to me ?

Since LastPass was acquired. I switched to Dashlane, which seems good, but there is this nagging feeling that Dashlane might stop the free version, or something.

I had used KeePass long time ago. But the Problem is "syncing" KeePass Web solves (in theory) this problem by supporting Dropbox syncing "out of the box". All I really need is backup.

If you are interested, you can download KeeWeb here

Stumbling block

I installed the desktop app, which is based on electron shell. (Other apps using electron are Atom editor, and Visual Studio Code)

On OSX, I was not allowed to open the app, since the app is not signed. This is clearly mentioned on the site, that the author doesn't plan to spend money on this (yet)

But do not despair.

OSX allowed to open this via the following method:

  1. Find the app in the finder
  2. Ctrl-Click to open
  3. You see a message, click OK
  4. Now onwards the app will open without error


Finally, I didn't switch, mainly because importing the existing database was not easy. Creator of KeeWeb mentioned that he may support import in later release. He suggested using native KeePass to do the One time import This kinda defeats the purpose, but I was OK to try it, since it is only one time.

Unfortunately, installing native KeePass on OSX is not trivial.

KeePass is essentially a "Windows" program. Supported on OSX and Linux via mono.

I could have tried this route, if I were planning to use KeePass native as a long term/permanent solution. Since that is not the case, it is too much an effort, hence decided against it.

How to define Primary Composite Key in SQLAlchemy

When using fully declared table metadata,use the primary_key=True flag on those columns:

class Dummy(Base):
    __tablename__ = "dummy"

    pk1 = Column(Integer, primary_key=True)
    pk2 = Column(String, primary_key=True)

This will create the following table (in postgres)

testdb=> \d dummy;
                              Table "public.dummy"
Column |       Type        |                      Modifiers
pk1    | integer           | not null default nextval('dummy_pk1_seq'::regclass)
pk2    | character varying | not null
   "dummy_pkey" PRIMARY KEY, btree (pk1, pk2)

See SQLAlchemy documentation

Be Unreasonable

I came across this video by Robin Sharma (The author of great books like "The Monk who sold his Ferrari" and "The leader without title")

It starts with the following quote :

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.

  • George Bernard Shaw

Robin goes on to suggest that you install 3 habits during the next 90 days, that set the tone for the next 12 months, so that 2016 can be your greatest year (Rather than a repeat of the last year)

  1. Protect your mindset
    • Make sure you are surrounded by positive people
    • Don't watch TV
  2. Prepare the night before
    • Plan for the next day.
    • Write top three lessons learned that day
    • Write three positive things that happened today
  3. Focus on single biggest opportunity

A Person who chases two rabbits, catches neither

  • Confucius

Note: I have been writing the Five Minute Journal last 6 months. It covers the second point very well.

How did I "recover" from broken spacemacs ?

OK, it wasn't really that bad, I could have easily "lived" with it.


While thinking of creating API documentation for my project, I first considered Markdown syntax (Later I selected ReST, since sphinx supports it better.)

I also wanted to keep the documentation in .org files. I was planning to export these .org files to .md , which I can commit to git. .md other users can edit, .org is very emacs specific. It is unfair to assume others will be able to maintain them comfortably


At first, I didn't get "export to markdown" option at all, under SPC-m-e I looked around, and tinkered with my spacemacs configuration. I am sure I did several trial and errors Finally something worked.

I wanted "export to simple markdown", all I got was export to GFM (GitHub Flavoured Markdown) I didn't like the <div> tags in the markdown

Now I didn't know how to "rollback" I commented/removed (what seemed like) relevant config changes, but it didn't help

Solution (?)

I turned to Time machine, and restored .emacs.d from few days ago. The restore erred out midway

Now when I started emacs, I got vanilla emacs Hence the need to "fresh install"

I first renamed existing .emacs.d to .emacs.d.broken and existing .spacemacs to .spacemacs.broken

Then git clone d it from spacemacs repo

After spacemacs was setup (Takes really long time for the git clone to finish) I compared .spacemacs file with the old one, and ported my changes over.


  1. Turns out Sublime and Vim support Org mode too. See https://twitter.com/mandarvaze/status/681171214103085057
  2. This post written in .org format. Thanks to Org-mode plugin for Nikola
  3. Somehow using footnotes syntax of Org mode didn't export well in this Theme.

Maze Vs Labyrinth

I had always considered them to be same (like many people do) but realized that they are different in important ways.

In the Book "A Whole New Mind", Daniel Pink explains the difference between the two.

  • Maze engage the left brain (Logical) as a puzzle to solve, while Labyrinth is a "moving Meditation" and thus "frees" the right brain.
  • Objective of the maze is to escape, while Labyrinth are spiral walking course
  • There are about 4000 public and private labyrinths in the United States
  • labyrinths are showing up in hospitals and medical facilities

If you are interested to know more, this page has quite detailed explanation of the differences.

Rust, Python Requests Library and Freakonomics

May 21, 2015

  • Rust Language (The changelog)
    • safety without garbage collector
    • single ownership model (so cleanup is easy)
    • Transfer of ownership (permanent) or lending (temp)
    • Owner is supposed to cleanup
    • Better C++
    • C++ hackers can already do this stuff, but rust enables new/web programmers to systems programming
    • cargo (package management) - all (ex) C++ programmers (who now use rust) now like this
    • cargo - learn from other package managers like ruby, npm etc.

May 22, 2015

  • Talk python to me - Requests library
    • Kenneth talks about “Hallway” track being most helpful (for him?) in pycon.
    • python3 usage spiked significantly since last django release used it as default
    • writing all documentation/tutorials to use python3 could help adoption
    • Kenneth is happy with python2 personally
    • Kenneth says : “Who are the python3 users that bash everyone on HN/reddit - I don’t meet them at conferences, These are “new kids” who started directly with python3"
    • Personal favourite projects :

May 23-25, 2015

  • James Altucher talks to Steve Dubner (Freakonomics)
    • They talk about latest Freakonomics book, which is compilation of various previously published blog posts
    • about 120+ articles curated from 8500 posts
    • Dubner did something similar when he was at the New York times 100th anniv.
      • dubner met his wife (photographer) during this assignment
    • Cost of fearing strangers
      • Most of the damage (attack) done by people you know
      • A guy who used to dress as a santa killed his family (and himself)
      • A muslim family was taken off the flight for talking about “safest seats on the plane"
    • Levitt’s article about suggestions for terrorists created quite a stir on the first (?) day when freakonomics blog appeared on NYTimes site ;)
    • terrorists don’t need ideas from others, but people worry
    • Stories are important, just the data/results may be boring
      • The Bible is most read book, but only 15% people can remember all the 10 commandments

Freakonomics, Curl and Tim Ferris

May 14, 2015

  • James Altucher Show (Tim Ferriss experiment)
    • When division is shutdown, new management/owner will not take any decisions.
    • If the decision results into “loss”, new management will be blamed for shutting down the project/division.
    • If the decision results into “profit”, old management gets the credit
    • So leave it in a limbo :(

May 15, 2015

  • How think like a Child (Freakonomics Radio)
    • Children spot “magic” easily
    • They are always making theories
    • Adults have a pattern to learning based on what we already know (This may be good or bad)
    • “Play” means do something without thinking of “utility” (Difficult for adults)
  • Why we laugh - TED Talk
    • Humans aren’t the only mammals that laugh (Apes, Rats laugh too)
    • We can easily detect Fake laugh Vs real laugh
    • Children can’t easily detect Fake laugh, we learn (that) till we are mid-30s early 40s
    • As we grow, we need social context to laugh (less contagious)

May 16, 2015

  • 17 years with curl
    • Name change :
      • Initially httpget but then supported FTP protocol, so changed to urlget, but it supported POST as well, so changed to curl
    • Program structure change :
      • Originally one program, then split into libcurl - which other programs can use.
      • curl binary also uses the library.
      • php was (one of the?) first third party program to use libcurl
    • Version controls used : CVS, git
      • skipped using svn for the project but Daniel was a core contributor for svn
    • Hosting change :
      • Originally on sourceforge, now on github
    • License changed :
      • Originally GPL (default). Too restrictive, changed to MPL (not compatible w/ GPL?) Finally MIT - most liberal license

Go on Mobile, Pencil Pushups and Flask Sentinel

April 22, 2015

  • The changelog podcast episode 148 : The state of Go in 2015
    • Go on Mobile - Seems like cool stuff
    • Andrew talks about move from Google code to Github(He isn't too happy)
      • Google code was going away (Internal projects had to move first)
      • He explains why Gerrit is better than github "pull request" workflow
      • Github doesn't support CLA
      • When I worked on OpenStack for a short amount of time, I had signed CLA and used Gerrit. Openstack used git (as opposed to mercurial) but not github.
  • Raymond Hettinger's Presentation in Pycon 2015 : Beyond PEP8
    • He uses live code instead of slides, which is good but it means we must consume the 1 hour long video. Sometimes slidedecks are better (Not always)
    • He ran out of time (Due to lunch break, at that)

April 23, 2015

  • GraphQL (https://changelog.com/149/)
  • After being disappointed that users must consume 1+ hour youtube video, I looked and came across Raymond hettinger slidedeck It is not same, but lot of ideas from 2015 presentations are already covered here.
    • python3 has @ignored exception context manager
    • slidedeck has reference implementation for python2

April 24, 2015

  • Ask Altucher podcast: Changing Your Lifestyle Can Change Your Life Episode 239
    • pencil pushups"
    • eye exercises
    • ginger+lemon for better digestion
      • This is known to all the Indians since childhood. My grandma who lived till the age past 90, used to use this whenever she had upset stomach
  • Talk python to me Episode 1
    • EVE framework
      • I had read about it some time ago. At that time it was very restrictive in a sense that it supported only MongoDB. Now it supports other databases via SQLAlchemy
    • Flask sentinel
      • Token based access control for Flask application
      • When I tried Token based access control for the Flask app earlier, it was not trivial. You can read about it here So I think this might be worth looking into.
Google Analytics Alternative