CodeIgniter icon

CodeIgniter 4: Save to log

26 Feb, 2024
In this snippet we're using log_message() to log messages of different severity levels (error, debug, info). Depending on the condition, we log different messages. Ensure that logging is enabled and...
JavaScript

Vanilla JavaScript trigger click event

24 Feb, 2024
To trigger a click event using vanilla JavaScript, you can use the click() method on the element you want to simulate a click for. For more information: https://developer.mozilla.org/en-US/docs/Web/...
css3 icon

Center inline block vertically in CSS

22 Feb, 2024
CSS
In this layout structure, the parent element is set to display as inline-block, creating a container that adapts to the size of its content. Similarly, the content within the parent element is styled...
JavaScript

Iterate objects in JavaScript

21 Feb, 2024
In JavaScript, for iterating over objects, I recommend using the Object.entries() method, introduced in ECMAScript 2017 (ES8) and supported by modern browsers. This method provides key-value pairs in...
JavaScript

Deep merge in JavaScript

21 Feb, 2024
Deep merging in JavaScript refers to the process of merging two or more objects deeply, ensuring that nested structures, including arrays, are merged recursively. While JavaScript provides the...

React Native get SQLite table rows

17 Feb, 2024
To retrieve rows from a SQLite database in a React Native Expo project, you can use the expo-sqlite package along with JavaScript's asynchronous capabilities.
html5 icon

Overwrite button text for Screen Readers

16 Feb, 2024
If you use the aria-label attribute to provide alternative text for a button, screen readers will prioritize reading out the content of the aria-label attribute over the visible text on the button.
CodeIgniter icon

CodeIgniter 4: Add migration file

14 Feb, 2024
To add a migration file in CodeIgniter 4, you can use the command-line interface provided by CodeIgniter's CLI tool called spark.
JavaScript

Remove all but first n array items in JavaScript

10 Feb, 2024
To remove all but the first n elements from an array in JavaScript, you can use the splice() method or array slicing. The splice() method in JavaScript is used to change the contents of an array by...
JavaScript

JavaScript one-liner to get unique array values

9 Feb, 2024
This snippet uses a combination of Set and Array.from() to filter out duplicate values and convert the result back into an array. When you initialize a Set with an array, it automatically removes any...