Sunday, August 25, 2019

Setting the Default Terminal to zsh In VS Code

If you are like me, you've fallen in love with both VS Code and zsh.  VS Code has made my Angular and Ionic development much easier.  And if you are here, you know zsh is the most beautiful shell out there.  So, how do you mash them together?

It turns out it's pretty easy... much easier than it used to be.

Just fire-up any project in VS Code.  Then bring up the terminal window (Control ~).  Next, look for a dropdown that is on the right top of the terminal window.  If you click on that dropdown, you can select zsh and make it your default.





Happy coding.

Wednesday, January 16, 2019

Mac OS Mojave Dark Mode - Set Mail Background to White

This is an example bad-looking email.
I don't entirely hate the Mac OS Mojave Dark Mode.  It's kind of a cool, different view of our real estate.  I don't know that it was entirely worth the download, but at least my Mac isn't bothering me every day to upgrade.

Anyway, one problem I had was that email backgrounds were all dark.  This made reading emails super-tough when I got replies in dark text.  Emails never quite look right.  Well, there is a fix for it!

To return your Mac Mail emails to defaulting to white, follow these steps:
  1. First be in Dark Mode (Apple -> System Preferences -> General.  Set Appearance: Dark)
  2. Next, open Mac Mail and go to Mail preferences.  Mail -> Preferences
  3. Select the Viewing icon
  4. Un-check the Use dark backgrounds for messages

Have an awesome, productive day!

Friday, June 22, 2018

Regenerating XSD Dataset After Change

I find myself constantly having to maintain projects built with XSD datasets.  The thing I always *strongly disliked* about XSD's is their tendency to be fragile.  Whenever I make a change everything breaks and I'd end up fooling around for a 1/2 day getting it to work again.

Well, I think I've finally figured out how to make changes to an XSD, then regenerate the schema correctly.  Here are the steps that are working well for me now:

Open the XSD and make whatever changes you need.  In this sample, I'm just adding a new column to a SQL Server stored procedure.  Once I've made the change in the stored procedure, it's time to synchronize the XSD.

Go to the XSD view in Visual Studio, right-click on the object you need to change and click "Configure."


Go through all the steps of configuring that item...


You will notice that there is a file called "...Designer.cs".  This is the file auto-generated by the DataSetGenerator tool (or at least it's supposed to be auto-generated).


If this file isn't being changed, you can force it to make a new one.  First, delete the Designer.cs file (Right click => Delete).

Then right-click on the .XSD file and select "Run Custom Tool".  This will regenerate the Designer.cs file and you should be off and running.



What?  You don't have a menu item that says "Run Custom Tool"?  Then you need to add it to the XSD file type.  You do that by left-clicking on the XSD file, then go to the properties.



Under custom tool, make sure it says MSDataSetGenerator.  If it doesn't, add it.

Happy coding!




Tuesday, January 16, 2018

SSRS Report Rendering GIF and PNG Format

This is a historical post so I don't forget how to turn this on in MS Reporting Services.  Hopefully, it helps others too as it isn't immediately obvious (like everything Microsoft makes, I suppose).

Anyway, to turn GIF and PNG rendering on in SSRS:
  1. Edit the file:

    {Reporting Path}/rsreportserver.config
  2. Which happens to be this on the server I'm working on:

    C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServ\rsreportserver.config
  3. Now, search for the tag <render> within this XML file.
  4. Add the following rendering options within this <render> element:
<Extension Name="PNG" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
                <Configuration>
                    <DeviceInfo>
                        <ColorDepth>24</ColorDepth>
                        <OutputFormat>PNG</OutputFormat>
                    </DeviceInfo>
                </Configuration>
            </Extension>
<Extension Name="GIF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
                <Configuration>
                    <DeviceInfo>
                        <ColorDepth>32</ColorDepth>
                        <OutputFormat>GIF</OutputFormat>
                    </DeviceInfo>
                </Configuration>
            </Extension>

You should be all set. SSRS will pick up the change immediately, and it will be an available output rendering format.

As a bonus, you can add this to your automatic Reporting Services web service, by sending in this device info string:

@"<DeviceInfo><StartPage>{0}</StartPage><EndPage>{1}</EndPage><OutputFormat>PNG</OutputFormat></DeviceInfo>"

Maybe I'll do another blog on how to use Reporting Service's Web Service to render reports in code.  When I do, I'll link to it here.

Wednesday, October 18, 2017

Null Coalescing Operator

Remember this operator from your first Perl class back in 1994?  Well, if you don't it's a good one for your back pocket.  It works in Perl, Bash, C#, F#, Objective-C, Swift, and even SQL.  It is great for a quick way to do a Null comparison:

[C#]
string strNewValue = strRequestValue ?? "Default";

In this case, if strRequestValue is null, "Default" is assigned to strNewValue.

In SQL Server, it looks like this:

[SQL]
ISNULL(strRequestValue, 'Default')
Neither of these formats are super readable unless you are used to seeing them.  In the case of the SQL example, it looks very close to the IS NULL comparison, but whatever => the SQL team at MSFT sometimes does things like that.

It might be you want to do this instead:

[C#]
string strNewValue = isNullOrEmpty(strRequestValue) ? "Default", strRequestValue;

but I never found this to be very readable either.

I think the real power of Null Coalescing Operators is when it's used to create an object instance like this:

[C#]
private IList<Foo> _foo;
public IList<Foo> ListOfFoo
             { get { return _foo ?? (_foo = new List<Foo>()); } }
Boom!  You're off an running!

(Props go to @wilbursullivan who showed me this)

Saturday, September 30, 2017

How to Fix Orphaned SQL Server Users

No, not this kind of Orphan -- too
bad we can't fix this issues as easily!
Just a quick entry this time.  However, it happens all the time: you restore a database to a new server and can't login to the database with the original usernames.  It happens because the usernames have become "Orphaned Users."

It's now easy to fix, as of SQL 2000 sp3.  It used to be REALLY hard before.

First find all your orphaned users, by running this command:

EXEC sp_change_users_login 'Report'

It will yield something like this:

jobean 0x2BB8F8255C002E47B232FB331B1698BA

From this, I know 'jobean' is an orphaned user.

So, run this command to fix it:

EXEC sp_change_users_login 'Auto_Fix', 'jobean'

The row for user 'jobean' will be fixed by updating its login link to a login already in existence.
The number of orphaned users fixed by updating users was 1.
The number of orphaned users fixed by adding new logins and then updating users was 0.

This hooks up the jobean user of the database to the jobean of the database server.  Did this fail (probably because you don't have a jobean user in the database server?)  Then issue this command to make a new user and wire it up to the jobean orphaned user.

EXEC sp_change_users_login 'Auto_Fix', 'jobean', 'login', 'password'

[Where login and password are those you want assigned to the new user]

Easy as can be.



Friday, September 15, 2017

Logging IIS POSTS

Have you ever needed to see the raw POSTS coming into your IIS-hosted web site, but don't want to change code to write it to a file?  Well, there is an easy way:

  • Bring up IIS Manager
  • Find the Site you want to log, and click on it
  • Click the IIS icon, "Failed Request Tracing Rules".  Even though it says failed requests, it also will do successful requests.

  • Select "Add..." in the right menu
  • Select "All Content (*)" and "Next"












  • Then put "200" in the "Status Codes" box.  You could add a range to get all requests: "200-999"



  • Then press "Next",  "Finish"


A new folder under your default logs root will be built called "FailedReqLogFiles".   You will see it get filled with XML files that exhaustively log every aspect of all posts.

Remember - Don't leave it on long or it will blast your storage with tens of thousands of files.