In WordPress, determine whether a post has any given term out of a custom taxonomy

posted in code with 0 comments

This bugged the shit out of me yesterday, since WordPress doesn’t seem to have an equivalent to has_category() for custom taxonomies. If you don’t supply a term to check in the taxonomy, it checks all terms in the taxonomy.

function has_foo_taxonomy($term = null, $post_id = null) {
    $taxonomy = 'foobar';

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

    if ('' == $term) {
        $term_list = get_terms($taxonomy);

        foreach ($term_list as $a) {
            array_push($term, $a->term_id);
        }
    }

    return (has_term($term, $taxonomy, $post_id)) ? true : false;
}

by Mark -

Generic smartphone CSS media query

posted in code with 0 comments
@media only screen 
    and (min-device-width: 320px) and (max-device-width: 736px) and (orientation: portrait),
only screen
    and (min-device-width: 320px) and (max-device-width: 736px) and (orientation: landscape) {
        .foo {
            bar: norf;
        }
}

I see a great many media queries targeted for different devices-and it’s a good way of detecting the exact device viewing your site-but there doesn’t seem to be many rules for general smartphone use. This rule will cover screen sizes ranging from the iPhone 3S through to the iPhone 6, Samsung Galaxy II and Nexus 5.

by Mark -

Post dad, year 11

posted in family with 0 comments

I am supposed to be hard at work on a broken website, but I’m distracted by the topic of my dad, so here we all are. Tomorrow, Friday, is the tenth or eleventh anniversary of my dad’s death. I’m not sure and I don’t care to check, so let’s say eleventh. My dad was the fulcrum around which all the things I hate in Ireland rotate: the denial of mental health problems, our circumstantial poverty from his alcoholism, the ‘sure what will the neighbors think’ mindset and the refusal of our relatives and parents’ friends to intervene in what was a completely fucked up situation.

I’ve spent months of time spread over the last decade in trying to reconcile my dad’s conduct with and my misadventures with my ex-wife and children. Mum has been a source of constant admonitions to me to forgive and forget and my brother and sister have been silent, so I have been left to my own faculties for a resolution.

My dad, Francis, was an abusive alcoholic. His alcohol abuse started before I was born in 1981 and continued through to the end of the 1990’s. In that time he was a monster. Francis abused my mum, my brother, my sister and myself. He destroyed our belongings, beat us, and shouted at us; he stole mum’s money and let me take the blame. One year he smashed our Christmas presents because we fought over him. Another year, Jennifer was at a scout camp down in Ballyvaughan in Co. Clare. Mum and I went down for the day to visit Jennifer as part of some family open day, and mum left dad at home because he was drunk and unconscious. Mum couldn’t rouse him. When Francis finally crawled out of bed at some stupid hour and copped on to the fact that we’d left him at home, he smashed all of mum’s ornaments and mantlepiece knick-knacks. Dad went through the house, took mum’s stuff outside, and one by one destroyed them.

Dad, my sister and I

There was more. My dad tried to strangle me during a family row. I don’t even remember what the row was about. I wound up on my parents’ bed with his hand wrapped around my throat. I got my leg under Francis, kicked him off me and beat him halfway to a pulp. I think after that he took the hint and started to dry out because the frequency of bad fights decreased.

Look-there was lots of this spread over fifteen years. I could sit here all day and relate one awful anecdote after another about Francis, but in the end it is is the same sob story repeated ad nauseum. Maybe my brother or sister would say otherwise about dad, as they would have been old enough to know him before he got too bad, but I can’t find it in me to say any good word. Francis is this huge, sullen, drunk bastard who stomped all over my home life as a child. He was the reason we could never bring friends over and in my mind why we were so poor: he upped and quit his job one day, because, and then drank his dole and mum’s wages. There were points in time that Francis was one of the whinos in Eyre Square. Those drunks yours eyes just siddle past out of embarrassment? Yeah.

Mum would (and has!) argue that dad: had demons, was only human, had good days, loved us, wasn’t always bad and did lots for my grandmother Nora when she got sick. It’s hogwash; I had my own demons from my ex-wife. I came to home to mum with a diagnosis of PTSD and a row of knife marks down my arm. Her automatic response was to tell me to shut up, find a job and just get better, Mark. She visibly shut down and started to me out, because you don’t talk about that sort of thing, so if my dad did have problems, and had spoken, then she probably shrugged him off. In the end I discount anything she has to say because of this: she never once chose to protect her children from the monster who conceived them. We begged mum, on knees, to leave him, throw him out of the house. We barricaded ourselves into our bedroom more than once because we were afraid of him. All down through the years, mum sat around and wrung her hands in that all-too-Irish manner.

