Daniel Doubrovkine bio photo

Daniel Doubrovkine

aka dB., CTO at artsy.net, fun at playplay.io, NYC

Email Twitter LinkedIn Github

The newly remodeled code.dblock.org is powered by Jekyll and Github pages. The source code can be found here.

The Old

My homegrown system was built in 2008. The tech stack was Microsoft ASP.net with a SQL Server back-end. I did most publishing with Windows LiveWriter that used AtomPub.

Needless to say that was starting to really annoy me, having to boot a VirtualBox VM with Windows on my Mac just to publish an article. Worse, copy paste between the host and the guest OS was not working for images, so I used Dropbox for screenshots. The system was originally designed to save me time, only to ultimately become a time suck. Finally, WinHost, where the blog was hosted, while providing excellent service, actually costs quite a bit of money.



I had to write a migration from the old SQL data to the new markdown format.

ActiveRecord does a good job talking to a SQL server.

gem 'activerecord'
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 4.0.0'

I had to fight tiny_tds a bit, needing to reinstall iconv and brew install freetds.

require 'rubygems'
require 'bundler'

Bundler.setup :default, :development

require 'yaml'
require 'active_record'

Create a database.yml configuration file.

  adapter: sqlserver
  host: sql.winhost.com
  database: DB_26545
  username: ...
  password: ...

Connect to the database.

dbconfig = YAML::load(File.open('database.yml'))

Define models, such as Post.

class Post < ActiveRecord::Base
  self.table_name = 'Post'

Require the models explicitly.

Dir['models/**/*.rb'].each do |f|
  require File.expand_path(f)

Iterate over posts.

puts "Reading #{Post.count} post(s) ..."
Post.order('created ASC').each do |post|
  puts "#{post.Slug}: #{post.Title}"

The posts were stored in HTML, I convert them to Markdown with reverse_markdown.

content = ReverseMarkdown.convert(post.Body, github_flavored: true)

Figure out where to write the post on disk and write the markdown post.

  File.open "#{post.Slug}.markdown", "w" do |file|
    file.write <<-EOS
layout: post
title: "#{post.Title}"
redirect_from: "/#{post.Slug}"
date: #{post.Created.strftime('%F %T')}
comments: true

The full script is here.


I wrote a script to rewrite post URLs for Disqus comments and uploaded it as instructed. Posts appeared after I set the correct disqus-shortname in my _config.yml.



I picked Minimal Mistakes and altered it a bit to remove clutter. Thanks @mmistakes for the awesome work.

Github Limitations

If you’re like me and don’t want to generate the Jekyll site yourself, be aware that Github pages doesn’t support many plugins. This means you can’t make features like, for example, tags, to work at the moment. Create a Gemfile that references github-pages to see an identical output as what Github would show.

source 'http://rubygems.org'

gem 'github-pages'

Serve Jekyll locally via bundle exec jekyll serve.

Syntax Highlighting

Github pages don’t support syntax highlighting the same way all markdown content does on Github. You can’t use backticks. This means ```ruby will not syntax highlight Ruby, you have to use Pygments with one of the very many lexers to highlight code.

{% highlight ruby %}

# Ruby code goes here

{% endhighlight %}

None of these will currently work on Github pages, so I removed them from the theme. Add your +1 to pages-gem#93.

I added Google Custom search in this commit.


I used code2.dblock.org while iterating on the system, then finally updated the CNAME file to make the actual switch. Github custom domains are documented here.

Finally, I happened to rename the repo a few times from code to code.dblock.org and back. Github will bring your site down for a while when that happens - you have been warned.


If you see a typo in a post or want to contribute in any other way, please don’t hesitate to open issues and make pull requests.