PHP

PHP: Detect mime type by extension

27 Oct, 2024
PHP
If you're working in a PHP environment and want to detect MIME types by file extension, using Symfony's Mime component is a great choice. Here’s how to set it up and use it:

navigation.goBack() does not refresh context/state in react native

21 Oct, 2024
To ensure that navigation.goBack() refreshes context or state in React Native, add logic to refresh or reload data when the screen is focused after navigating back.

Get mimetype from takePictureAsync() in Expo React Native

18 Oct, 2024
takePictureAsync() from expo-camera does not directly return the MIME type. It only returns the URI, base64, width, height, and other metadata. To get the MIME type, you can determine it based on the...
JavaScript

JavaScript: get char count from the end of a string

17 Oct, 2024
You can count the asterisks at the end of a string, in JavaScript, using this snippet. This uses match() with the regex \*+$ to find the sequence of asterisks at the end of the string. If there's a...
PHP

PHP: use docstring to mark function deprecated

15 Oct, 2024
PHP
To mark a PHP function as deprecated and provide an alternative in the docstring, use the @deprecated tag. This makes it clear to developers that the function is deprecated and specifies the...
JavaScript

Dialog form fieldsets to show in columns not rows in CKEditor 4

13 Sep, 2024
Instead of stacking elements vertically in rows, we use an hbox layout, which arranges the child elements horizontally (in a single row). hbox is CKEditor's way of arranging elements in a horizontal...
css3 icon

Equal width columns except the last one, using flex in CSS

13 Sep, 2024
CSS
To create CSS flex columns with equal width except for the last one, you can use this combination of flexbox properties.
JavaScript

Append to HTML with JavaScript

13 Sep, 2024
To append content to an HTML element using JavaScript, you can use appendChild() for DOM elements or innerHTML for strings.
JavaScript

JSHint: Expected an identifier and instead saw ']'.(E030)

6 Sep, 2024
The JSHint error "Expected an identifier and instead saw ']'. (E030)" usually occurs when there is a syntax issue in your JavaScript code involving square brackets ([]). The least obvious is that you...
JavaScript

CKEditor 4: Add edit button to context menu

6 Sep, 2024
This code snippet adds a custom "Edit" button to the CKEditor context menu, specifically for a widget with the class "my-widget." It first creates a new menu group called myWidgetGroup and then...