Browsed by
Month: August 2018

Will Write for Money

Will Write for Money

You may have noticed a new button over there on the right. Looks like a mug with a heart on it. Looks kinda like this:

Yeah, that’s the one. what’s that lil’ guy doing there?

Here’s the thing: back in the day I ran ads on my blogs. They never brought in all that much money, usually just enough to keep the lights on. But I never liked it. I’m not some fancy auteur who thinks I’m “too good” for advertising; I just don’t like feel of ads, they’re a distraction from the content.

So here’s my new solution: a tip jar. If you like this site, and you have a few bucks to spare, I’d love it if you drop me a tip.

ko-fi is great because every cent you drop in there goes directly to me. no middle men. I like that! 😆 Right now I’m playing with “ko-fi Gold” which costs me $6/month, but if three people every month chip in I’m still in good shape.

And Here’s What You Get

But this isn’t just a one-way street. When you drop me a tip in ko-fi you can make a little comment along with that tip. Why not make it an idea for a story or an essay? If it’s family friendly I’ll write it up and post it to ko-fi as a (timed) subscriber-only post.

Beyond being family friendly I really don’t have any limits. If you want me to write about you waking up as a bear in a new version of the Metamorphosis I’m game. If you like one of my stories or series and want more of that you can just yell “MOAR ANGEL LIZ” in the comments and I’ll get the hint. And you’ll have access to an Angel Liz story that won’t be on the site for at least 30 days.

Like I said, this is an experiment. Running these blogs isn’t exactly breaking the bank, but it’s not free either. I can’t wait to see what kind of weird stuff you wonderful people want me to write.

Automation for Authors

Automation for Authors

Or: Writing with Python

I really love Scrivener. I may have mentioned this before. And I really love Leanpub. And for the most part, they work really well together. But there’s always room for improvement. And tonight I have added yet another layer of sophistication to my workflow. I’m pretty excited to share this with you.

The Workflow

Here’s a high level overview of how this all works:

  1. Write in Scrivener
  2. Export text files from Scrivener
  3. Check text files into a git repository shared with Leanpub
  4. Tell Leanpub to publish the book

Scrivener: Writing and Exporting

In Scrivener, you write all your text in little individual sections that you can move around at will. This is incredibly handy. If you decide the chapter on configurations should be in Part I: Beginning instead of Part II: Refinement you just drag it to the appropriate folder and you’re good to go. You can then export all these snippets as text files, and Scrivener will keep your file structure intact, like so:

A list of topics in Scrivener

Which turns into this on export:

The exported files from Scrivener

But where did those numbers in the file names come from? They came from here:

Scrivener Export Options

So now we’ve got a directory full of directories full of text! Let’s send it to Leanpub, right? Well, we need to do a little work first.

Prep for Print: The Leanpub Stuff

If you just give the Leanpub book generator a pile of text files it doesn’t know what order they should be in. So you provide it an extra file, book.txt, that includes all of your text files and the order in which they should be put into the book. The current book.txt file for Painless Git looks like this:

1 Front Matter/1 frontmatter.txt
1 Front Matter/2 Book Status.txt
1 Front Matter/3 Preface.txt
1 Front Matter/4 Introduction.txt
1 Front Matter/5 Structure.txt
2 Main Matter/1 mainmatter.txt
2 Main Matter/2 Beginning/01 Part 1.txt
2 Main Matter/2 Beginning/02 A Brief History of Git.txt
2 Main Matter/2 Beginning/03 Installing.txt
2 Main Matter/2 Beginning/04 First Steps.txt
2 Main Matter/2 Beginning/05 Commit.txt
2 Main Matter/2 Beginning/06 Interlude Tools.txt
2 Main Matter/2 Beginning/07 Branching.txt
2 Main Matter/2 Beginning/08 Configure.txt
2 Main Matter/2 Beginning/09 Sharing.txt
2 Main Matter/2 Beginning/10 Oops.txt
2 Main Matter/3 Refinement/01 Part 2.txt
2 Main Matter/3 Refinement/02 Good Git Habits.txt
2 Main Matter/3 Refinement/03 Small Commits.txt
2 Main Matter/3 Refinement/04 Hygiene.txt
...

When I wrote Painless Vim and Painless Tmux I kept this book.txt file up to date by hand. It was just another text file in Scrivener. So when I added a new section to the book I would go into book.txt and add each new section. The benefit to doing it that was was that I could work on a new section for a while before it got added to the book. The downside, of course, is human error. Sometimes I would add a new file in the wrong place, so chapter two came before chapter one. Or I would update the order in Scrivener and not update it in book.txt, which meant that when I published a new version it didn’t include my new chapter, and I had to fix book.txt, then publish again immediately. Whatever the case, sometimes book.txt got out of sync with reality.

It’s so easy to get files lined up in Scrivener and once you’ve done it in Scriv you shouldn’t have to do it again in book.txt. If you’re a developer the words “write a script” are already foremost in your mind, aren’t they? What if we could hook into git’s workflow to generate book.txt just before we commit?

Oh right, we can.

Python and Git Hooks

So now you need to create book.txt programmatically from your actual file structure. You’ve got numbered everything, so you can just recurse through the directory, find each leaf node and then prepend its path, and you’ve got a file path, right?

You just did too much work. Python is made to make things easy. os.walk will find every file in your directory and all subdirectories. I wrote a short python script that finds all the files, puts them in order, and then calls git add book.txt. Make that executable and save it as /painless_git/.git/hooks/pre-commit and you’re in business, my friend.

So now I no longer have to manage book.txt by hand. Using the features in Scrivener and in git, I’ve made it that much more painless to write Painless Git.

I’ve also come up with a good excuse for why I haven’t added any actual text to Painless Git today.