Skip to main content

Posts

How to Floor a number to 0.05 increments in T-SQL

Say you've got a number like 72.26 and you want to round it or floor to the nearest 0.05 The first thing to do is divide it by the round number.   For example, if you want 72.26 rounded to the nearest 0.05, this will show how many 0.05's there are in the number                     72.26 / 0.05 = 1,445.2                     From there, round or floor as needed               eg,                 SELECT ROUND( 72.26 / 0.05  , 0 )   or  SELECT FLOOR( 72.26 / 0.05  , 0 )                Results in 1445.0 Then, multiply it by the round number  This returns you to the original value, less then remainder (or to the next increment if it rounded up)           eg  SELECT 0.05...

Can't Install Powershell Modules

 When trying to install a PowerShell module I was getting this error... WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'. PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'XXX'. Turns out it was a problem with the SecurityProtocol, fixed by entering  [System.Net.ServicePointManager]::SecurityProtocol =                     [System.Net.SecurityProtocolType]::Tls12;  SecurityProtocols I had in place before entering this command were... PS C:\WINDOWS\system32> [System.Net.ServicePointManager]::SecurityProtocol Ssl3, Tls Afterwards, I had  PS C:\WINDOWS\system32> [System.Net.ServicePointManager]::SecurityProtocol Tls12  

Backup and Restore Database Commands

  BACKUP   DATABASE   [DB_Name]         TO   DISK   =   N'\\server\directory\backupfile.bak'         WITH   NOFORMAT ,   INIT ,   NAME = N'DBNAME' ,   SKIP ,      NOREWIND ,   NOUNLOAD ,   STATS = 10 ;   RESTORE   FILELISTONLY                FROM   DISK =   N '\\server\directory\backupfile.bak'   DROP   DATABASE   [DB_Name]   ;   RESTORE   DATABASE   [DB_Name]             FROM   DISK = ' '\\server\directory\backupfile.bak'         WITH         MOVE   'DB_logicalName'   TO                'D:\Databases\data file name....

Using GetEnumerator

  The tips are:  Seems to work better if you know the type you want back from GetEnumerator, notice the IEnumerator<Employee> Notice the use of Current

Good article on getting the right characters of a string in C#

Left, Right, SubString C#   https://kodify.net/csharp/strings/left-right-mid/#left-right-and-mid-string-segments-in-c Feature Description C# equivalent Left Get specific number of characters ( count ) from left part string.Substring(0, count) Right Get specific number of characters ( count ) from right side string.Substring(string.Length - count, count) Mid Get a specific number of characters ( count ) starting at a certain point ( index ) string.Substring(index, count) Mid Get all characters starting at a certain point ( index ) string.Substring(index)

How to trust IIS Certificates for Development

 Type the following on a command line  > dotnet dev-certs https --trust If you're accessing the dev site from another computer or device, via an application, you can disable ssl certificate checking in the client app with... HttpClientHandler handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = ( message, cert, chain, errors ) =>  { if(cert.Issuer.Equals("CN=localhost"))                    { return true;                     } return errors == System.Net.Security.SslPolicyErrors.None; }; Notes about Android and Xamarin Requires TLS 1.2 The default AndroidClientHandler supports TLS 1.2, but only for Android versions greater than 4.1 If an Android version is needed that is lower than 4.1, then we'll need to use the HttpClientHandler which supports TLS 1.0.  It is slower and increases the package size...