Test Double is a generic term for any case where you replace a production object for testing purposes.
Under test doubles, there are various types like stubs, spies and indeed mocks! Check out Martin Fowler’s post for more detail.
When creating an array in Go, we can put
... in place of array’s length to determine the length of the array automatically based on the number of elements provided.
When working with session cookie, it’s important to be aware that using
SameSite=Strict will block the session cookie being sent by the user’s browser for all cross-site usage — including safe requests with HTTP methods like GET and HEAD.
While that might be the safest setting, the downside is that the session cookie won’t be sent when a user clicks on a link to your application from another website. Your application will initially treat the user as ‘not logged in’ even if they have an active session.
So if your application will potentially have other websites linking to it (or even links shared in emails or private messaging services),
then SameSite=Lax is generally the more appropriate setting.
In Go, the syntax for SQL parameter placeholder differs depending on your database. MySQL, SQL Server and SQLite use the
? notation, but PostgreSQL uses the
To remove a package in a Go project:
go getand postfix the package path with
Remove all references to the package in your code, then run
go mod tidy, which will automatically remove any unused packages from your go.mod and go.sum files.
A Tailwind snippet to emulate
.stretched-link from Bootstrap
- Make sure the parent element has position
- Make sure the z-index value of the other nested links are bigger than 0
Analogy of how OAuth works:
At a high level, the process is similar to sending a child home from school with a permission slip to go on a field trip. The teacher asks students if they want to go on a field trip. If they say yes, she sends them home with a paper for their parents to sign. Their parents then sign the permission slip and send the child back to school with it. Once the teacher receives the signed permission slip, the child can be taken on the field trip.
Quickly write to a file through command line:
- Replace whole file
- Append to end of file
A CSS snippet to handle nested border radius: