Skip to content

Instantly share code, notes, and snippets.

View davidisnotnull's full-sized avatar
🛠️
On contract

David Johnson davidisnotnull

🛠️
On contract
View GitHub Profile
@davidisnotnull
davidisnotnull / drupal-notes.txt
Created July 19, 2020 14:14
Things to remember when you're setting up Drupal 9
CSS and JS not working? You'll get "MIME type ('text/html') is not a supported stylesheet MIME type".
Run the following command in Drush
drush -y config-set system.performance css.preprocess 0
drush -y config-set system.performance js.preprocess 0
@davidisnotnull
davidisnotnull / php.ini
Created July 21, 2020 22:11
PHP 7.4 config for Windows
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
@davidisnotnull
davidisnotnull / drop-all-users.sql
Created August 20, 2020 06:51
Drop all Users in database
--Drop all Users in database
DECLARE @sql NVARCHAR(max)
SET @sql = ''
SELECT @sql = @sql+
'
print ''Dropping '+name+'''
drop user ['+name+']
'
@davidisnotnull
davidisnotnull / worldpay-sample-card-numbers.md
Created November 3, 2020 15:24
Worldpay Sample Card Numbers
Card Number Alternate Number
Airplus 122000000000003
American Express 34343434343434
Cartebleue 5555555555554444
Dankort 5019717010103742
Diners 36700102000000 36148900647913
Discover card 6011000400000000
JCB 3528000700000000
Laser 630495060000000000 630490017740292441
@davidisnotnull
davidisnotnull / powershell-commands.md
Created December 9, 2020 19:31
Useful Powershell commands

Wipes the DNS cache on your local machine. Useful for when you've migrated a server and your machine is still caching the old IP address.

Clear-DnsClientCache
pool:
name: Self Hosted
demands: npm
variables:
solution: '**/*.sln'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
@davidisnotnull
davidisnotnull / port-in-use-fix.md
Created December 13, 2021 10:05
Fix for IIS Express error in Visual Studio being unable to start

Open CMD as an administrator and run the following commands in sequence:

net stop winnat

net start winnat
@davidisnotnull
davidisnotnull / get-properties-using-interactive-window.md
Created December 14, 2021 14:35
Using C# Interactive window to get all properties of an object
> #r "C:/MyApp/bin/Debug/Foo.dll"
> using MyApp;
> var personType = typeof(Person);
> var personProperties = personType.GetProperties();
> foreach(var personProperty in personProperty) { Console.WriteLine($"{nameof(Person)}.{personProperty.Name}"); }

This will return a list of all of the properties to the Console

@davidisnotnull
davidisnotnull / checkbox-validation.js
Created February 2, 2022 22:21
Custom jquery-validation handling for check boxes must equal true
window.onload = () => {
/*
Custom jquery-validation handling for check boxes must equal true
Decorate C# model bool properties with
[Range(typeof(bool), 'true', 'true', ErrorMessage = 'Add your error message')]
to make their corresponding checkbox validate to 'must equal true'
*/
var defaultRangeValidator = $.validator.methods.range;
$.validator.methods.range = function (value, element, param) {
if (element.type === 'checkbox') {
@davidisnotnull
davidisnotnull / enable-migrations.md
Last active February 23, 2022 22:33
Enable EF Core migrations

Make sure you install Microsoft.EntityFrameworkCore.Design from nuget to allow migrations in the project. Then, open terminal and navigate to the root folder of the project in the solution that contains the EF implementation that you want to enable migrations on.

Create initial snapshot

dotnet ef migrations add InitialCreate

Run migration

dotnet ef database update