Remove 'memory/' from beginning of name for brevity
|
|
<%= yield :preheader %>
<% end %>
Apple autolinking
Phone numbers, addresses, dates, and (somewhat random) words like "tonight" frequently turn blue and underlined in emails viewed on an iPhone or iPad. These links trigger app-driven events, such as making a call or creating a calendar event. While these may come in handy for some scenarios, in others, they can be a nuisance and ruin your carefully-planned branding, even decreasing legibility.
They weren’t relevant to our emails, so we removed them:
+
+
{children}
}
function Fence({ children, file, language }) {
return (
{file}
children
{children}
}
function connectPlatform(userAgent) {
userAgent = userAgent.toLowerCase()
switch (true) {
case /linux/.test(userAgent):
return 'linux'
case /mac/.test(userAgent):
return 'mac'
case /windows/.test(userAgent):
return 'windows'
default:
return 'ubuntu'
}
}
function connectSslCertificate(platform) {
switch (platform) {
case 'linux':
return '/etc/ssl/certs/ca-certificates.crt'
case 'mac':
return '/etc/ssl/cert.pem'
default:
return '/etc/ssl/certs/ca-certificates.crt'
}
}
function Fence({ children, file, language }) {
return (
) } Fence.scheme = { // … } Because a user's development environment is often different from their production environment, we also had to add a selector that allows users to select the certificate on their own. The final code for that is shown below.import React, { createContext, useState } from 'react' import { parse, renderers, transform } from '@markdoc/markdoc' const Platform = createContext({ platform: null, setPlatform: () => {} }) export default function Page({ userAgent }) { const initialPlatform = connectPlatform(userAgent) const [platform, setPlatform] = useState(initialPlatform) const sslCertificate = connectSslCertificate(platform) const config = { nodes: { fence: Fence.scheme }, variables: { host: 'us-east.connect.psdb.cloud', user: 'mpl0y3jv3a92h4qc4ufn', password: 'pscale_pw_V8db13jnq5mrOWcGFn6GTs6AerDI7A0womsmnJ1qxOc', ssl_ca: sslCertificate } } const doc = `# Configure your application\n…` const ast = parse(doc) const content = transform(ast, config) const children = renderers.react(content, React, { components: { Fence } }) return ({file}children
{children}
{file}
{isDotEnvFile && (
)}
children
{isDotEnvFile && (
{isWindowsPlatform && (
<>
For Windows you may need to download a root certificate to connect securely.{' '}
Learn more
)}
{!isWindowsPlatform && (
<>
View the{' '}
certificate authority root
{' '}
paths for the SSL CA details.
)}
)}
wait_timeout value (28800 seconds by default) and increase it if it’s too low.
Error 2008: Client ran out of memory
This error message means there’s not enough memory to store the entire query result. To solve this problem, check the specifics of the query. Do you need to return this many results from the database? If not, modify the query to return only the necessary rows.
Error 2013: Lost connection during query
Error 2013 occurs when the connection drops between the MySQL client and the database server, usually because the database took too long to respond.
To fix the error, first, check that your internet connection is stable. Delayed results may be due to network connectivity issues. Also, try increasing the net-read-timeout value to give more time for the query to complete.
Non-coded errors
In addition to coded errors, there are several common non-coded MySQL errors that you might encounter.
Packet too large
The maximum possible size of a packet transmitted to or from a MySQL 8.0 server or client is 1GB. The max_allowed_packet variable stores the allowable packet size.
For the client, the default max_allowed_packet value is 16MB and for the server is 64MB. To fix this error, increase the max_allowed_packet value for the client and the server.
For example, increase the max_allowed_packet for the client to 32MB:mysql --max_allowed_packet=32M
Note that MySQL needs to restart for the change to take effect.
Can’t create/write file
You’ll get this error when MySQL can’t create the temporary file for the result in the temporary directory. This might be because there’s no memory left in the /tmp folder, or if there’s an incorrect configuration that doesn’t allow MySQL to write in the /tmp folder.
To solve the memory issue, try starting the MySQL server with the --tmpdir option and specifying a directory for the server to write to. For example, to specify C:/temp:tmpdir=C:/temp
If the configuration is incorrect, make sure MySQL has permission to write to the directory specified by tmpdir.
Commands out of sync
The commands out of sync error occurs when you call client functions in the wrong order. For example, using mysql_use_result() before calling mysql_free_result() will raise this error.
To fix this error, check your functions and make sure you are calling them in the correct order.
Hostname is blocked
This error occurs when the MySQL server receives too many connections that have been interrupted by the host. The server assumes something is wrong, like someone trying to break in, and blocks the hostname until you execute the flush-hosts command.
The number of interrupted connect requests is determined by the max_connect_errors variable, 10 by default. Modify the value by starting the MySQL server like this:mysqld_safe --max_connect_errors=10000
Aborted connections
This error occurs when clients attempt and fail to connect to the MySQL server, often due to the client using incorrect credentials or lacking access privileges.
To fix this error, start by checking the error logs and general logs at /var/log/mysql/ to determine the cause of the aborted connections.
Conclusion
Error handling can be exhausting and time-consuming, so it's important to understand how to fix the common MySQL errors. If you're looking for a straightforward, developer-friendly way to run MySQL, try PlanetScale. You can import your application's existing database with no downtime using our Import tool and be up and running in no time.]]>{true /* TODO: if queue length = 1 */ && <>There is a deployment queued to deploy} {false /* TODO: if queue length > 1 */ && ( <>There are {/* TODO: queue length */} deployments queued to deploy )} ({/* TODO: loop over queue, comma-separate links */} #{/* TODO: DR number */} )
@yield('content')
@foreach($entries as $entry)
{{ \Carbon\Carbon::parse($entry->date)->format('m/d') }}
@endforeach
Legend
-
@foreach($moods as $mood)
- {{ $mood->name }} @endforeach
@foreach($entries as $entry)
@endforeach
| Date | Mood | Notes | Edit | Delete |
|---|---|---|---|---|
|
{{ \Carbon\Carbon::parse($entry->date)->format('M d, Y') }}
|
{{ $entry->mood->name }}
|
{{ $entry->notes }} |
Edit |
Edit your mood entry
How are you feeling?
{{ $message }}
@enderror
@endsection
Since the resource controller uses PATCH, you're using a hidden PATCH method on the form with @method('PATCH').
You're also validating this input on the backend in EntryController.php, so if the input is invalid, the error messages are displayed here with {{ $error }}.
Another thing to note is this view needs to show the existing entry that’s being updated, so you're setting the value for each input with the entry data that’s passed in from the database.
entries/create.blade.php
Next, update the view used to create a new entry. Open up entries/create.blade.php and paste in the following:@section('title', 'New entry')
@extends('layout')
@section('content')
Create a new entry
How are you feeling today?
Entry
Edit- Date
- {{ \Carbon\Carbon::parse($entry->date)->format('M d, Y') }}
- Mood
- {{ $entry->mood->name }}
- Notes
- {{ $entry->notes }}
<%= f.label(:password, "New password", class: "mb-0") %>
<%= f.password_field(:password, class: "js-password-strength", autofocus: true, autocomplete: "new-password",
required: true) %>
This form element also has a tiny bit of extra JavaScript added to update the meter after each check.<% # Make 10% the min so _some_ red appears. # For values > 90, keep arc slight unclosed. strength = 10 if strength < 10
strength = 90 if (strength > 90) && (strength < 100) radius = 40 perimeter = Math::PI * radius * 2 stroke_dashoffset =
(perimeter - (perimeter * strength)) / 100 arc_color = case strength when 0..33 "rgba(var(--red-500))" when 33..66
"var(--orange-500)" when 66..100 "var(--yellow-500)" end %>
<%= strength == 100 ? "Strong" : "Too weak" %>
Password strength calculation
The controller code determines the password strength percentage and then renders the meter.def create
checker = User.password_checker
entropy = checker.calculate_entropy(params[:value] || "")
percentage = (entropy / STRONG_ENTROPY) * 100
percentage = 100 if percentage > 100
render(partial: "users/shared/password_strength_meter", locals: { strength: percentage.to_i })
end
Learn more on how to implement entropy-based password forms
Give it a try yourself by playing around with our sign up form: https://auth.planetscale.com/sign-up
We found these resources useful when implementing our password strength meter:
How to calculate password strength
Strong_password gem
Password strength test tool]]>