Fix The inferred type of X cannot be named without a reference
If you’re experiencing a TypeScript mistake related to module determination or sort induction.
The blunder message recommends that the sort of ‘X’ cannot be named without a reference to ‘path/from/node_modules’, and it may not be convenient.
To resolve this issue, you’ll have to be give a type annotation for ‘X’ or adjust your module determination settings.
Here are a few of methods you’ll be able take:
Sample problem
For example I will resolve these error
The inferred type of 'loadSavedCre ...
List loaded posts in HexoJS
Basic codes to list loaded hexo posts
by default to list all posts you can using below codes:
javascriptconst posts = hexo.locals.get('posts').data.map(({ title, keywords, description, raw, tags, categories, path }) => ({
title,
keywords,
description,
raw,
path,
tags: tags.data.map((tag) => tag.name),
categories: categories.data.map((category) => category.name)
}));
Fix missing description
by default hexo not provide property de ...
Toggle enable/disable github hooks event
Pre-commit hooks are scripts that run locally before a commit is made.
They are not specific to GitHub but can be part of your local development environment.
Tools like pre-commit allow you to configure and run hooks before each commit.
enable git hooks
To toggle enable git hooks you can do following:
git config core.hooksPath ./git-hooks
disable git hooks
To toggle disable git hooks you can do following:
git config --unset core.hookspath
Visual Studio Code Run task on save
In Visual Studio Code, you can configure tasks to run automatically when you save a file using the tasks.json file.
Here is a step-by-step guide for configuring tasks to run on save:
Method 1: Using plugin Trigger Task on Save
You can use the Trigger Task on Save extension.
Configure plugin settings
To set it up, add the following to your .vscode/settings.json:
{
"task.saveBeforeRun":"always",
// task name to run on save action
"triggerTaskOnSave.selectedTask& ...
Boostrap 5 Color Theme Switcher
How to create Color Mode Switch for Bootstrap 5
Bootstrap 5 does not come with a built-in theme switcher but you can easily implement one using Use JavaScript and CSS.
Here’s a simple example of how you can create a Bootstrap 5 color theme selector:
Includes Bootstrap CSS from CDN.
Add an empty <style/> tag with attribute data-bs-theme="light|dark" where you will automatically insert the CSS of the selected theme.
Create a toggle switch using the Bootstrap form toggle component. ...
Include livereload in spring boot web
LiveReload is a tool that automatically reloads your web application whenever you alter the source code or static resources. To integrate LiveReload into a Spring Boot web application, follow these steps:
Add LiveReload Server as a Dependency
Add the LiveReload server as a dependency to your project. If you use Maven, you can include the following dependencies in your pom.xml file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-de ...
spring Content-Type application/x-www-form-urlencoded;charset=UTF-8 is not supported
Usually, the message “Content-Type ‘application/x-www-form-urlencoded;charset=UTF-8’ is not supported” suggests that there is a problem with the content type that was given in the request header. This issue frequently happens while using an API or web application. The errors log like sample below:
21-06-10 15:32:10.363 ERROR [-nio-8080-exec-8] c.e.pay.common.ResponseErrorHandler :50 - Base Exception caughtorg.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/ ...
How to create dynamic toast with flowbite-react
In this article you will learn of How to create toast with flowbite-react dynamically, see below screenshoots.
Below is an example of how you can create a dynamic toast component in React using flowbite-react.
Create flowbite toast element
save below codes with filename FlowbiteToast.tsx in folder src/component
import { Toast } from 'flowbite-react';
import React from 'react';
import { HiFire } from 'react-icons/hi';
interface FlowbiteToastPro ...
Exported variable has or is using name from external module
In TypeScript, when you have an exported variable that uses a private type from an external module, you may run into issues because private types are not accessible outside of their module.
answers for exported variable that uses a private type from an external module:
Exported variable ‘yourVariable’ has or is using name ‘TypeName’ from external module “module/path” but cannot be named. ts(4023)
TS4023: Exported Variable has or is using name from external module but cannot be named
Exported ...
Enable CORS globally in spring boot
To enable Cross-Origin Resource Sharing (CORS) globally in a Spring Boot application with Spring Security,
you can configure CORS in your security configuration class.
Here’s an example of codes how you can do this:
import java.util.List;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.Aut ...