- Array – use plural nouns. e.g. items
- Number – use prefix num or postfix count, index etc that can imply a number. e.g. numItems, itemCount, itemIndex
- Bool – use prefix is, can, has
- is: for visual/behavior variations. e.g. isVisible, isEnable, isActive
- can: fore behavior variations or conditional visual variations. e.g. canToggle, canExpand, canHaveCancelButton
- has: for toggling UI elements. e.g. hasCancelButton, hasHeader
- Object – use noun. e.g. item
- Node – use prefix node. containerNode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * WordPress opcache preloading. | |
| * Requires PHP >= 7.4. | |
| * | |
| * @author Konrad Fedorczyk <contact@realhe.ro> | |
| * @link https://stitcher.io/blog/preloading-in-php-74 | |
| * | |
| * @version 1.0.0 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| upload_max_filesize = 2048M | |
| post_max_size = 2048M | |
| max_input_time = 3600 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** @constant string THEME_NAME **/ | |
| define( 'THEME_NAME', get_option('stylesheet') ); | |
| /** | |
| * Custom script | |
| */ | |
| function my_scripts_method() { | |
| wp_enqueue_script( | |
| 'custom-script', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Check if a PID was provided | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <pid>" | |
| exit 1 | |
| fi | |
| PID=$1 | |
| OUTPUT_FILE="usage.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable no-console */ | |
| /* eslint-disable react-hooks/exhaustive-deps */ | |
| import { useState, useEffect } from "react"; | |
| export const useLocalStorage = <T>(key: string, initialValue: T) => { | |
| const [storedValue, setStoredValue] = useState<T | undefined>(); | |
| const setValue = (value: T) => { | |
| window.localStorage.setItem(key, JSON.stringify(value)); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { DocsContainer as BaseContainer } from "@storybook/addon-docs/blocks"; | |
| import { useDarkMode } from "storybook-dark-mode"; | |
| import { themes } from "@storybook/theming"; | |
| export const DocsContainer = ({ children, context }) => { | |
| const dark = useDarkMode(); | |
| return ( | |
| <BaseContainer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function generate_unique_hex_string($length) { | |
| // Calculate the number of bytes needed for the desired length of the hexadecimal string | |
| $byte_length = ceil($length / 2); | |
| // Generate random bytes | |
| $random_bytes = random_bytes($byte_length); | |
| // Convert the random bytes to a hexadecimal string | |
| $hex_string = bin2hex($random_bytes); |
You must use Storybook with webpack5!
npx sb@next init --builder webpack5
Remember to install all nedded packages because debugging babel deps might be tricky.
Enjoy!
NewerOlder