WTF is Sculpin

wtf is, sculpin
Meet Jackson, the Sculpin mascot

Sculpin is a static site generator written in PHP. And WTF is a static site generator? It's a tool for generating html files using raw data like TWIG and markdown. It's great for a website that has content that doesn’t need to be updated by multiple users on a regular basis, authentication, search, or any logic that requires server side communications. It can remove much of the complexity that comes with a CMS or hefty framework, as well as the need for server side technologies like PHP or a database server. A Static site generator is great for my personal blog or the local astronomy group news site, but not ideal for a large news organization that has much more dynamic content. Sculpin has the advantage of being written in a language I’m already familiar with; PHP. Some of the standout features of Sculpin include:

  • Writing content in markdown
  • TWIG templating
  • Syntax highlighting
  • Extremely fast
  • Secure (everything is client side)
  • Easily deployable (Can host static sites from github for free)

Sculpin is perfect for creating a blog with a minimum amount of resistance for sharing code snippets and jotting down a few of opinions to share with the Interwebs from time to time. It's Especially useful for anyone already familiar with PHP and writing markdown.

How does one Sculpin?

Installing Sculpin

  1. Download the starter kit
git clone https://github.com/sculpin/sculpin-blog-skeleton.git myblog
cd myblog
composer install

The starter kit is a skeleton build of Sculpin and is a great starting point for launching Sculpin as a blog.

  1. Run Sculpin
vendor/sculpin/sculpin/bin/sculpin generate --watch --server

Navigate to http://localhost:8000. BAM! You now have a boiler plate Sculpin site.

What's Happening?

Magic! Okay maybe not magic. Sculpin comes with an executable bin, that we're running to parse all of the source objects (Twig templates, html, and markdown) files it can find to generate static html pages.

--watch tells Sculpin to watch for file changes in order to rewrite necessary HTML files. --server launches PHP's built in web server which allows you to see your work in progress. The fact that a working web server like apache isn't required makes it even easier to skip straight to writing content without any needless complicated setup.

Creating Content in Sculpin

Sculpin uses a markdown converter michelf/php-markdown for taking the blog content written in markdown and converting it to html. That means once the Twig templates and theme are in place, adding new content can be as simple as dropping a new markdown file into the code base. Luckily the starter kit comes with a working layout and theme, so we can get jump start to creating content.

By default Sculpin will look for blog post content or source objects in each file under the `/source' directory. All content posts can be written in markdown which Sculpin with convert into html.

 # Markdown Cheatsheet

 # This is an <h1>
 ## This is an <h2>
 ### This is an <h3>

 We can place special emphasis on some words by making them **bold** or *italics*

  Link
  [More on Markdown](https://guides.github.com/features/mastering-markdown/)

 Lists
 1. Step 1
 1. ????
 1. Step 3: Profit

 * Moon Knight
 * Scarlet Witch
 * Gambit
 * Hope Summers

This is an <h1>

This is an <h2>

This is an <h3>

We can place special emphasis on some words by making them bold or italics

Link More on Markdown

Lists

  1. Step 1: Make numbered list
  2. Step 2: ????
  3. Step 3: Profit
  • Moon Knight
  • Scarlet Which
  • Gambit
  • Hope Summers

Syntax Highlighting

Another key feature that is a necessity when writing about code is syntax highlighting. Sculpin ships with highlightjs. No assembly required, batteries included!

```php
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once 'autoload.php';

$kernel = new DrupalKernel('prod', $autoloader);

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();

$kernel->terminate($request, $response);
`'`
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once 'autoload.php';

$kernel = new DrupalKernel('prod', $autoloader);

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();

$kernel->terminate($request, $response);

Theming

Sculpin's theming system can be heavily customized, but for the most part does a great job of getting out of your way. It uses TWIG for it's templating engine, and relies on creating layouts, which are mostly just wrappers around page content.

# source/_layouts/default.html
<!DOCTYPE html>
<html>
<head>
    {% include "head" %}
</head>
<body id="body">
    <div class="page-content">
        {% include "header" %}
        <main class="content" role="main">
            <div class="row">
                <div class="col-md-6 col-md-offset-2">
                    {% block content_wrapper %}{% block content %}{% endblock %}{% endblock %}
                </div>
                <div class="col-md-2">
                    {% include "side_bar" %}
                </div>
            </div>
        </main>
        {% include "footer" %}
    </div>
    {% include "scripts" %}
