fsck -vf /dev/hdc1 > log

 

Programming as a profession is only moderately interesting..You’re much better off using code as your secret weapon in another profession.

Tinkering Chisel

While I’m not leaving Tumblr, I am not averse to tinkering with a static site generator script either. Call it Plan B. This for an unlikely event if Tumblr decides to do something I am yet to imagine.1 So, I’ve been trying out Chisel, written by David Zhou.

A few things that jumped at me about Chisel, in spite of the fact that there’s zero documentation, were the following:

  • Written in Python, a scripting language I am familiar and comfortable with.
  • Minimum number of dependencies.
  • Code brevity. In less than 150 lines, I can actually read, understand, and modify Chisel.
  • Minimalism, and lack of complexity in comparison to, say, the likes of framework based static generators.

I keep a backup of all my posts in Markdown.2 The advantage of this is that I can simply drop these files in a folder, and let Chisel regenerate my entire site in a matter of seconds.

How-to

Chisel needs a few packages for it to function. But before they can be installed, one needs pip, a python package installer. On Debian, it can be installed thus:

sudo apt-get install pip-python

On the Mac, you can install pip this way:

sudo easy_install pip

Install python packages

Using pip, install these:

sudo pip install jinja2 markdown 
sudo pip install mdx_smartypants PyRSS2Gen

Create a site structure

~/site
    /posts
    /www

Write posts in Markdown and park them in the sub-folder posts , e.g., chiseling.markdown.

Post pre-format

All posts require a minimal pre-formatted information for the posts to be parsed into their HTML equivalents by Chisel. Following is the structure of a post:

Post title
m/d/Y
[blank line]
Content here onward.

Date in the second line needs to be input as e.g., 5/14/2012 by default. (Note: Chisel does not support taxonomy, and therefore, there are no fields for categories or tags in the above.)

Download Chisel

Download chisel under ~/site folder, so its path would be ~/site/chisel as below:

git clone git://github.com/dz/chisel.git

My fork includes the following that didn’t exist in the original:

  • Smartypants content parsing to emit typographically nicer quotes, proper em and en dashes, etc.
  • A shorter (just year based) permalink structure.
  • RSS feed generator script (Hat-tip: Ronan Jouchet).

Edit chisel.py to update settings

There are a few things to set in the single file, chisel.py, which can be edited to suit. Once done, write a post, park the file with .markdown extension under ~/site/posts folder, and then run the following command:

python ~/site/chisel/chisel.py

And the static site will be generated in the www folder. This can then be synced to a web host, either manually, or via a cron job.

Serve it

Once chisel churns out the posts into html files, the next obvious thing is to serve it. The beauty of generating a site with chisel is that you don’t need mod_rewrite. And once you don’t need it, then running Apache or even nginx feels like an overkill on a home server. Instead here’s what I do. Run the following in a Terminal:

cd ~/site/www
python -m SimpleHTTPServer

Then point my browser to http://localhost:8000. The default port the webserve listens to is 8000. If you’re looking for serving without the port part of the URL (like http://localhost) instead, then you’ll need to run it in sudo, like this:

sudo python -m SimpleHTTPServer 80

Want the terminal free, while leaving the server running until you shutdown? Then append it with an ampersand:

sudo python -m SimpleHTTPServer 80 &

I wrote a tiny snippet in Gedit (under Markdown snippets) to automate the pre-formatted template, and assigned a trigger, ct to this.

$(1:echo $GEDIT_CURRENT_DOCUMENT_NAME)
$(2:date +%m/%d/%Y)

When I open a new .markdown file in Gedit, type ct and hit tab, line one above picks up the name of the file, and line 2, the date—as required.3

I am yet to tinker with its templating engine, Jinja2, but I like what I see. It looks straightforward, and I don’t expect it to vex my learning curve. Plan to work on this over next weekend.

