Migrating A PostgreSQL Blog to Jekyll

It’s a great last day of the year for me because I managed to migrate my PostgreSQL and Sinatra tech blog to use Jekyll. It was been using Sinatra and PostgreSQL for some years. In 2009, I was using an opensource PHP CMS worse than Wordpress. It was so bad and overkill. Using Sinatra and PostgreSQL’s still overkill for a blog.

Isn’t it a chore to change and throw away everything that already works? No. I feel like it’s a great step forward so I could write more useful posts. It seems like I got a lot done within a few hours. I used Python to convert the posts to Jekyll markdown format.

I am more familiar with Ruby, but in coming years, I will use Python more because it is the number one language for Data Science.

These few lines of code connect to the PostgreSQL database and fetch all of the posts I have written in the last 8 years.

conn_string = "host='localhost' dbname='codekat' user='user' password='password'"
conn = psycopg2.connect(conn_string)
cursor = conn.cursor()
cursor.execute("SELECT * FROM posts")
records = cursor.fetchall()

The rest of the code’s not very interesting. But it was super easy, and I still have a lot of time to explore Sydney before the year ends!

Focus on Product Design and DevOps Culture

2018 will be great, because I just automated a lot of work, and probably do not have to click buttons to publish posts.

People these days use Wordpress, but it has not changed much for the better since its b2 days. I used Wordpress when it wasn’t even called Wordpress. It was a project forked by Matt. He just made it a bit better, and created a globally successful business out of it.

I believe that blogging and publishing in general could benefit from people who focus on Product Design and the DevOps culture. I am quite surprised how blogging and publishing is still archaic and Wordpress has not done a great job with this. They have, however, done a great job in promoting open source. The cost of publishing will be closer to free. It should be easier to edit any article from anywhere and you don’t even have to click a button. I am close to achieving this.

As a software engineer, I focus on adopting this DevOps culture, particularly the “automate all things” part. At the amazing company I work for now, we have a DevOps culture. Everyone codes. Even the quality assurance engineers. We like to automate all things we can.

With the Amazon cloud infrastructure, the costs of developing these automation tools and services are closer to free. By the way, this is the second time Amazon in-house recruiters reached out to me but I am not interested in any career change now. I think I am learning a lot, and I am doing a lot of really important work with a company that has a great culture.

I talked to some guys about some ideas on how to make blogging a better experience with Jekyll. They ascend to it. The best part is you don’t even have to write code to get it done! You can use Lambda to auto-publish your posts and read from a directory in the cloud. Jekyll does not have to live in GitHub. You can publish it on Amazon s3.

Tools Should Be Fit for Purpose

People think that blogging should never be a chore. It should only take 5 minutes to install a blog software and configure it. I have the same belief. This is why I think Jekyll is great. It only took a few minutes to set up.

The process of writing and publishing is simplified. You don’t fight with WYSIWYG editors.

It does not matter if you use Ruby, Python or JavaScript as long as you are automating a lot without sacrificing performance, forgetting about user experience and going off the web standards. In the end, these are the only things that matter. I didn’t have to struggle to figure out slug generation. It is a best practice to keep your slugs short and relevant for search engine optimization purposes, so I didn’t want to change how I did it for years.

This year I learned that good tech companies use fit-for-purpose tools. It’s not just the company I work for. Some Fortune 500 companies would rather use JavaScript React Native for developing mobile applications because it fits in their processes. They did not have to change the people who worked with them. They only change the tools.

Languages and frameworks are just tools for me. I learned to throw away code and give up the NIH syndrome. I only work want to work for companies that allow me to use fit-for-purpose tools. If we use Ruby, I think the app will crash and burn, and the business will die. You have to understand the business before you say that can’t be true. They sensibly use Golang a lot which I definitely agree with. For those who are interested in learning Ruby, I can still publish the code of my blog application. Probably not today, but I will soon.

Happy New Year!

Despite the probable drama and setbacks you may have encountered this year, understand that nothing matters. You just have to know how to manage both your energy and your time.

2017 was a great year for me. Read What did you accomplish in 2017?.

I was assessed to be skilled and suitable for migration by the Australian Computer Society. It’s a big deal because I did RPL or Recognition of Prior Learning. This year, I studied Computer Science. Did poorly on the first few months but I got a perfect score for my project on a graph theory problem.

I will probably write a long post about how I learn Computer Science, and what I think about formal education. A lot of my 2018 blog posts will be completely focused on Computer Science fundamentals.

But for now, I have to go out and enjoy the last few hours of 2017.

Enjoy New Year’s Eve!

Further Reading

  1. Jekyll
  2. Jekyll Deployment Methods