Books. Music. Programming. Publishing. History. Purchase. Interviews.

Leif M. Wright is author of true crime thriller
Deadly Vows, murder mystery novel
Minister of Justice and the upcoming novel
Robby the R-Word.

I now have a solution to the "smart quotes" issue that has dogged me for so long. To recap, "smart quotes" are quotation marks that face the text they're quoting, and apostrophes that face the larger part of the combined word, and doing them in the programming language PHP is incredibly difficult.

So I finally got it to work, and here is the code I used to do so:

function educate_quotes($string) {
        //set up patterns to look for (dumb quotes, etc)
        $pattern = array('/\b"/',//right double
                    '/"\b/',//left double
                    '/"/',//left double end of line
                    "/\b'/",//left single
                    "/'\b/",//right single
                    "/'$/",//right single end of line
        //set up html entities to replace them with
        $replace = array("”",//right double quote
                    "“",//left double
                    "”",//left double end of line
                    "’",//left single
                    "‘",//right single
                    "’",//left single end of line
        //split into array with tags on their own line
        $new_string = preg_split("/(<.*?>)/",$string, -1, PREG_SPLIT_DELIM_CAPTURE);
        //iterate through each array item, change quotes to non-html items
        for($i=0;$i<count($new_string);$i++) {
            $str = $new_string[$i];
            //some array items are empty. skip them
            if ($str) {
                //if this item doesn’t contain an HTML open tag
                if (strpos($str,"<") === false) {
                    //replace dumb quotes and apostrophes with smart equivalents
                    $new_string[$i] = preg_replace($pattern,$replace,$str);
        //turn the array back into a string
        $str = join('',$new_string);
        return $str;

The issue all along was that "smart quotes" mess up HTML tags (the little bits of programming like <b> that cause text to be bold or <a href=""> that create links for you to click). Teaching a computer program to change quotes to "smart" quotes in text while leaving HTML tags alone is surprisingly difficult.

PREG_SPLIT_DELIM_CAPTURE splits the string into an array, with items surrounded by HTML tags <> being on lines of their own, so I can process and work ONLY on strings that don't have HTML tags in them.

So this solution works, and it is in production on my news sites. Feel free to steal it.

In another of those "this is really too bizarre to be true" situations that seem to pop up with regularity in Oklahoma comes the case of Misty Velvet Dawn Spann and her mother, Patricia Spann, both of Duncan, Oklahoma.

It seems Patricia Spann hadn't seen her kids until a few years ago, and when they reconnected, they really reconnected.

In 2010, Patricia married her son, Jody Spann Jr., who promptly filed for annulment, citing "incest" as the reason.

Undeterred, earlier this year, Patricia Spann married her daughter, Misty. She had "looked into it," she told her daughter, and she was pretty sure they weren't breaking any laws, because her name was no longer on Misty's birth certificate. Misty, it seems, didn't realize her mother had already been married to her brother.

If you have the stomach, read the affidavit here.

I guess, they're keeping it in the family.

The subconscious mind is a weird thing, and it shows its usually-obscured face to us when we are sleeping.

For instance, more than one novel I've been writing has been completed due to a dream telling me who did it, or how to steer it, or how the main character would react.

Numerous programs I've written have been completed because dream-me told wake-me how to solve the niggling problem that had been keeping it from working the way I had envisioned when I started it.

I've even written songs in my sleep.

But the strangest of these phenomenon, to me, is the fact that many times, I dream in computer code. Like, I'll wake up and have an entire computer program in my mind from the night, when I dreamed it up. And without exception, the programs work when I type them in and compile them.

There is even a web site dedicated to that idea.

Ultimately, I don't think it's that unusual. I read somewhere that dreams are our brains' ways of preparing us for real life situations. The example I read whenever and wherever was that people often dream of fighting, and that is their brains teaching them to react to situations they expect might come up at some point; a random assailant attacking them on the street, and how they should respond to preserve their life - and ostensibly the ability to pass on their genes to the next generation of obese Walmart addicts.

So if our unconscious brains are really going through scenario after scenario in attempt to prepare our conscious brains for situations expected to arise, it's normal that someone who spends a lot of time programming might dream about such a thing. Or songwriting. Or book writing. Or picking lint out of toenails. Whatever.

The point is, subconscious me is a lot smarter than conscious me. So rather than fight it, I embrace it. And hope it never stops.

If you've ever seen Penn & Teller: Bullshit, or Good Eats, you'll understand me. (If I could be friends with Penn Jillette or Alton Brown, I'd consider my wish granted)

I love things that debunk popular belief, and I love things that use science to explain things we take for granted.

Knowing those facts, you'll be completely unsurprised to know I love the show called "Adam Ruins Everything" on TruTV.

It's like a combination of Bullshit and Good Eats. Adam (whatever his last name is) is a standup comedian who uses facts, research and science to shatter popular myths about commonplace things we all believe and love.

And it's EXACTLY who I am, and what I love.

A friend (Daughin Chan, if you must know) once described me as an icebreaker ship - the boats that go through arctic ice, cutting the way for other ships to sail on water by breaking ice with hardened hulls. What that means is I cherish above all other things shattering the misconceptions that encapsulate and imprison the minds of people.

And that's exactly what Adam Ruins Everything does. Like Bullshit, it challenges preconceived ideas with scientific facts and statistics, and like Good Eats, it uses nerdy facts and a nerdy host to delineate those things with humor and aplomb.

I just started watching tonight, but I'm already halfway through the first season.

I recommend it to anyone who wants to understand why I'm such a pain in the ass.

There is an alleged child molester living in my hometown who does really bizarre things. I mean, even more bizarre than what he's accused of doing (including possession of child pornography).

Today, he posted this to a Facebook page he controls:

And then, in the comments, he posted this:

What's bizarre about that? you might ask. Well, I spoke to some law enforcement people who are familiar with his case, and they confirmed that the screenshot above is actually FROM his case. Like, the blueish bubbles are him and the white bubbles are an underage person he was talking to.

That is just incredibly bizarre, as far as I'm concerned. This isn't "news" enough for me to post to my news site, but I thought it was just too weird to ignore completely.

Earlier this summer, I sold half of several of my non-Muskogee news and information properties to an investor who is motivated to amp them up as intensely as possible.

At a meeting with that investor yesterday, he convinced me that the news properties need to reinstitute comments (if you read this blog, you know comments are the bane of my existence), so I've been coding on that tonight.

But he and I had a long discussion, and part of that discussion involved several things I had been planning to add to my sites, and he confirmed my opinions on those. It's definitely the next step in the evolution of my business - even that part of the business where I remain sole owner. These improvements, which will be coming in the next week or so, will vault my sites to the level I originally envisioned for them seven years ago.

My stuff is all about efficiency and low overhead. Currently, I can do the jobs of 12 people in half a day of work. That's not bragging; it's just a fact, due to the advanced computer programs that I have created through the years to enable my sites to run efficiently. I'm very proud of what I've accomplished so far, and I would talk in great detail about it here, except a lot of it is proprietary, and therefore I can't reveal its inner workings.

I'm very proud of what I've accomplished so far, but not nearly as proud as I will be when I launch the new features that are coming in the next little bit.

Warning, there's graphic language in that video.

Let's get some shit straight right now. I generally lean left politically, if you couldn't guess that from, oh, everything on this site and in my books. That means I think the police state is a real thing, the thin blue line is a serious problem, and in some cities, police act with a vicious racial bias.

With all that said, I give you the video above. I posted it on Facebook yesterday around this time, and from that time to this, it's been viewed 100,000 times. The video is police dash cam and body cam footage of an 84-year-old woman being pepper sprayed by police in her home in my city of Muskogee, Oklahoma.

Initially, the local Fox station ran portions of the video edited to make it look like the police broke into her home and aggressively pepper sprayed this poor, frail grandma with no warning. So I issued a Freedom of Information Act Request to the local police department for all the raw video associated with the incident.

And man, was I surprised at how different the real story was from the one portrayed on the Fox station. Turned out, the woman's son, a lifelong felon who just got out of prison, was eluding police, then refused to obey police orders to stay in his car after they finally pulled him over in his mother's driveway. Then he refused their orders to not go into the house, since they didn't know whose house it was and whether he was committing a home invasion or what.

Once inside the house, the man refused to open the door, cussing police out and generally acting crazy. So the police kicked the door in and eventually tased him. His mother, a longtime drug dealer, came out, started acting crazy, cussed the police out and refused to comply with their simple orders to turn around so they could take her into custody while they secured the house and made sure nothing crazy was going on. So they pepper sprayed her.

And the community is in an uproar about how they could have used other methods to subdue her, how they should have waited for a warrant to get into the house, how police are horrible. The state NAACP made it into a racial issue, since the woman is black, and began calling for heads to roll at the police department.

Here are some facts:

  • If you elude police and then disobey their orders to stay put and instead go into a house, they have probable cause to kick your door down.
  • If you're acting crazy and not obeying their orders while you demand that they tell you why you should put your hands up and walk toward them, you will be tazed because the officers fear for their own safety and the safety of anyone else who might be in the house.
  • If you come out and start acting crazy, cussing the cops out and refusing to turn around so they can detain you while they search the rest of the house, they will pepper spray you and take you into custody anyway, because elderly people can kill and injure others just as well as young people can.
  • The bottom line is this: if a police officer tells you to do something - even if they're wrong - the law is clear: do what they tell you to do and if they're wrong in telling you to do it, fight it in court later.

But people are set in their opinions that the police are trying to attack black people. And again, I generally fall on the side of agreeing with them. But in this case, this wasn't a black and white issue. This was a crazy and sane issue, an obey and disobey issue.

As a society, we entrust police with lethal force, because sometimes unfortunately, lethal force is necessary to keep the peace and safety of the population. As such, the law demands that you obey police orders so you can avoid being the subject of that lethal force. The law provides remedies for you if the police wrongfully detain or arrest you or treat you poorly while you're in their custody.

If you're acting crazy and the police have to use nonlethal force to detain you, count yourself lucky that they used such restraint.

I'm not saying it's a perfect system, but the fact is, police officers die all the time in the legal execution of their duty, and to keep themselves safe, they have to use measures that the rest of us might consider extreme. That said, some police officers overstep their bounds and use excessive force. Those police officers should be terminated and imprisoned and their victims should be compensated. But that wasn't the case in the video above. The fact is, the woman and her son got what they should have expected was coming, because they were acting crazy and refusing lawful orders from police officers who clearly identified themselves and treated them with respect as far as was possible.

For the last time, I'm usually on the side of "the racist and bully police need to calm the hell down", but in this case, I think making it about race and then pushing the idea that the police were out of line simply because of the age of the woman who was obstructing and resisting them plays into the already heated rhetoric that is leading to unrest across the country.

And that shit needs to stop.

It really illustrates a point I think is salient for most aspects of life: most people do not like to think for themselves. Oh, they think they do, but when it comes down to brass tacks, they want to be told what to think. So when a media source like the local Fox station tells them "this is the story and exactly how it happened," they have no reason to question that narrative, even when it is foisted upon them by a clearly biased reporter with an agenda to push. My entire report on this incident began with a simple question after watching the Fox station's report: "What happened before they sprayed this woman in the face?"

To rephrase, "What aren't they showing me?"

If people would ask themselves that question more often, maybe some of the craziness we're witnessing now would be quelled.

  • As a side note, I'm pretty proud of my newfound video editing skill. I spliced together the dash cam and body cam footage, then painstakingly added the subtitles. Like a boss, I might add.

UPDATE: Here's a conversation I had with a local attorney friend of mine about this post. For the record, he leans right in his politics, I think. (I'm the blue bubbles; he's the gray)

"Smart" quotes are hard to pull off.

Quotation marks are supposed to enclose the text they're quoting, at least in American English. For instance, this is a sentence quoted without "smart quotes":

"Hi, I am being quoted!"

And here is a sentence with smart quotes:

“Hi, I am being quoted”

If you don't recognize the difference, this post isn't for you. The point, however, is it's a small thing that drives grammar nerds like me crazy. It is a surprisingly difficult problem to fix programmatically. For instance, how does a program know for sure a quotation mark is at the beginning of a string of characters and not at the end? It matters, because the one at the beginning has to face right, the one at the end has to face left. What about apostrophes? They face the same issues as double quotes, but you can solve the double quote problem by simply checking to see whether the quotation mark is at the beginning or the end of the string.

For apostrophes, it's much more complicated, because like in the word "it's", the apostrophe sits between two characters, but apostrophes can also be used as embedded quotation marks when someone being quoted is quoting someone else, like this: "Hey, I'm being quoted while quoting another person who said 'I'm being quoted.'"

So, like I said, complicated.

I have developed a function to handle this in PHP, but also to handle special circumstances (in my narrow use case, images) where tags inside the text must use the straight quotes instead of the curly quotes in order for a web browser to render them correctly.

So without further ado, here's the function I came up with (and am currently using on my news sites):

Pretty nifty, right? I'm still refining it, and I'm going to have to change the image-specific special tag cases to be more universal, but eventually, it's going to be a big help to PHP coders who hate straight quotes. Also entertaining - the comments in that chunk of code where I call myself lazy. Like you do.

UPDATE, September 5: In the interest of full transparency, I have abandoned this approach, because it's buggy, especially when dealing with things like trying to post HTML5 video, which requires quotation marks inside HTML tags. I'm sure I could write a pattern to deal with that, but I found a Javascript that does the same thing and I don't have to do any coding. So while I still think this is a nice piece of coding, I'm not using it anymore.

The way I work is scattered and kind of chaotic. I work on one project until I hit a wall and then I skip to another project.

If you look at the picture above, the column to the left is the list of books I'm currently writing, minus Robby The R-Word, which is about to send out initial hard copy proofs to reviewers and me.

Because I'm kind of scattered.

And by the way, the program you're looking at there is my WriteEverywhere platform, which I coded earlier this summer. so far it's great.

This old Victrola record player is worth maybe $100.

When I was 10 years old, I had one of the best memories with my dad - he and I took an old stand-up Victrola record player he had inherited from someone and painstakingly restored it, stripping decades of black paint by hand, carefully sanding out dings and dents, and then staining and sealing the wood back to its original factory condition.

As a reward for how hard I worked, Dad gave the hand-cranked record player to me, and I proudly displayed it in my room from that day until the day I left for college.

Shortly after I left for college, my dad and mother got divorced, and Dad took the Victrola with him for safekeeping while I was young and wild, which I think was a pretty smart move.

My relationship with my father over the years has been complicated. We disagree on more things than we agree on, and I still have a lot of scars over how I was treated as a child, he I think, had scars over how I basically left home and never looked back.

Last Saturday morning, my dad died.

His new family apparently was pretty upset with me for some things I had said about Dad, but that just shows they didn't understand our relationship, because that was an ongoing dialog between him and me. They set the funeral for Monday, just two days after he died, and when my 82-year-old aunt, who raised my dad, called my dad's step-son to ask if it could be pushed back a day or two to accommodate out-of-state people who wanted to come pay their respects, he called her "everything but white" and used so many f-bombs on her that she lost count. And then he threatened to "punch her out" if she didn't settle down and do what he said.

He was furious over how I had spoken about my dad, and some ugly things I had said about his sister after she rudely confronted me and inserted herself into my final moments with my dad.

They made it clear that I wasn't welcome at the funeral, and that my wife (who had done nothing) would be barred from entering.

Today, my sister went to my dad's house to retrieve a few sentimental items that my dad had specifically asked to be passed on to his children. I didn't ask for anything, but I kind of expected that the Victrola, which was given to me 37 years ago, might make its way back to me, and I was happy about it, because it was a memento of one of the few good moments I had of my childhood with him.

Nope. My dad's wife put her foot down. The Victrola was in her office, and she just hadn't had time to go through the stuff in her office, so it would stay. I don't know what's to "go through," since it's just a big hunk of wood with a non-functioning hand-crank turntable. The fact is, despite my dad's explicit instructions, she had no intention of letting me have my Victrola, the one I worked so hard on, the one that represented in physical form the memory of one of the very few good times of my childhood.

I had already instructed my sister to not make a big deal out of it, because I figured they were going to pull a stunt like this, and frankly, I'm not very interested in engaging in a lot of drama.

So to my dad's widow, Roselyn Wright, keep the Victrola. Seriously. I hope it makes you feel good and you enjoy it the rest of your life. I lived this long without it, I'll be fine. To her family, DeWayne Eddington and Jamie Eddington Clinton, I hope you never have to face negative consequences for how you treated my dad's grieving family because of a petty disagreement with me, and I'm sure you're glad you'll never have to hear from me again for any reason. May your life be full of peace, joy and satisfied minds.

I will still have one of my few happy childhood memories, with or without the object that personified it. I'd rather you have it and have peace now.

← Older articles