Update: I worked on my layout, and was surprised that it required less than half the markup I thought it would need. Awesome. Here’s a screenshot.


  1. Be acquired; become evil over time; or simply close shop. 

  2. For those I don’t, there’s an easy markup converter called pandoc by John Macfarlane. 

  3. I suppose, I could do this on a Mac using TextExpander or TextMate as well. 

I tend to write directly on my server whenever I use the iPod. This is better than going via the cloud sync. But Vim in its default mode tends to break words, and I need to run this to get non-breaking word wrap:

:set lbr


I avoid setting this permanently in .vimrc as set lbr because that isn’t convenient for writing or editing code.

There are times when I do not like carrying my laptop, and occasionally this becomes my sole rig. But every time I use it, I wonder why I need a computer.1



There are a couple of offline apps I could use, viz., Elements and Day One that would do well, of course, if you do not have access to a server. I like Vim best because once you configure the server with the choicest of Vim plugins, it becomes pretty powerful, all without the UI bloat. ↩

I tend to write directly on my server whenever I use the iPod. This is better than going via the cloud sync. But Vim in its default mode tends to break words, and I need to run this to get non-breaking word wrap:

:set lbr

I avoid setting this permanently in .vimrc as set lbr because that isn’t convenient for writing or editing code.

There are times when I do not like carrying my laptop, and occasionally this becomes my sole rig. But every time I use it, I wonder why I need a computer.1


  1. There are a couple of offline apps I could use, viz., Elements and Day One that would do well, of course, if you do not have access to a server. I like Vim best because once you configure the server with the choicest of Vim plugins, it becomes pretty powerful, all without the UI bloat. 

Changes you won’t notice

This log has been on a quote overdrive lately. In my enthusiasm to share, I realized I was crowding my own voice in the process. So, I will be cutting down—moving them instead to my private bookmarking account.

The other thing I want to do is to keep my gripes in check. They bother me more than they bother you, because a sense of helplessness isn’t what I want to share here. Believe me that kind of stuff exists wherever you look.

What I’ve always liked is making this more about positivity and unbridled enthusiasm. One way I measure this is by reading my dated stuff, and see if it makes me feel like it has been a positive contribution overall. Looking at my posts here, by and large, I think I’ve succeeded. That said, a well reasoned long form of writing isn’t possible every day. But I promise I’ll do my best to share, whenever it is I do have something to.

The other aspect of this log is about aesthetics. I spend an insane amount of time on presentation, legibility, words per line, line-height, and colors towards making it a good reading experience. While some think my single column may be too narrow, I think I’ve found a sweet spot that doesn’t stray your focus away when you’re reading. Also, there are no ads, no tracking, no social buttons, nothing to promote, and nobody to influence. This is a labor of love, so if it aims to earn anything, then I hope it’s goodwill.

Automating parts of command-line git

Add files

git add %|

%| places the cursor at the intended position. If you don’t add individual files, then replace it with the following (to add all files in the folder):

git add .%key:enter%

Commit updates

git commit -a -m '%|.'

Placing the cursor ready to input commit message.

Check status

git status%key:enter%

Push updates to origin

git push -u origin master%key:enter%

From last two, note that you can include keystrokes too. So, the moment I hit ;gp (my trigger for git push command), TextExpander takes my pre-assigned trigger-to-command and pushes it to my (origin) repository—all without requiring the need to press enter manually.

Download

Download from my GitHub repository into TextExpander as Add Group from URL.

Image courtesy: National Geographic, via ASME.

This month marks the centenary of RMS Titanic, the ill-fated ocean liner that hit an iceberg near 41.44N-50.24W and sank—killing over 1,500 of her passengers in the process.

Aside from operational issues (poor sighting, late warning, incorrect instructions to change course upon iceberg sighting, and inadequate time to “hard-a-port” around), the subject of my curiosity has long been on what led to the loss of hull integrity upon collision.

