Über-crude incrementing post view counter for WordPress

posted in code with 0 comments
function increment_view_counter($post_id = null) {
    $key = 'mark_view_counter';

    if ($post_id == '') {
        $post_id = get_the_ID();
    }

    if (is_single() && !is_user_logged_in()) {
        $count = (int) get_post_meta($post_id, $key, true);
        $count++;
        update_post_meta($post_id, $key, $count);
    }
}
function get_view_count($post_id = null) {
    if ($post_id == '') {
        return;
    }

    $key = 'mark_view_counter';
    $count = (int) get_post_meta($post_id, $key, true);

    if ($count == '') {
        update_post_meta($post_id, $key, 0);
        return 0;
    }

    return $count;
}

by Mark -

Friday

posted in me with 0 comments

Tuairisc.ie at launch

The past few months have been ones of continual-and cumulatively large-changes in the status quo of my life. As much as I tell all of my friends in dire straits “this too shall pass,” it has been jarring to realize that the same thing has happened in my own. On Friday night I attended the formal launch of the Tuairisc.ie website at the Mansion House on Dawson Street. I’ve spent the last few weeks working with the team of this Irish language news and opinion website both remotely and at their offices in Barna after I was sub-subcontracted to develop portions of the backend. By the end of the work I had had an influential say in the appearance of elements of the site. I was mentioned by name twice to Irish national media in a speech given at the launch event. At the moment that the site actually went live, I was the person who quietly flipped the switch while the actors gesticulated on stage.

I swept out of the Mansion House with with Eadaoin after all of the speeches were said and done, for dinner with Eadaoin at Yamamori on the quays. I had even made reservations in advance! I feel adult and capable as I never had in the past. I made plans, came to decisions, acted on them and finally reaped the satisfaction of the rewards. At last I feel like I’ve stepped out of the shadow of my awful ex-wife’s punishment of independent action.

But right now I’m tired; there was a straight twenty four hour-long grind to finish the site and input content before the launch event, and I walked back and forth around Dublin yesterday for a good six or seven hours. I’m tired, but I’m good and whole as I haven’t been in a very long time.

by Mark -

So I swear a lot here

posted in the website with 0 comments
#!/bin/bash
# List compiled from:
# Slate: http://goo.gl/vPC4X4
# Wikipedia: http://goo.gl/mdcyT8

swear_words=(
    'shit' 'fuck' 'damn' 'bitch' 'crap' 'dick' 'bitch' 'crap'
    'dick' 'piss' 'pussy' 'fag' 'asshole' 'cock' 'bastard' 'darn'
    'douche' 'slut' 'whore' 'christ' 'jesus' 'arse' 'bloody' 'bollocks'
)

if [[ -f "$1" ]]; then
    echo -e "\t\nCount for swear words in $1:\n\t"
    printf "%-12s %s\n" "Word:" "Count:"
    echo "----------------------"
    for w in "${swear_words[@]}"; do
        n=$(egrep -o -i $w "$1" | wc -w)
        printf "%-12s %s\n" $w $n
    done
else 
    echo "Error: $1 is not a valid file"
    exit 1
fi

exit 0
Word:        Count:
----------------------
shit         1323
fuck         2933
damn         146
bitch        318
crap         475
dick         62
bitch        318
crap         475
dick         62
piss         384
pussy        4
fag          4
asshole      201
cock         362
bastard      160
darn         16
douche       2
slut         0
whore        116
christ       1224
jesus        73
arse         632
bloody       176
bollocks     0

by Mark -