Removing files from git that match the gitignore file

 

Recently a developer accidentally committed and pushed a metric-ton of binary files into our repo that were supposed to be ignored by the gitignore file.

After a bunch of work trying different options I came across a solution.  We used the Git Bash (on windows) and ran the following:

git ls-files -i -z –exclude-from=.gitignore | xargs -0 git rm –cache

This effectively told git to remove all files that matched the ignore list.  It’s not perfect, but it saved us a ton of time removing files from a hundred different folders.

Getting hibernation working on Lenovo 100S

I have a Lenovo 100S but no matter what I tried I couldn’t find how to get hibernation as an option.

When researching the problem it seemed some people with a similar problem were able to get hibernation working by opening an admin command prompt and running:

powercfg.exe /hibernate off

However after doing that I didn’t see any change, and furthermore when running:

powercfg -a

it said “The hiberfile does not support hibernation”

Doing more research I found that the likely reason was that for some reason the hibernation file was too small. Running:

powercfg -h -size 100%

caused the hibernation file to grow significantly, and after a reboot I had “Hibernate after” options on the sleep menu.

Nonce errors with AzureAD SSO ASP.NET

We recently converted an application to use AzureAD for single sign on and discovered in our logs that we were seeing a number of Nonce related errors such as the one below.

We haven’t fully fleshed out this issue, but we were able to reproduce it with the following steps:

1) Browse to the site

2) Get redirected to the AzureAD SSO login page.

3) Wait 1 hour

4) Attempt to complete the login

Here is an article I found that discusses the same issue (with a slightly different error) along with some code for catching the exception and changing the nonce timeout.

https://teknovenus.com/nonce-expriation-idx10316-workaround-asp-net-mvc/

The error we are getting:

Session state is not available in this context.

Error method: Void ValidateNonce(System.IdentityModel.Tokens.JwtSecurityToken, Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolValidationContext)

IDX10311: RequireNonce is ‘true’ (default) but validationContext.Nonce is null. A nonce cannot be validated. If you don’t need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to ‘false’.

Stack: at Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolValidator.ValidateNonce(JwtSecurityToken jwt, OpenIdConnectProtocolValidationContext validationContext)

at Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolValidator.Validate(JwtSecurityToken jwt, OpenIdConnectProtocolValidationContext validationContext)

IIS: BadImageFormatException

 

[BadImageFormatException: Could not load file or assembly ‘Interop.SHDocVw’ or one of its dependencies. An attempt was made to load a program with an incorrect format.]

If you are getting an exception like that, it could mean that your App Pool is not setup to work with 32 bit applications.  Try enabling it:

enter image description here

MSDTC with client OS (Windows 7, 8, 10)

When trying to setup distributed transactions (MSDTC) there are essentially 2 things you need to do. 

First, you need to enable connections by running Component Services MMC

image

Second you need to allow access through the firewall

image

But if you are doing this on a “client OS” like Windows 7, 8, or 10, trying to get your dev machine to talk to your SQL Server on the network for example, you might run into additional problems.

If you run the DTCPing ( https://www.microsoft.com/en-us/download/details.aspx?id=2868 ) MSDTC trouble shooting tool and you get “Access is denied”, like this:

Invoking RPC method on (compname)
Problem:fail to invoke remote RPC method
Error(0x5) at dtcping.cpp @303
–>RPC pinging exception
–>5(Access is denied.)
RPC test failed

To fix this issue follow these steps (https://blogs.msdn.microsoft.com/puneetgupta/2008/11/12/troubleshooting-msdtc-issues-with-the-dtcping-tool/)

  1. Click Start, click Run, type Regedit, and then click OK.
  2. Locate and then click the following registry key:  HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT
  3. On the Edit menu, point to New, and then click Key.
  4. Note If the RPC registry key already exists, go to step 5.
  5. Type RPC, and then press ENTER. Click RPC.
  6. On the Edit menu, point to New, and then click DWORD Value.
  7. Type RestrictRemoteClients, and then press ENTER.
  8. Click RestrictRemoteClients.
  9. On the Edit menu, click Modify.
  10. In the Value data box, type 0, and then click OK.
  11. Note To enable the RestrictRemoteClients setting, type1.
  12. Close Registry Editor and restart the computer.