</body>
</html>

But that's a blog for another time.

YAML Formatter

Sculpin provides a method to add additional information about conten via a YAML formatter. YAML formatters are are a great way to provide meta information about the blog with in the markdown file. Information that can be used to do things like generate markup for something not easily supported in markdown, provide meta tag information, create taxonomy tagging of content, and more.

Markdown without YAML formatter.

 # Normal Markdown

With YAML formatter

---
title: WTF is Sculpin
date: 2017-03-31
layout: default
tags:
    - wtf is
    - sculpin
featured_image: 
    image: jackson.png
 ---
 # Markdown with spandex and a cape

The YAML formatters are seperated by --- and written in YAML syntax. The YAML formatter will be parsed and injected into every page twig template using page.%KEY%. Nested structures are accessible by using a . to decend through the structure.

we can access YAML directives with the TWIG template view WTF is Sculpin

<img src="jackson.png"/>

Conclusion

Sculpin does exactly what it sets out to do, and does it well. It's a great tool for someone already familiar with PHP, looking for a way to quickly take TWIG templates, html, and markdown to create a static site that is easily deployable. While it can be extended by creating new bundles, it does not offer a lot in terms of managing dynamic content that requires server side interactions. It is a tool for a specific task, a task that it handles extremely well.

A huge thanks to Beau D. Simensen who created Sculpin, and being an all around awesome human being.

An Impostor's New Blog

lifestyle, impostor
Skeptical Yoda

After a year and a half, I'm finally getting around to launching my new blog. That's a lot of time for a small static website. That should mean that this blog is packed full of innovative technologies, captivating designs, and polished features, right? It has to be perfect. Thankfully this is not perfect, or so I keep telling myself. Perfection is the number one reason I'm surrounded by half finished projects. Perfectionists often seem like super human people who strive for a higher quality than us mere mortals, but that's not the case. Perfection is a mask for fear, and an enemy to "done". This blog is my acceptance that imperfect and done is ultimately better than perfect and incomplete.

Going back in time almost two years ago, my reasons for launching a blog were simple; I wanted to use it as a learning experience and to share my knowledge with others. I'm a developer by day and spend a lot of my time in the back-end of code, buried in logic. I put a great deal of effort into staying within my comfort zone. For example, I typically manage to sidestep doing anything design related. I'm not very good at it so I try to avoid it at all costs, but because I never get any practice I'm not very good at it. I started this project to break the cycle. Along with weak design skills I've never been a strong writer. Both were areas that I hoped to improve, all while sharing some of my experiences and expertise in hope that someone out there in Internet land would find it helpful.

As I passed the 80% completion mark of everything I wanted to accomplish the biggest blocker quickly became perfection. I've traveled down this road many times before. It started as I began to approach what I had defined as being done. At the thought of my work leaving the comfort of my computer and being in front of my colleagues I became filled with doubt. I drastically change my expectations and exponentially increase the level of effort by adding more features, refactoring all of the things in the best (seemingly most clever), and doing another redesign. Just like that I'd gone from 80% completion back to 10%. "It's not good enough" was an easy justification for me to shelve this whole project... again.

This quest for perfection wasn't about high quality standards, pride, or attention to detail, it was about procrastination and fear. As soon as a project came close to being done and released into the wild, I started fantasizing about my potential audience and their experience. I desperately desired to seem intelligent and clever, and for my blog to emphasize those qualities. But I secretly feared that I'm not. That I've stumbled and lucked into my position in life, and that at any moment of any day everyone is going to find out that I'm woefully under qualified and completely inept. I'm a fraud. Georgia State Psychologists Pauline R. Clance and Suzanne A. Imes describe this phenomenon as "Impostor Syndrome" in their paper “The Imposter Phenomenon in High Achieving Women: Dynamics and Therapeutic Intervention.”. (It’s worth noting in the years since this paper was first published there hasn’t been any evidence to support that this phenomenon affects genders differently.)

