Site Map - skip to main content - dyslexic font - mobile - text - print

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

Welcome to HPR the Community Podcast Network

We started producing shows as Today with a Techie 11 years, 0 months, 17 days ago. Our shows are produced by listeners like you and can be on any topic that "are of interest to Hackers". If you listen to HPR then please consider contributing one show a year. If you record your show now it could be released in 22 days.

Latest Shows

hpr2146 :: Cards Against Humanity Tabletop Game

Klaatu reviews Cards Against Humanity

Hosted by klaatu on 2016-10-24 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Comments (0)

Klaatu reviews the tabletop game, Cards Against Humanity. This is a non-offensive episode, so you can listen to it regardless of your feelings about the game.

hpr2145 :: Daily notes and todo list with markdown

How I use markdown and git to keep up with what I do

Hosted by norrist on 2016-10-21 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Comments (1)

Using Markdown and git to store your todo list and daily journal

Why markdown
  • No distractions
  • Simple syntax
  • Plain text, Human readable.
  • Inline HTML
  • Easy conversion to other formats
Why git
  • Any SCM probably OK
  • Github and Gitlab render markdown.
The todo page
    # TODO

    ### Can do now
    * Bullet 1
    * Bullet 2

    ### Near term
    1. Numbered 1
    1. Numbered 2

    ### Long term
The journal script
    DAILYFILE="/Users/norrist/Projects/todo/daily/$(/bin/date +%F).md"

    if [ -f $LOCKFILE ]
            echo "$LOCKFILE PRESENT - ABORTING"
            read -n1 -p "Remove and Continue? [y,n]" doit
                case $doit in
                    y|Y) echo "Continuing with $LOCKFILE PRESENT" ;;
                    *) exit 1 ;;

            echo "NO LOKCFILE"
            touch $LOCKFILE


    if [ -f $DAILYFILE ]
            echo "$DAILYFILE exists"
            echo  >> $DAILYFILE
            echo  "-----">> $DAILYFILE
            echo "# $(/bin/date +%F)" >> $DAILYFILE
            echo  >> $DAILYFILE
            echo "### Projects" >> $DAILYFILE
            echo  >> $DAILYFILE
            echo "### Tickets" >> $DAILYFILE
            echo  >> $DAILYFILE
            echo "### Walkups" >> $DAILYFILE

    /usr/local/bin/edit -w --new-window $DAILYFILE
    /opt/local/bin/aspell -c $DAILYFILE
    /opt/local/bin/aspell -c $TODOFILE

    rm $LOCKFILE
    rm $DAILYPATH/


    for f in $(ls  -r $DAILYPATH/2*md)
     do cat $f >> $DAILYPATH/
     echo >>$DAILYPATH/

    cd /Users/norrist/Projects/todo; /usr/bin/git add . && /usr/bin/git commit -m "$(date)" && /usr/bin/git push origin master

Daily file template

    # 2016-08-02


    ### Projects

    ### Tickets

    ### Walkups
aspell is awesome

hpr2144 :: An Interview with All About Code at Manchester BarCamp

This is a follow up interview with Josh as he has been busy since I last interviewed him

Hosted by Tony Hughes AKA TonyH1212 on 2016-10-20 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Series: Interviews | Comments (0)

This is a follow up interview with Joshua Lowe as he has been very busy developing further python tools for the Raspberry Pi

The interview took place at BarCamp Manchester on the 24th September 2016 after he had done a talk about EduBlocks his new project for programming in Python and part of his Edupython project.

Josh will be at at the end of October and will be presenting his project again.

hpr2143 :: Gnu Awk - Part 3

In this episode, I go into more advanced topics for the awk tool.

Hosted by b-yeezi on 2016-10-19 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Series: Learning Awk | Comments (0)

Awk Part 3

Remember our file:

name       color  amount
apple      red    4
banana     yellow 6
strawberry red    3
grape      purple 10
apple      green  8
plum       purple 2
kiwi       brown  4
potato     brown  9
pineapple  yellow 5

Replace Grep

As we saw in earlier episodes, we can use awk to filter for rows that match a pattern or text. If you know the grep command, you know that it does the same function, but has extended capabilities. For simple filter, you don't need to pipe grep outputs to awk. You can just filter in awk.

Logical Operators

You can use logical operators "and" and "or" represented as "&&" and "||", respectively. See example:

