Theldoria's Blog

All about hacking I think is worth to note.

Categories and Tags in Octopress

| Comments

In order to add Categories and Tags pages, create those:

rake new_page[blog/categories]
rake new_page[blog/tags]

And insert the following content:

blog/categories
1
2
3
4
5
<ul>
{% for item in site.categories %}
    <li><a href="/blog/categories/{{ item[0] }}/">{{ item[0] | capitalize }}</a> [ {{ item[1].size }} ]</li>
{% endfor %}
</ul>
plain blog/tags
1
2
3
4
5
<ul>
{% for item in site.tags %}
    <li><a href="/blog/tags/{{ item[0] }}/">{{ item[0] | capitalize }}</a> [ {{ item[1].size }} ]</li>
{% endfor %}
</ul>

Finally add them to the navigation bar:

plain source/_includes/custom/navigation.html
1
2
  <li><a href="{{ root_url }}/blog/categories">Categories</a></li>
  <li><a href="{{ root_url }}/blog/tags">Tags</a></li>

Deploying to Heroku

| Comments

To add a new heroku app simply call:

heroku create

You now should have a heroku remote. Check with:

$ git remote -v

You can set heroku to be the default remote for push/free:

$ git config branch.master.remote heroku

You can deploy with:

$ git push heroku master

If you encounter the error Permission denied (publickey). while pushing, you may have to add your public key:

$ heroku keys:add ~/.ssh/id_rsa.pub

Freezing Vi

| Comments

Today I stumbled over an frozen vi, after using ctrl-s (from a remote session). To resolve it simply use ctrl-q.

This can easily happen if you switch from emacs, where C-x C-s saves the buffer, to vi, where you have to use ESC :w.

The reason for this is the XON/XOFF protocol. Sending ctrl-s is XOFF, stopping the communication (in one direction), and ctrl-q sends XON, reenabling the data exchange.

Post With Octopress

| Comments

This is my first post with Octopress (a framework designed by Brandon Mathis for Jekyll, the blog aware static site generator powering Github Pages). Now I’m gonna look around to find out how it work’s and if I cand use it as a tool to store useful information an knowledge about hacking.

Code Snippets

First of all: it is possible to include code snippets in posts, in several ways, and for many languages. For example, a snippet for ruby, using backticks (used by github):

Syntax

``` [language] [title] [url] [link text]
code snippet
```

Example

Small ruby backtick example
1
2
3
def test()
  puts "color"
end

Without Highlighting

For code, that does not need to be higlighted (e.g. for shell commands) one can use four spaces in front of the snippet:

snippet

Liquid

One can also use liquid for code snippets. This has the ability to disable tag processing in order to add liquid examples.

1
2
3
4
5
{% codeblock %}
{% raw %}
liquid-snippet
{ % endraw % }
{% endcodeblock %}

Links

Links can be added by using [link text](url).

Posting

Ok, now, in order to post Octopress provides a rake command:

$ rake new_post["title"]

This create a new file with right naming convention and puts the filename, so it can be opened with a text editor. I only whished I could set an editor which is fired automatically with the new file…

One can also create pages:

$ rake new_page["page title"]
# creates /source/page-title/index.markdown

$ rake new_page[xyz/page.html]
# creates /source/xyz/page.html

But I am not shure, how those pages my be accessible. Possibly one is expected to add an link to them somewhere.

Preview

Changes can be inspected before deplying with:

$ rake generate
$ rake watch    # Watches source/ and sass/ for changes and regenerates
$ rake preview  # Watches, and mounts a webserver

Visit webserver at http://localhost:4000 to see changes.

Deploying

If new posts are ready the blog can be newly generated and deployed:

$ rake generate
$ rake deploy