Posts
Behat: context class not found and can not be used.
If you are using Behat for testing your PHP application and you encounter the following error after trying to run your tests:
In UninitializedContextEnvironment.php line 44: Tests\\Feature\\Behat\\Context\\Account\\MyOldContext\\ context class not found and can not be used. Do not forget to remove your obsolete Behat Context file (MyOldContext in this case) from your behat.yml configuration file:
default: suites: default: paths: - '%paths.base%/tests/Feature/Behat/features' contexts: - Tests\\Feature\\Behat\\Context\\ApplicationContext # Remove the old context file - Tests\\Feature\\Behat\\Context\\MyOldContext - Tests\\Feature\\Behat\\Context\\EmailContext - Behat\\MinkExtension\\Context\\MinkContext - behatch:context:browser - behatch:context:debug - behatch:context:system - behatch:context:json - behatch:context:rest
Posts
Test multiple SQL Server connection strings in a dotnet console app
As I have explained how to create some new logins and users in my previous post image/svg+xml , I now had to create some connection strings for those logins. To check if all logins were created successfully, I have created a small dotnet console application to test out the connection strings associated with these logins:
using System.Data.SqlClient; class Credentials { public string Username { get; set; } public string Password { get; set; } public string Server { get; set; } public Credentials(string username, string password, string server = "sql-server.
Posts
Create an Azure SQL Server login and connect a user to it
In my previous post image/svg+xml I showed how you can convert a .bak file to a DAC file and how to fix any errors that may appear. For the same job, I had to add some new SQL logins and users after the migration of the database. This post serves as a notebook for how to do that.
\-- Execute this query in the "master" database -- Create new login CREATE LOGIN \[new-login\] WITH PASSWORD = 'complex-password' GO -- Execute these queries in the target database -- Create a user and connect it to the login CREATE USER \[new-user\] FOR LOGIN \[new-login\] -- Create a role to execute stored procedures CREATE ROLE \[db\_executor\] AUTHORIZATION \[dbo\] GO GRANT EXECUTE TO \[db\_executor\] GO -- Give the user read/write/execute rights sp\_addrolemember @rolename = 'tc\_execute', @membername = 'new-user' GO sp\_addrolemember @rolename = 'db\_datareader', @membername = 'new-user' GO sp\_addrolemember @rolename = 'db\_datawriter', @membername = 'new-user' GO -- Check if roles have been assigned to the user correctly SELECT UserType='Role', DatabaseUserName = '{Role Members}', LoginName = DP2.
Posts
Fix a SQL database before exporting to a DAC .bacpac file
When you want to migrate an old (on-premise) SQL database to an Azure SQL database, you need to export the database to a DAC .bacpac file. Such an export also includes schemas, views and users/logins. It is easy to receive errors when attempting to make a .bacpac export. In this post, I sum up the errors I received and a way to fix them.
1. Drop Windows users In my case, the database that I wanted to migrate contained references to Windows users.
Posts
Wordpress cannot send emails to email addresses on its own domain
Imagine the following situation: You have a Wordpress website hosted on example.com. The host has a Plesk configuration panel. Your email is handled by Google Workspace. MX records have been configured for this in Plesk, as described here image/svg+xml . The website has a contact form that should send an email to you, the owner of the website, on info@example.com.
But… the emails are not arriving.
Posts
Reload css stylesheet without reloading the page
Sometimes, a local development environment can be really slow at reloading pages. If you are working on styling a page or component and you want to check your changes, every page refresh generates frustration.
You can then also opt for only reloading the stylesheets of a page. This will likely be significantly faster. You can do this by using the following command in the console of your browser’s development tools:
Posts
Update the PUBLIC_URL environment variable in Gitlab's CI for a React website hosted in a subfolder
When hosting a React website in a subfolder, you want the paths to the images and fonts to be updated as well. When the path of an image in your development environment is /images/background.jpg and your website is hosted at https://example.com/app, you want the path to be updated to /app/images/background.jpg in the production build.
You can do this using the PUBLIC_URL environment variable image/svg+xml .
Posts
How to quickly add multiple colors to your Wordpress theme customizer
I am currently working on dark mode support for a Wordpress theme. For that, the website will need to use different colors depending on the preference of the user. At the same time, I want those colors to be easily customizable through Wordpress' Customizer.
What I don’t want, however, is 500 lines of code just to add a few colors. The hooks for adding Wordpress customizer settings image/svg+xml and controls image/svg+xml are no one-liners.
Posts
Organize your Wordpress theme's functions.php by using namespaces and classes
As you can extend your Wordpress theme by adding actions to the theme’s functions.php, it is safe to say that it is very easy to bloat this file with hundreds of lines of code.
The nasty thing is that the usual advice is to write a function and then add that function as an action by passing the function’s name as a string. That would look something like this:
<?php // file: functions.
Posts
IOException: Permission denied for .NET application running as a linux service
For an upload feature, my .NET application needs to upload a file to a newly created directory. My application is running as a linux service. Whenever the application tries to create a folder and add the file, I get an IOException:
An unhandled exception occurred while processing the request. IOException: Permission denied.
At first, I though I’d just chmod 777 the /var/bots folder and give full write permissions. It worked, but it would probably not be a viable and secure solution for the long term.