Custom Quarantine PoSh Prompt

Since I’ve been quarantined at home and working in my office, every day is the same. I can’t go to the gym, or coach, or go to the restaurant, or much of anything. As a result, I regularly, forget what day it is.

Yes, it’s on my phone, but that’s not always open and visible. It’s on my watch, but I have to swing up my wrist and hope it lights up. Or reorient my wrist to see it.

I have Rainmeter running, which is nice, and I have a summary in the upper corner of my screen, but often I have something covering this.

2020-05-19 15_04_13-Microsoft Edge

The time is in the toolbar, but I sometimes hide toolbars to record things. Basically, I forget what day it is and I’m looking for a few hints I can use to make this easier. As I play with PowerShell regularly, I thought it would be good to update my prompt slightly.

Plus, it would be good PoSh practice.

Setting a profile. I’ve seen a few posts on customizing the prompt, and they all say I need a function, called prompt, in my profile. I found this article, which gave me a good idea. Put the time in the prompt.

I then had to figure out how to get to my profie. It turns out “notepad $PROFILE” in a PoSh prompt will get you there. If you don’t have a profile, you’ll see this:

2020-05-19 14_55_12-Notepad

Say yes, and then add some code. I had to look up the Format options and experiment a bit to decide how I wanted things to look.

function prompt {
        $lastResult = Invoke-Expression '$?'
        if (!$lastResult) {
                Write-Host "Last command exited with error status." -ForegroundColor Red
        }
        Write-Output "${msg}$(
                # Show time as 12:05PM and day of week
                Get-Date -Format "dddd HH:mm"
                # Show current directory
        ) $(Get-Location)> " 
}

I saved this and now when I get a new PoSh prompt, I get this:

2020-05-19 15_01_53-PoSh

Now I easily know the day and time when I’m working in a PowerShell terminal. This also shows up in my Visual Studio Code terminal as well, since that’s just a PoSh environment.

SQLNewBlogger

This was a quick thing I did in about 5 minutes to customize my environment, and help me be more productive. A happy employee works smoother.

I decided to show off how I did this and spend a quick 10 minutes writing down and documenting what I did.

Posted in Blog | Tagged , , | Comments Off on Custom Quarantine PoSh Prompt

The Challenges of Working Under Quarantine

It’s been nearly two months since the Redgate Software offices closed. I am not normally in the office, but I did cancel a trip that I normally would have taken to touch base with a number of teams. That’s a minor change for me, but a still a change. It’s much less than the change for most other people, and by now, I expect many people have somewhat adapted to working at home.

Working at home under this pandemic isn’t the same as working remotely. This has been forced upon us, and I agree with Scott Hanselman. Like me, he’s worked remotely for years, and this is different. We have kids, partners, roommates, and others around. We can’t easily change our scenery or engage in some of our usual activities. This is stressful, overwhelming, upsetting, disconcerting, and more.

Some of you might have accepted this and are learning to work in a new way. Some are coping, but expecting to go back to normal at some point. Some of us are getting much less work done, which adds another level of stress. Performance reviews, and the inevitable comparison with others will weigh on our minds. Whether we go back to normal soon or not, companies will add and remove staff. There are new projects to tackle, raises to award, and all the regular work of running a company.

This is a difficult time for all, and most of us are experiencing life in our own unique ways. Our view of the world, of coping and getting our daily work done is much different than our co-workers. Even if we appear to be the same people, we aren’t. We may react differently day to day, and there may not be a good explanation.

This is not the same as remote work, and I hope managers understand that. It is important that we all appreciate that our view of any big or little thing at work is not necessarily the same way others view the same action. A daily standup meeting might seem like a little thing to you, but perhaps it’s exam day for someone else’s child and they can’t focus, or maybe not even attend.

Be kind, be more flexible, and be more understanding. You never know what someone else might be dealing with in their life today.

Steve Jones

Listen to the podcast at Libsyn, Stitcher or iTunes.

Posted in Editorial | Tagged | Comments Off on The Challenges of Working Under Quarantine

Daily Coping 28 May 2020

I’ve started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here.

Today’s tip is to recall three things you’ve done that you are really proud of.

