• Replace Multiple Occurrences of a string or char in SQL Server

    It is unbelievable to me that Microsoft SQL Server does not support regular expressions. In the absences of regex, replacing multiple occurrences of the same string/char becomes super tedious. You can nest multiple Replace() statements which gets ugly and impossible to read and you have to know exactly how many multiple occurrences there are. But for a current project I have to replace all line breaks in a column.
    Here’s how I did it:

    WHILE EXISTS(SELECT * FROM #yourtable WHERE (Comments like '%'+char(10)+'%')) --note I knew that char(10) and char(13) always occurred next to each other and in an effort to speed up this loop got rid of the char(13) filter
    BEGIN
    
      UPDATE #yourtable
      SET Comments=REPLACE(Comments,char(10),' ')
      WHERE (Comments like '%'+char(10)+' %')
     
       UPDATE #yourtable
      SET Comments=REPLACE(Comments,char(13),' ')
      WHERE (Comments like '%'+char(13)+' %')
     
        -- again you can probably do this in one statment but I was hoping to speed it up by simplifying the where statements. 
     
    END

    There are no doubt a dozen ways to optimize this but it seems to have worked and didn’t take forever. Good luck out there, folks, working with a “modern” RDMS that doesn’t support regex.


  • Bullshit.

    Wealthy white boys from North America are more likely to be full of shit than other kids:

    Having derived and established the comparability of our bullshit scale via measurement invariance procedures, we go on to find that young men are more likely to bullshit than young women, and that bullshitting is somewhat more prevalent amongst those from more advantaged socioeconomic backgrounds. Compared to other countries, young people in North America are found to be bigger bullshitters than young people in England, Australia and New Zealand, while those in Ireland and Scotland are the least likely to exaggerate their mathematical knowledge and abilities. Strong evidence also emerges that bullshitters also display overconfidence in their academic prowess and problem-solving skills, while also reporting higher levels of perseverance when faced with challenges and providing more socially desirable responses than more truthful groups.

    Here’s the study: Bullshitters. Who Are They and What Do We Know about Their Lives?


  • 2019-04-29 14.01.11

    Whoa. Mesh. Where have you been all of my life? Picked up a Netgear Orbi bundle the other day on Amazon. All of a sudden all of my Rogue Amoeba Airfoil setup is WAY more stable and predictable. Stoked. Detailed review forthcoming. #wholehouseaudio #firstworldproblems


  • 2019-04-26 12.16.44

    surly

    Ten years ago Kyle built up my Surly LHT and he’s been my go-to guide for all things bikes ever since. New Jersey is so lucky to call this guy our own. Terrific to see him getting some recognition on The Radavist. #surly


  • Freedom vs Function

    Great piece by Brent Simmons (the guy who originally wrote MarsEdit, the app that I’m writing this entry in) about the freedom to make your computer your own and how that freedom is slowing eroding away.

    With every tightened screw we have less power than we had. And doing the things — unsanctioned, unplanned-for, often unwieldy and even unwise — that computers are so wonderful for becomes ever-harder.

    G4

    Just this week I built up an old Mac G4 with OS 9.2 on it with my son and recalled how much I loved Mac OS 9 and the flexibility to make it look and do all sorts of crazy stuff (Drag Thing!) That’s not so much the case with OS X and Marzipan threatens to make OS X even less flexible under the hood. The only real freedom and flexibility the end user has (besides changing the wallpaper, etc.) is at the command line. If that ever goes away then Linux starts to look very attractive from a desktop perspective.


  • Day One Morning Health Shortcut

    Some folks over on the Day One Community FB group were interested in this shortcut I wrote. It computes your 7-day average for active energy and steps, asks you a few questions and creates a Day One journal entry. You will need to modify this shortcut. It’s a little tricky as it pulls health kit data which is really fiddly. You can drop me a note if you get in too deep but I can’t promise I’ll be able to make it work for you. Download the shortcut here.

    I find the seven-day average data more interesting and useful. It was this podcast with Jim Collins that got me thinking about using multi-day averages to track certain metrics (e.g. as long as I’m average about 40 minutes per-day singing and playing guitar, I’m making progress, if my seven day average slips below that I am just treading water). Collins uses a 3month, 6month and 365-day average as opposed to 7, but the gist is the same. Very interesting approach to self-quantification. Go to the podcast and fast-forward to the 45-minute mark, great information.


  • 2019-04-20 20.56.36

    Was out cruising in the Atlantic Ocean this past week so broke my streak of posting but I’m back. Here’s a picture from the trip.


  • Ed Boyden on Minding your Brain

    I listened to this absolutely fascinating podcast yesterday. Tyler Cowen is a great interviewer and he and Boyden cover such a huge range of neuroscience topics: from mental illness to optogenetics to ketamine to meditation to blowing up bits of your brain using a material like the use in diapers so that the bits are large enough to study under a microscope. Really, really great discussion. Definitely worth your time, give it a listen.

    BOYDEN:I think one of the things we have to figure out is how can you detect consciousness, and how can you create consciousness? Alan Turing proposed the Turing test, where you would converse with something and you could try to decide whether it was conscious. But with Siri and Alexa and all this stuff in homes and on phones nowadays, I think everybody would agree that’s probably not enough. You need to know something about the internal state as well, but we don’t have a firm grasp on that yet.

    I also loved this exchange:

    COWEN: Is there a puppet master in the theater, or is it a kind of nominalist reality, where all there are are the different desires? And maybe the film involves a kind of illusion that someone’s in control, but that’s just another actor in the play?

    BOYDEN: Here’s another way of looking at it, which is there’s so many things that we’re consciously aware of, but the vast majority of the things that the brain is doing, we’re probably unconsciously aware of.

    For example, here we are in my office, and there’s all sorts of stuff around. Your brain has been processing a lot of it. If I point at that blue highlighter over there, you probably saw it earlier but were not paying conscious attention to it. But now that I point at it, you are consciously aware of it.

    I actually think that something that we have to understand is, how are all these unconscious processes — this roiling sea of stuff that we have no access to — how are those processes contributing to the emergence of consciousness?

    That’s one reason why I’m very excited to study the process of consciousness, if you will. What are the processes in the brain that lead to it that happen beforehand and that might help us understand, in a causal way, what gives rise to consciousness? But again, this is just an idea right now.


  • 2019-04-12 15.07.12

    Love it when shuffle gives you EXACTLY the right song for snaking through Red Bank traffic.</>


  • 2019-04-10 13.15.55


    5 years ago today (thanks Day One for the reminder). Seems like we’ve done a lifetime of travel in this thing and it’s only been 5 years. #bestpurchaseever


Current Spins

Top Albums

Check out my album Set It All Down on your favorite streaming service.


Posts Worth Reading:


Letterboxd


Reading Notes

  • Who profits from our constant state of dissatisfaction? The answer, of course, is painfully obvious. Every industry that sells a solution to a problem you […]
  • the shifts have been in place for awhile. A certain kind of book—say those reviewed in the NYRB—will become like opera, or theater, or ballet, […]
  • • No more struggle: “Whatever arises, train again and again in seeing it for what it is. The innermost essence of mind is without bias. […]
  • The real problem, in my mind, isn’t in the nature of this particular Venture-Capital operation. Because the whole raison-d’etre of Venture Capital is to make […]
  • . The EU invokes a mechanism called the precautionary principle in cases where an innovation, such as GMOs, has not yet been sufficiently researched for […]

Saved Links

RSS Error: A feed could not be found at `https://links.jimwillis.org/feed/atom?`; the status code is `404` and content-type is `text/html; charset=utf-8`