Using Jekyll to make my blog.
Thursday 16 June, 2011There are a ton of these posts out there. For all I know it is a requirement of using Jekyll.
I think I was a little more noobish than most when I was trying to start out with Jekyll. I had a feeling that it was the right thing for me, so I was determined to figure it out.
It turned out not to be nearly as complicated as it seemed, but the documentation was pretty minimal and most of the examples were really complicated.
Not a good combo.
What Jekyll does, essentially, is generates a flat HTML website based on some templates that you set up. (Flat HTML means that there isn’t a database, like SQL, involved. That makes it really easy to back up, publish, migrate, &c. The most basic example is as follows:
First, install Jekyll. If you have RubyGems installed, you can install it with gem install jekyll Otherwise, check out the repo on GitHub
Next, create a _layouts directory and put a file called default.html inside.
In the file you will put in {{ content }} Something like this:
<HEAD>
<TITLE>{{ post.title }}</TITLE>
</HEAD>
<BODY>
<DIV>
{{ content }}
</DIV>
</BODY>
</HTML>
That is the first part. Now you’ll make the file with content (this file will be called index.html):
layout: default
title: My Webpage
---
<h1>Hello, World!</h1>
<p>This is my new website. I made it myself!</p>
When you run jekyll in your site directory, it will grab the content from index.html and run it through your layout and stick it all in the _site directory. The {{ content }} bit will be replaced by everything below the YAML header (which is between the two — at the top).
At this point, this might seem a bit silly as it is considerably easier to just make the index file. The point is that you take the default layout and then making all of your pages is really simple. Also, when you want to change the layout you just change the default file and then re-run jekyll.
The real nice part of Jekyll is when it comes to blog posts. You’d want to create a _posts directory at this point. If you want the posts to look different than the default page, you can make a new layout in your _layouts directory.
The filename needs to be something like 2011-06-16-First.html and it would look similar to the index file above.
layout: posts
title: My First Blog Post
---
<h1>Blog Time</h1>
<p>This is my first blog post! I hope my host can handle all of the traffic.</p>
That’s pretty much the basic layout. Any file not in _posts will be placed in the same order in the _site directory.
You can make a nice page that will display a list of all of your blog posts like this:
{% for post in site.posts %}
<div class="post_info">
<li><span>{{ post.date | date:"%d/%m/%Y" }}</span> <a href="{{ post.url }}">{{ post.title }}</a> <em>{{ post.snip }}</em></li>
<br />
</div>
{% endfor %}
</ul>
The {% for %} statement at the top will grab everything that is in the _posts directory. It will print out the date and then the title as well as a custom bit that I added to the YAML header called snip. The end result is a nice list of your posts.
nag: a bash script.
Saturday 11 June, 2011I made a thing called nag. Well, I copied most of it from One Thing Well. Using aliases is okay, but I kept finding myself wanting to type nag and then a command. Like nag ls to list nags or nag clr to clear nags.
It is pretty simple. It makes a file called ~/.nag and then adds and removes items.
For instance, to add something type nag add and enter your item at the prompt. That’s it. Type nag ls to see a numbered list of items like this:
1 Sleep at some point.
2 Write a post about nag.
Easy, right? You can remove one of the numbered lines by typing nag rm 1 and clearing the whole list is done with nag clr.
If you want to check it out, you can see it on GitHub.
Copy nag.sh to a directory in your $PATH (I use /usr/local/bin) and relaunch your shell. If you don’t have a ~/.nag file, it will make one for you.
GNU screen Cheatsheet
Thursday 09 June, 2011Options
-A - Adapt all windows to the new display width & height.
-r - Reattach session.
-R - Reattach session if there is one, otherwise start a new one.
-list - Show list of current screens.
Interactive
Use CTRL-A (^A for short) to get screen’s attention and then issue the following command:
(for example, to go to the next screen hold CTRL and then press a. Release and then press n)
NOTE: All commands are cAsE SenSiTiVE!
Common:
^A " - List all windows and their titles.^A c - Create a new window.^A k - Destroy the current window.^A n - Next window.^A p - Previous window.^A d - Detach this screen.
Regions:
^A S - Split in half vertically.^A | - Split in half horizontally.^A TAB - Go to the next window.^A Q - Kill all regions except the current.^A X - Kill the current region.
Others:
^A 0-9 - Select the numbered window.^A A - Set the title for the current window.^A C - Clear the screen.^A F - Resize window to match the current size.^A l - Refresh the window (lowercase L)^A M - Monitor window for activity.^A _ - Monitor window for inactivity.^A x - Lock terminal.^A [ - Enter scrollback^A ] - Write the contents of the paste buffer to stdin