The Snowboarding Investment

I started snowboarding before I had kids. I got pretty good, and I’ve enjoyed going fast, avoiding breaks, and making the most of the time I have on the slopes. As my kids grew up, we started all of them on skis, and in ski school. Expensive, but it allowed them to learn from someone that wasn’t a parent and it allowed my and my wife to continue to enjoy ourselves. As they learned, we enjoyed them learning to keep up with us.

For my younger two, they wanted to start snowboarding relatively quickly after learning to keep up with us adults on skis. Rather than do more ski school, I took the time to work each each of them. My son was older, 11 or 12, when he wanted to switch, but taking days to teach him meant I was really on the beginner slopes with him, not having a fun day.

407428_3246577052191_1422307751_n

It took the 4-5 days at the end of one season and 2-3 at the beginning of the next to get him to the point where we could progress to a continuous run down Keystone or Copper mountain.

My daughter started younger, which was harder. She was barely on skis when she say her brother snowboarding and wanted to try.

10391628_1266488471214_3245615_n

This was many more days, often family days where I would spend half the day walking alongside her, or holding her balanced and helping her learn how to move down the slopes.

I had to put aside fun times to invest in them. It’s paid dividends over the years, and I’ve had great times with them on the slopes. I’m really proud of spending the time to teach them and then watching them grow and learn to love sliding down the mountain.

Ranch Improvements

We moved to a horse ranch about 15 years ago, and my wife started full time teaching about 10 years ago. As she’s tried to experiment with her skills as a horse whisperer, she’s asked me to help build things to help her better care for horses.

She gave me the challenge of building slow feeders years ago, and I spent some trying different designs and building her feeders that work well for her purposes. Here is one of the early designs. Hint, plywood doesn’t work well over time.

1097896_10201736507843332_1419379804_o 

Some have now been in service over a decade, and I’ve built quite a few more. We have 13 in use and 2 spares now. Recently, she also got the idea that she wanted a horse back scratcher, so I figured out how to do this.

92938268_10221411947757033_154728138163617792_n

SQLServerCentral

It wasn’t my idea. Credit goes to Brian Knight for the idea and helping bring the founders together. Over the years, a lot of the site has grown and evolved because of me. I was the founder that was able to work for the company full time, I started the editorials, and I’ve been the face of the site for many years.

I remember crossing 1 million posts, 1 million subscribers, publishing books and a magazine, hosting parties at the PASS Summit, and getting the chance to meet many of you in person over the years have been highlights.

Hearing many of you tell me that the site has helped you in your career, has solved a problem, or inspired you in some way are immensely gratifying to me. I can’t tell you how much I’ve appreciated the kind words and comments from many people over the years.

I’m grateful to Redgate for allowing me to continue to steward the site as the Editor in Chief, and this has been one of the things I’m most proud of in my career.

Posted in Blog | Tagged , , | Comments Off on Daily Coping 28 May 2020

Using WAITFOR to Test Slow Code–#SQLNewBlogger

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

One thing I needed to do lately was test how a calling program would respond to slow code. I decided to use a normal query, but add a WAITFOR() to simulate different delay levels. However, I had to look up the syntax for the call and I decided to blog about it.

WAITFOR DELAY

The WAITFOR call isn’t a function. I’ve written about that before. Instead, this is listed as a control-of-flow element in the language.

I have a rough idea of how this works. I use

WAITFOR DELAY

as the basic syntax. SQL Prompt helps me here, since looking this up is a pain and slow. I know there is a time element in here, but I always worry I’ll pick the wrong time and then sit for a long time testing.

The key is this format: hh:mm[[:ss].mss]

To delay for 2 minutes, I write this:

WAITFOR DELAY '00:02:00'

 

That gives me what I need, and using a string variable, I can control this delay programmatically.

SQLNewBlogger

This is a good example of learning a piece of code and writing about it. Short, simple, show how this one works in T-SQL. Add the why, show some code, and results. How you use it, and what you learned.

This was a 10 minute post.

Posted in Blog | Tagged , , | Comments Off on Using WAITFOR to Test Slow Code–#SQLNewBlogger