So, one of the major goals for Sand and Blood (SAB) is to create my own font. Yeah, it is a “pie in the sky” as it were, but it is something I’m enjoying doing during my lunch breaks. However, I decided I needed something a bit more complicated than just creating the glyphs by hands. And I wrote a Unicode chart generator to help me do it.
Continue readingTag Archives: Python
MfGames Writing: Something useful has been written
I decided to take a week or two off from writing. I was getting burned out but also because I have a few things that need to be done that I’ve been ignoring in my obsession to finish BAM (just got the writing group feedback on the last three chapters).
Yesterday, I got to a stopping point on rewriting one piece of MfGames Writing from Python to C#. It was an interesting experiment that took about four days (two was playing with coding style) to work out, but it is pretty critical for my build system for making both ebooks and collecting data for typesetting print books.
Continue readingTwo years of Python
About two years ago, my dad convinced me to try Python. His argument was “I liked it, you probably will too.” I know, it isn’t exactly the greatest argument, but after the initial blowing him off, I decided that I needed to be open-minded and actually try Python.
Since then, I’ve written a few non-trivial applications including some media processing tools, a pretty extensive set of writing utilities, and a slew of other little scripts here and there. I also have an entire ebook publication system written in Python.
When I went to the cabin two weeks ago, I was talking to my dad about it and I realized something: I don’t like Python. I mean, Python is a great little language and I’m fairly competent at it. I would still recommend it for teaching people who to program. But, as a language, I don’t think it’s the language for me.
MfGames Writing and build system
With my work with formatting Sam’s Dot Publishing’s (SDP) books for the Kindle, I have a steady stream of books in Microsoft Word format that need to be converted to Mobi files. This is a fairly tedious process since SDP’s formatting isn’t conductive to just throwing the book through kindlegen and having everything magically ready.
Getting the SDP document into DocBook is the hardest part, but only takes about 10-15 minutes. I mainly go through the document and change headings, add some keywords for poetry, and normalize the section breaks. Once I have a clean Word document, I wrote a Perl program to convert Word into DocBook 5 and try to arrange everything according to DocBook’s XML schema. This includes making articles, putting in authors, and parsing the legal page.
With the prompting of a co-worker (who suffers through my emoness) and a really nice person on Reddit, I decided to make most of this system public to get improvements and maybe save someone else some time and effort. Plus, I like giving back to the communities who helped me get this far.
With the work this weekend, I think I have a decent alpha-quality build system that takes a DocBook file and creates a fairly clean PDF, MOBI, EPUB, DOC, DOCX, RTF, HTML, and ODT version. Almost all of this is driven by XSLT stylesheets so it is easy to change the format for ascetic or branding appearance. It also has tools for uploading stories to WordPress for when you might want to make a story public.
Continue readingWordPress mass uploading
I’m a lazy person. I can’t really describe it any other way. I don’t like doing the same thing over and over again. It is tedious and my time is better spent on other things. However, I’m always changing. It might be a new technology, file format, or organization. For example, in the process of analyzing how many words I’ve written over the years I touched on the problems of repeatedly changing file formats . I want to keep them consistent instead of in a ton of different formats. My previous analysis would have been a lot harder if I had five different formats. And I’m not going to change this part of me. If I decided to Creole is a horrible format to write in (actually, I want to move to Markdown since that is the most popular format right now), I will translate every story, novel, and chapter to the new format.
The only reason I haven’t switched over is because I’m in the middle of a serial and I thought it would be cool to show the progression of the serial over time and I don’t want to worry about renames when I do it.
Changing websites is one of those things. With the DokuWiki site, I had the Creole parser plugin so I just made a couple changes and uploaded them directly into the file host. This is actually one of DokuWiki’s strengths. When I had a new story or chapter, all I had to do was scp the file up and visit the site. It was there and it took no effort.
Using WordPress is a much harder. I can’t just scp the files up and have them show up. I need to go through the website (or at least the API) and create the page. And then copy/paste it in and change the formatting (I rarely use italics but I do use them). And that is fine for the 5-6 stories I have on http://d.moonfire.us/. For the other byline, I would have hundreds of files to upload.
And I’m too lazy to do that.
MfGames Media: Getting information about a movie
In the process of not writing, I decided to clean up my media server. One of the drawbacks of switching from MythTV front end to Roku is that the Roku doesn’t have the flexibility that the MythTV had. I couldn’t use MPlayer which had everything in a single file. Instead, I had to break things out. One advantage is that the files are grouped together so the metadata is with the cover image is with the video files.
Now, I want my Roku to be as pretty as my MythTV. This means I want to get an image on the display and maybe some information about the movie. On the MythTV, I just had a screenshot of whatever was in the movie 20% into it. It was… okay, mainly because I didn’t have a good poster downloader. I also had poor metadata information (year, plot, etc) because the MythTV’s process always hung so I killed it.
I wanted more.
How to see the first five words of each sentence (Python version)
A few days ago, I wrote a Perl program to view the first five words of each sentence in a paragraph. Over on Reddit, someone asked if Python could also be used. Below is the Python version that produces an identical output.
Make pretty books (and PDFs, Mobi, and ePUBs)
This weekend, among everything else I was doing (Flufy and EDM were out of town), I drastically improved my build system for working with writing. One of the key parts of how I write (using a text editor and Creole-formatting) is to get it into the formats I need it. Most of the time, Microsoft Word for the writing group and PDF for everyone else is fine enough. However, I’m working on getting some of my short stories on Smashwords/Kindle which means I needed to expand it to handle a lot more.
The progress was actually pretty good. I managed to implement a nice system for handling XeLaTeX-based system along with FOP for PDF generation. The XeLaTeX (type that fast, I dare you) creates much nicer PDFs that are also Lulu friendly, but not as easy for me to work on (TeX makes XSL:FO looks child-like).
The Kindle stuff is moving forward nicely, but I have a bit more work with that. On the other hand, a secondary build system I’ve been mocking out to handle Sam’s Dot Publishing’s (SDP) catalog conversion to Kindle is much further along on that part. I got the input files almost down to a science. From the files I get, I can get a Kindle book reformatted, cleaned up, and uploaded in about twenty minutes. And I think they look pretty good too.
What I’m figuring out for SDP will roll into my primary build system so my short stories/novels can easily (and mostly automatically) converted into Mobi files (and the Smashwords Word document for their Meatgrinder).
I’ve been doing the SDP stuff for about two months now. They are a small publisher and could use my help. Hopefully, I’ll get paid for what I’m doing but that might be a bit further down the line. Overall, I just like helping people.
http://mfgames.com/mfgames-writing/
As part of work toward automated converting my stories into various formats, I spent five hours waiting for the dog to be groomed working on some additional functionality for MfGames Writing. There are now tools for querying and manipulating both OPF and NCX files from the command line. Most of this is so I can programmically add an “About the Author” or “If You Want to Give Me Money” (e.g., Also by the Author) pages without polluting the source file.
Overall, I’m pretty happy with how far I got this weekend on the programming side. (I also banged out about 20k words, cleaned the house, put up some shelves, fix stuffed, and wrote a barcode and QR code generator for SDP.)