$2 == "purple" && $3 < 5 {print $1}

Here, we are selecting for color to to equal "purple" AND amount less than 5.

Next command

Say we want to flag every record in our file where the amount is greater than or equal to 8 with a '**'. Every record between 5 (inclusive) and 8, we want to flag with a '*'. We can use consecutive filter commands, but there affects will be additive. To remedy this, we can use the "next" command. This tells awk that after the action is taken, proceed to the next record. See the following example:

NR == 1 {
  print $0;

$3 >= 8 {
  printf "%s\t%s\n", $0, "**";

$3 >= 5 {
  printf "%s\t%s\n", $0, "*";

$3 < 5 {
  print $0;

End Command

The "BEGIN" and "END" commands allow you to do actions before and after awk does its actions. For instance, sometimes we want to evaluate all records, then print the cumulative results. In this example, we pipe the output of the df command into awk. Our command is:

df -l | awk -f end.awk

Our awk file looks like this:

$1 != "tempfs" {
    used += $3;
    available += $4;

    printf "%d GiB used\n%d GiB available\n", used/2^20, available/2^20;

Here, we are setting two variables, "used" and "available". We add the records in the respective columns all together, then we print the totals.

In the next example, we create a distinct list of colors from our file:

NR != 1 {
    for (b in a) {
        print b

This is a more advanced script. The details of which, we will get into in future episodes.

BEGIN command

Like stated above, the begin command lets us print and set variables before the awk command starts. For instance, we can set the input and output field separators inside our awk file as follows:

    print "color,count";
NR != 1 {
    for (b in a) {
        print b, a[b]

In this example, we are finding the distinct count of colors in our csv file, and format the output in csv format as well. We will get into the details of how this script works in future episodes.

For another example, instead of distinct count, we can get the sum of the amount column grouped by color:

    print "color,sum";
NR != 1 {
    for (b in a) {
        print b, a[b]

hpr2142 :: Book Reviews

I take a brief look at two books others may find of interest.

Hosted by m1rr0r5h4d35 on 2016-10-18 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Comments (0)

It's been a while since I submitted a show due to time constraints. I was actually feeling pretty bad when I recorded the show, so my voice may not be as loud as usual.

The first book I talk about is "Hacker Culture" by Douglas Thomas

The second book is "A History of Modern Computing" by Paul E. Ceruzzi

hpr2141 :: Make Web Python with Flask

Klaatu talks about Flask, a Python-based web microframework

Hosted by klaatu on 2016-10-17 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Comments (5)

Klaatu talks about the Python web framework, Flask. Think Ruby-on-Rails but for Python, or a lightweight Django.

Links in this show:

hpr2140 :: Vim Plugins I Use

In this episode, I talk about vim plugins as I drive home from work

Hosted by b-yeezi on 2016-10-14 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Series: Vim Hints | Comments (1)

Vim Plugins I Use

hpr2139 :: From Org Mode to LaTeX Beamer to PDF

My presentation pipeline

Hosted by Clinton Roy on 2016-10-13 and released under a CC-BY-SA license.
Listen in ogg, spx, or mp3 format. Comments (1)

I have recently been fortunate enough to give a presentation to two conferences, PyCon Australia and Kiwi Pycon, the Australian and New Zealand Python conferences, respectively. I'm not going to give a talk based around the presentation, as it's rather code heavy, and we know that doesn't translate well to an audio medium.

Instead, what I wanted to do, was to talk a little bit about the presentation pipeline that I used to prepare this talk. The input is a plain text file, edited in Emacs, using a mode called Org mode. The intermediate form is a LaTeX file, using the document class Beamer which is designed for presentations that are going to be projected. Beamer is apparently the German word for digital projector. The final output form is a plain PDF.

HPR isn't known for having many Emacs talks, so I should probably explain the idea of modes. Emacs has major modes and minor modes. For every document that you're editing there's one major mode, and any number of minor modes. So if I was editing a Python file for example, I would have the Python major mode which understands Python and can thus do Python specific things like Python code completion, and I would have a spell checker minor mode to check the spelling of comments, and another minor mode to automatically line wrap comment lines that are very long, and another minor mode to show what line number I'm currently editing, and another minor mode to blink the cursor and so on.

The other topic that I haven't heard too much on is LaTeX. LaTex is the venerable typesetting solution for Unix based systems. LaTeX documents have a single document class, and then any number of packages. In the case of my presentation, the document class is Beamer, which sets up all the margins and fonts to be good for presentations. Some of the packages I'm using are the symbols package, for arrows and maths symbols, and several graphics packages so I can draw trees in my slides.

I'm fairly comfortable with LaTeX, I could certainly write this presentation directly in LaTeX, but I think there are some advantages in using Org mode to generate my LaTeX instead.

As the name suggests, Org mode is designed to be an organisational mode, helping you write TODO lists and organise documents. While the document is just a plain text document that you can read and write with any text editor, the Emacs Org mode understands its own mark up and provides an outlining mode, where you can hide and expand trees of bullet points. The basic layout of a set of slides for a presentation is a tree of bullet points, where the top level bullet points are slides, and the second level of bullet points are lists of information put into each slide.

Another mark up that Org mode understands is that of code blocks, so that we can easily say ``this chunk of code is a Python block''. Org mode understands how to export this Python code block as a separate file, run it under Python, and can even insert the output of the program, or the result of a function, back into the original document as a code output block.

The advantage of having just one file for my presentation, versus one file for my presentation and a separate file for each code block, is that the code examples in my presentation never get out of sync with the code that I'm actually running. This style of programming where the documentation is the primary document, and the code files are generated, secondary documents, is the inverse of the typical way of programming where the code documents are the primary documents, and documentation, the secondary documents, are automatically generated.

This style of programming, where the primary document is documentation is called literate programming. The process of creating the documentation (the PDF in my case) is called weaving. The process of creating the code files is called tangling.

I really like having just one file to generate one PDF presentation file, so I'm going to keep using this technique in the future.

Now, I have to admit that my presentation is not completely literate, there are some bits of output in my presentation that are copied and pasted, rather than automatically gathered, so I've still got some work to do.

Down to brass tacks. The conventional file name extension for Org mode files is dot org. The typical metadata you put in presentations are Author, Email, and Title. In mine I've also added Subtitle and Institute. Now, the interesting one here is Institute, for whatever reason, it's not a piece of metadata that Org mode knows about, but it's really easy to drop down into LaTeX and just use the LaTeX institute command directly.

There's a metadata line that Org understands called Options, I request that my presentation has a table of contents, and that all the bullet points of level two become line items in that table of contents. Then I'm straight into the slides. Bullet points at the first level are converted to sections, bullet points at the second level are turned into slides, and anything deeper than that are turned into contents of that slide. I have many code blocks, and I use options that specify what file this code block is tangled to, and to leave the white space alone when the code block is exported, as white space is critical to Python. I also turn on an option that gets line numbers printed for the code blocks. In a couple of places where I want to highlight certain areas of the code, I add labels to the code, then outside the code block I can refer to the label, and LaTeX will replace this with the line number. I think I'd prefer to do this referencing with highlighting, or an arrow or something, but I'm not sure I can do that.

Engineering is the process of dealing with tradeoffs to get something done, there are many trade offs when writing code to solve a problem, writing code for slides has quite a different set of tradeoffs, you want code to be easy to read, in terms of using long variable names, but you also need code blocks to contain as few lines as possible, so that you can use a large font size on the projector, and you also don't want to have to split an example across multiple slides if you can help it. I'm also of the view that syntax highlighting is a waste of time, it's just a pretty layer of obfuscation that the mind has to understand, then drop in order to actually see the code. This stance of mine was vindicated when several presenters with syntax highlighted code realised on the day that the projected code was impossible to read due to the low contrast projectors used in a reasonably well lit room.

One feature that I would like to add is the ability to reveal new code. It's quite common to have a code block, reveal a problem with it, and display the same code block again, but with a minor change that fixes the previously explained problem. Ideally the old code and new code would be rendered differently, but I don't think that's an option right now. The other thing that I couldn't work out was how to run custom programs on my code blocks, I was wanting to run the Python unit test program, not the Python interpreter, and could not find a way to do that.

There's a single command to run inside Emacs to create the output PDF, M-x org-beamer-export-as-pdf.

So, overall, I'm very happy with this pipeline. It lets me have a primary document with code snippets, and it lets me have LaTeX snippets wherever I like. It's not perfect, but I'm hoping to find ways to improve it.

Older Shows

Get a full list of all our shows.