In 2008, The New York Times ran a story titled, “In weak rivets, a possible key to Titanic’s doom”. While this may have been one of the problems, my suspicion—that it wasn’t all of it, and that the key to hull failure was inherently ingrained in mechanical properties of unqualified steel—turned out to be true. Typically, these properties are considered at standard temperature and pressures. Under high temperatures, the molecular grain distribution becomes denser, and vice a versa in cold. In a rectangular plate at low external temperatures, e.g., molecular grain distribution becomes denser at plate’s re-entrant corners, while significantly thinning out at its center—like in magnetism. At a cruising speed of 22knots, her bow plates—brittle due to low temperatures—gave away.

In an article published by the ASME in its Mechanical Engineering magazine this April, titled, “Testing The Titanic’s Steel,” there’s a note by Henry Baumgartner, which suggests it more clearly than ever:


  When the Titanic samples were also examined with a scanning electron microscope, the grain structure of the steel was found to be very large; the coarse structure made it easier for cracks to propagate. Rivet holes were cold punched, a method no longer allowed (they must now be drilled), nor were they reamed to remove micro-cracks.
  
  The grain size; the oxygen, sulfur, and phosphorous content of the steel; and the cold punched, unreamed rivet holes were found to have contributed to the breakup of the Titanic, along with the steel’s relatively low ductility at the freezing point of water.

Image courtesy: National Geographic, via ASME.

This month marks the centenary of RMS Titanic, the ill-fated ocean liner that hit an iceberg near 41.44N-50.24W and sank—killing over 1,500 of her passengers in the process.

Aside from operational issues (poor sighting, late warning, incorrect instructions to change course upon iceberg sighting, and inadequate time to “hard-a-port” around), the subject of my curiosity has long been on what led to the loss of hull integrity upon collision.

In 2008, The New York Times ran a story titled, “In weak rivets, a possible key to Titanic’s doom”. While this may have been one of the problems, my suspicion—that it wasn’t all of it, and that the key to hull failure was inherently ingrained in mechanical properties of unqualified steel—turned out to be true. Typically, these properties are considered at standard temperature and pressures. Under high temperatures, the molecular grain distribution becomes denser, and vice a versa in cold. In a rectangular plate at low external temperatures, e.g., molecular grain distribution becomes denser at plate’s re-entrant corners, while significantly thinning out at its center—like in magnetism. At a cruising speed of 22knots, her bow plates—brittle due to low temperatures—gave away.

In an article published by the ASME in its Mechanical Engineering magazine this April, titled, “Testing The Titanic’s Steel,” there’s a note by Henry Baumgartner, which suggests it more clearly than ever:

When the Titanic samples were also examined with a scanning electron microscope, the grain structure of the steel was found to be very large; the coarse structure made it easier for cracks to propagate. Rivet holes were cold punched, a method no longer allowed (they must now be drilled), nor were they reamed to remove micro-cracks.

The grain size; the oxygen, sulfur, and phosphorous content of the steel; and the cold punched, unreamed rivet holes were found to have contributed to the breakup of the Titanic, along with the steel’s relatively low ductility at the freezing point of water.

git for an end-user

Picture this: you find a good piece of software on github that you want to use. Typically, you’ll click on the download button, and uncompress before using it. After a while, the developer pushes an update. To get this update, you’ll (need to) repeat the above. Here’s a better way:

Let’s assume, just as an example, you’re looking to download the latest version of my WordPress plugin, small-caps. SSH into your host, and run the following under wp-content/plugins folder (This is done just once ever. Updates thereafter do not require to run this):

git clone git://github.com/ckunte/small-caps

A few months later, let’s say I update this plugin.1 To update your server copy to the latest version, here’s what you do: SSH into your host, navigate to wp-content/plugins/small-caps folder, and then run the following:

git pull

Another update in a few months? No problem, just run git pull, and you’d be up to speed with the latest version.

Did you know that you can do all of the above for desktop downloads and updates too? All your computer needs is a copy of git. Whoever said you need to be a developer to use git?


  1. I presume, you keep track of this repository for updates by subscribing to its RSS feed.