Donate to support Ukraine's independence.

25 Dec'13

Creating shortcut function in Fabric to create a Pelican draft

I migrated from Wordpress to Pelican few month ago and so far I was satisfied with it, mainly because my demands to the blogging platform are far lower than one might imagine. But as atrue engineer, I always strive to eliminate any duplication in code or in actions.

For this reason I’ve created one more Fabric function that creates a draft for me, properly setting the date and slug for me:

drafts_path = 'content/drafts/'

def draft(title):
    from datetime import date
    from time import strftime, gmtime
    from unidecode import unidecode
    import re
    from subprocess import call

    today_iso = date.today …

Continue reading

Category: 

10 Aug'13

Rename all *.rst files in a directory according to their date

TODO:

  • add verbose mode
  • move awk output into variable and test if file already begins with a date
#!/bin/sh
for f in $(find ./content/ -name '*.rst'); do
    name=$(basename "$f")
    dd=$(dirname "$f")
    d="$dd/$(cat "$f" | grep ':date:' | awk '{print $2}')-$name"
    if [ ! -f "$d" ]; then
        mv "$f" "$d"
    else
        echo "File '$d' already exists! Skiped '$f'"
    fi
done

Continue reading

Category: 

14 Jun'13

VIM %crazy%

Well, I have a very simple use-case: I just copied a chunk of text and it contains line numbers. Can vim handle it??

Easy:

:%normal 2x

Continue reading

Category: 
vim