Francis died eleven years ago tomorrow. There is a memorial mass planned for him on Saturday, so I’ve made my own plans to be at the other end of the country with my girlfriend. Mum found Francis’ body on the kitchen floor, wrapped up in the tubes of his nebulizer and dead from what turned out to be an asthma attack. I called Jennifer (she was in the cafeteria at work) while mum freaked out downstairs. Then I went back to my computer and played Anarchy Online. Jennifer, Frank and all our cousins and neighbors turned up. Mum continued to melt down. Everyone else cried. I played more Anarchy Online. My cousin Willie brought to the hospital to make the formal identification of Francis’ body. This I did. I played more Anarchy Online.

The next couple of days was Anarchy Online interspersed with family tears. Jennifer turned on me at one point because I played so much of the game. Dad’s family came over from England for the funeral. His gobshite brother passed out drunk in the middle of the funeral mass. There were tears and hugs and fears and comfort from everyone else. Even my brother cried when they closed the coffin.

I felt not a single thing. Francis’ death was a fact to me, his body a symbol rich with factual meaning but without any emotional meaning. I didn’t feel anything when I saw his body in the kitchen, or the funeral home, mortuary, church or grave. I went back to work the next day and I haven’t looked back since. I’ve visited Francis’ grave maybe three or four times. Two of those times were to clean it and the third was to show my kids their parental grandfather.

As the years have gone by I have made ever-less effort to turn up to his memorials. I mean, I left the Catholic church in 2010 so I shouldn’t even be at their happy little ceremony in the first place. Their god will either smite me or hug me (depends on what testament you read).

Eleven years, and I’ve yet to miss him.

To be honest, despite this, I do wish I could have talked to Francis. I have survived abuse (not that I behaved any better and suicide, as well as PTSD, depression, anxiety and self-harm. I know the danger and temptation of drink: I’ve gotten drunk twice to escape negative feelings. It’s an easy and cheap out from all the shit in my life, so I can never take it. I am estranged from my ex-wife and through her from my children. I haven’t spoken to them in six months and I always wonder whether they’ll look at me like my dad. I put together all of this and I go back and try harder for my own children.

Dad-and his death-opened my eyes to the awful hypocrisy that runs deep here. Don’t talk about it, don’t deal with it, be mindful of the neighbours and always, always keep face, no matter the cost. I still go out, corner my mum and talk to her about my problems just because she needs to have her eyes opened this. She never wants to listen or do more than dismiss me, but to my shame I keep doing it. The chain of broken families endures for generations until the day comes that you stand up and decide to break it. Demons stay in the closet until you have at them with an old priest and a young priest.

Update: I raised taff with my family about dad. I don’t regret my anger, but I regret how I expressed it, because my mum and sister dug up their own feelings and aired them out too. They put put forward that:

  1. Dad demonstrated true remorse about his alcoholism.
  2. He wasn’t bad before or after his habit.
  3. Dad apologized at length to everyone for his behaviour.

I didn’t receive an apology, and now that eats me too. Did dad try to apologize? Did I ignore him? After all was said and done, I went to dad’s grave in Grealishtown on rainy Monday, and had a few choice words with him.

by Mark -

Move div between two columns in jQuery

posted in code with 0 comments

This annoyed the hell out of me for about three hours. I was asked to write a simple JavaScript game wherein you click or tap on elements in the left column to move them to the right in the correct order, and vice versa. If I set a left-to-right handler, this would carry over when the div was in the right div, which would effectively trap it there unless I reset the entire board.

My first solution was a recursive function that reset all associated click events on a click. It worked…for two or three cycles, before it crashed the browser.

My next solution was to not mess with the click handler, and instead just move the div to the first sibling of the parent:

$(div.leftCol).children().click(function() {
    $(this).appendTo($(this).parent().siblings().first());
});

Everything starts off in the left column. So if you want a click handler to swap between two columns-here you are.

by Mark -