I'm a fraud and everyone is going to find out. Like most of the biggest fears in my life this one is irrational. I have several irrational fears, like flying, heights, and alligators to name a few. I panic when my airplane takes off. I fear that it's going to crash into the side of a mountain, but have no concern hopping in my car to drive somewhere, even though statistics tells me the latter is much more likely to kill me. Yet, I will still white knuckle my arm rests on the plane as if somehow I can help hold the plane together when something bad happens. Equally ridiculous is how I can be a fraud that moments away from being discovered for a bumbling idiot, yet as an idiot I was able to deceive everyone in the first place and for so long.

Impostor syndrome is not all together uncommon, especially among high achieving people.

"The beauty of the impostor syndrome is you vacillate between extreme egomania and a complete feeling of: 'I'm a fraud! Oh God, they're on to me! I'm a fraud!" -Tina Fey


"What are you doing here? What do you think you’re doing? You’re going to be found out." - Liz Bingham (Managing partner Ernst & Young)


"You think, 'Why would anyone want to see me again in a movie? And I don't know how to act anyway, so why am I doing this?" - Meryl Streep


"When you go and watch a rehearsal of something you've written and it stinks, the natural feeling is 'I stink.' I'm a fraud. I need to go and hide" - Chuck Lore (Writer of Big Bang Theory)

I have an irrational fear, what now? Fear is good for exactly two things; preventing death, and overcoming. There's no conceivable way my life's in danger from since I'm not publishing a blog about butterflies, Chaos theory be damned. So it's time to try to overcome this fear. It's keeping me from several thing that I want in life.

Here's what I'm doing about it.

Do. or Do Not. There is No Try.

Irrational fear ultimately leads to suffering. It does no good. Instead of adding to an infinite todo list of things I'll never get done, I'm going to start marking them off. Instead of letting a fear of imperfections loom over me, I'm going to embrace it and invite it in for tea. I know it's there, I know what it is, I even know that other people have the sames fear and reservations. I'm going to move forward. My best learning experiences come from some of my biggest failures, so there really isn't any reason not to "do". I'm adopting the mentality that something either isn't worth my time, or it is and it’s 100% something I’m going to do. There is no try.

Which brings me to today, the day I launch my blog, and share my fears. I'm sure I could spend another year ironing out thousands of imperfections (no really, I have a list), but that path would only end with tearing everything down because it's not perfect. I'm just going to do my best and hit publish, imperfections and all. I hope that others don't let fear stop them from accomplishing their goals. Fear is the path to the dark side... fear leads to anger... anger leads to hate... hate leads to suffering.

Getting started with Upstart

upstart, linux

Upstart is an event based monitoring system for monitoring and controlling services and daemons. Upstart is meant to be a replacement for the older System V init.d start up scripts with better optimizations in parrelism and boot time. It can be used to run serveral one off tasks, like that of any shell script, or can monitor long running background services.

To create an upstart script, create a job configuration file in the /etc/init directory. All job configuration files follow the convention of .conf where is the name of the boot script for upstart. Below is a base template of an example upstart script.

#cooljob.conf
# my upstart template file
# This script will start / stop something for me.
description "Start/stop some service"
version "1.0"
author "Chris Zietlow"
script
  sleep 1000
end script

Once an upstart job file is in place it will be available to several upstart commands.

start on starting hubot-irc
stop on stopping hubot-irc
respawn

exec su - www-data -c 'cd /home/aczietlow/Web/hubot;
export PORT=5000;
export HUBOT_IRC_SERVER="irc.freenode.net";
export HUBOT_IRC_ROOMS="#spyderbytedesign";
export HUBOT_IRC_NICK="kikihubot";
export HUBOT_IRC_UNFLOOD="true";
export HUBOT_IRC_PRIVATE="true";
export FILE_BRAIN_PATH=".";
bin/hubot --adapter irc >> /var/log/kikibot/hipchat-1.log 2>&1'

Useful commands

  • initctl start | status | stop <script>
    • starts|stops the scripts under
  • initctl list
    • list scripts under /etc/init.d
  • initctl start | status | stop <script>
    • shorthand for initctl start | status | stop
  • initctl log-priority
    • displays the log priority
  • initctl log-priority debug | messages
    • change the messgae priority chkconfig - enable or disable systems services chkconfig --list - check what run levels service is running over