React redirect doesn’t work. Continue to stay in the same page

I’m trying to do a login with laravel react, so when I receive jwt from server I wanna redirect to my main page, but I continue to stay on the same page

import { Route, BrowserRouter as Redirect } from 'react-router-dom';


const Login = () => {
    const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");
    const [jwt, setJwt] = useState("");

    const login = async (e) => {
        e.preventDefault();
        await axios.post("/login", {
            email: email,
            password: password
        }).then((response) => {
            console.log(response)
            if (response.data[0] === "credenziali errate") {
                console.log('credenziali errate')
            } else if (response.data.token) {
                setJwt(response.data.token);
                return (<Route>
                    <Redirect to="/" />
                </Route>)

            }
        });
        setEmail("")
        setPassword("")
    }

    return (
        <div>
            <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} name="" id="" required/>
            <input type="password" value={password} onChange={(e) => setPassword(e.target.value)} name="" id="" required/>
            <button type="submit" onClick={login}>Login</button>
        </div>
    );
}

SVG arg fadeout/gradient effect

I’m trying to create doughnut visualization using d3 with fadeout/gradient effect for each arc like this:
enter image description here

I’ve tried to add ‘filter: drop-shadow(0 0 10px color)’ but it doesn’t give me this effect, also, it spread on both sides.

So I moved to use two pies

  1. Outer solid color
  2. Inner with (hopefully) the fade out effect

I know in gradient I can make solid, then fade out but since I don’t have a clear path to success, I split to two pies

I’ve tried to use both linearGradient & radialGradient on the second pie which seems like a step in a good direction, but the gradient effect changes as the arcs angles are different:

enter image description here

For the simplicity, currently I created a gradient filter for just one color as I’m not sure this is the solution for my problem…

I’ve added a snippet to help the helpers 🙂

const colors = ['red','green','purple','blue','orange','teal']
const data = [10,12,33,112,22,4];
const pie = d3.pie().padAngle(0.03);
const arcs = pie(data);

const svg = d3.select('body')
  .append('svg');
 
const svgDefs = svg.append('defs');

const mainGradient = svgDefs.append('radialGradient')
                .attr('id', 'mainGradient');

            mainGradient.append('stop')
                .attr('stop-color', 'red')
                .attr('offset', '10%');

            mainGradient.append('stop')
                .attr('stop-color', 'pink')
                .attr('offset', '90%');



d3.select('body')
  .style('position', 'relative')
  .append('svg')
  .style('position', 'absolute')
  .style('z-index', 10)
  .attr('width', 600)
  .attr('height', 600)
  .append("g")
  .attr("transform", "translate(100,100)")
  .selectAll('path')
  .data(arcs)
  .enter()
  .append('path')
  .attr('d', (a,b,c) => d3.arc()({...a, innerRadius: 96, outerRadius: 100}))
  .style('fill', (d, index) => colors[index])

 svg.style('position', 'absolute')
    .attr('width', 600)
    .attr('height', 600)
  .append("g")
    .attr("transform", "translate(100,100)")
    .selectAll('path')
    .data(arcs)
    .enter()
    .append('path')
      .transition()
      .attr('d', (a,b,c) => d3.arc()({...a, innerRadius: 0, outerRadius: 96}))
      .style('fill', 'url(#mainGradient)')
    
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.14.2/d3.min.js"></script>
<body>
</body>
</html>

Why recursion requires n <= 0 instead of n = 0 in base case? [closed]

The problem is to write a recursive function, sum(arr, n), that returns the sum of the first n elements of an array arr. Here is the correct solution according to the course (freecodecamp):

function sum(arr, n) {
  if (n <= 0) { return 0; }
  else {
  return sum(arr,n-1) + arr[n - 1];
}
}

Notice that the condition of the base case is “n<=0” instead of “n = 0”. This is what I don’t understand.

My understanding is that when the n reaches value 0, it will return 0 and the code will exit the function. Thus, no need to think about the case when n < 0 since the code already finishes BEFORE that.
But when I leave the condition of the base case as “n = 0”, my answer is not accepted.
Can anyone shed light on this?

Why does one the presence of one Import statement break another?

I have a JavaScript file with the following two import statements at the top of it:

import { FbxLoader } from "./ThreeJs/examples/jsm/loaders/FBXLoader.js";
import * as Three from "./ThreeJs/src/Three.js";

When I load this into a browser I get Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".. However, if I comment out the 1st import this error goes away but yet it looks like it’s referring to the 2nd import since it makes reference to “three”!

If I swap the two imports around, the browser console still reports the same error on the same line!

What’s going on here? The files definitely exist, the paths to them are definitely correct. If I make one of the file names incorrect I get a different (404) error in the console so it shouldn’t be a bad path issue.

My Minecraft Crashes ever time i look at any tool in Minecraft inventory [closed]

—- Minecraft Crash Report —-
// Hi. I’m Minecraft, and I’m a crashaholic.

Time: 2023-09-24 09:41:47
Description: Rendering item

java.lang.ClassCastException: null

A detailed walkthrough of the error, its code path and all known details is as follows:

-- Head --
Thread: Render thread
Stacktrace:
    at com.anthonyhilyard.iceberg.renderer.CustomItemRenderer.renderDetailModelIntoGUI(CustomItemRenderer.java:630) ~[Iceberg-1.20.1-forge-1.1.15.jar%23332!/:1.1.15] {re:classloading}
-- Item being rendered --
Details:
    Item Type: golden_hoe
    Registry Name: minecraft:golden_hoe
    Item Damage: 0
    Item NBT: {Damage:0}
    Item Foil: false
Stacktrace:
    at com.anthonyhilyard.iceberg.renderer.CustomItemRenderer.renderDetailModelIntoGUI(CustomItemRenderer.java:630) ~[Iceberg-1.20.1-forge-1.1.15.jar%23332!/:1.1.15] {re:classloading}
    at com.anthonyhilyard.legendarytooltips.tooltip.ItemModelComponent.m_183452_(ItemModelComponent.java:121) ~[LegendaryTooltips-1.20.1-forge-1.4.5.jar%23343!/:1.4.5] {re:classloading}
    at net.minecraft.client.gui.GuiGraphics.m_280497_(GuiGraphics.java:629) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.GuiGraphics.m_280677_(GuiGraphics.java:562) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.GuiGraphics.renderTooltip(GuiGraphics.java:556) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.m_280072_(AbstractContainerScreen.java:163) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:AbstractContainerScreenAccessor,pl:mixin:APP:attributeslib.mixins.json:client.AbstractContainerScreenMixin,pl:mixin:APP:puzzlesapi.common.mixins.json:iteminteractions.client.AbstractContainerScreenMixin,pl:mixin:APP:puzzlesapi.common.mixins.json:iteminteractions.client.accessor.AbstractContainerScreenAccessor,pl:mixin:APP:mousetweaks.mixins.json:AbstractContainerScreenAccessor,pl:mixin:APP:inventorio.mixins.json:client.HandledScreenMixin,pl:mixin:APP:inventorio.mixins.json:client.accessor.HandledScreenAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen.m_88315_(CreativeModeInventoryScreen.java:650) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.Screen.m_280264_(Screen.java:109) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:computing_frames,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:controlling.mixins.json:AccessScreen,pl:mixin:APP:balm.mixins.json:ScreenAccessor,pl:mixin:APP:konkrete.mixin.json:IMixinScreen,pl:mixin:APP:patchouli_xplat.mixins.json:client.AccessorScreen,pl:mixin:APP:inventorio.mixins.json:client.accessor.ScreenAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraftforge.client.ForgeHooksClient.drawScreenInternal(ForgeHooksClient.java:427) ~[forge-1.20.1-47.1.46-universal.jar%23395!/:?] {re:mixin,re:classloading}
    at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:420) ~[forge-1.20.1-47.1.46-universal.jar%23395!/:?] {re:mixin,re:classloading}
    at net.minecraft.client.renderer.GameRenderer.m_109093_(GameRenderer.java:965) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:railways-common.mixins.json:conductor_possession.MixinGameRenderer,pl:mixin:APP:ars_nouveau.mixins.json:GameRendererMixin,pl:mixin:APP:okzoomer.mixins.json:GameRendererMixin,pl:mixin:APP:freecam.mixins.json:GameRendererMixin,pl:mixin:APP:forge-immediatelyfast-common.mixins.json:core.compat.MixinGameRenderer,pl:mixin:APP:create.mixins.json:client.GameRendererMixin,pl:mixin:APP:create.mixins.json:accessor.GameRendererAccessor,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1146) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,pl:mixin:APP:dynamiclightsreforged.mixins.json:MinecraftClientMixin,pl:mixin:APP:rubidium.mixins.json:core.MixinMinecraftClient,pl:mixin:APP:modernfix-common.mixins.json:feature.measure_time.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:bugfix.world_leaks.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:bugfix.concurrency.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.blast_search_trees.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.dedicated_reload_executor.MinecraftMixin,pl:mixin:APP:modernfix-forge.mixins.json:feature.measure_time.MinecraftMixin_Forge,pl:mixin:APP:bookshelf.common.mixins.json:accessors.client.AccessorMinecraft,pl:mixin:APP:balm.mixins.json:MinecraftMixin,pl:mixin:APP:railways-common.mixins.json:conductor_possession.MixinMinecraft,pl:mixin:APP:konkrete.mixin.json:MixinMinecraft,pl:mixin:APP:architectury.mixins.json:MixinMinecraft,pl:mixin:APP:ars_nouveau.mixins.json:light.ClientMixin,pl:mixin:APP:inventorio.mixins.json:client.accessor.MinecraftClientAccessor,pl:mixin:APP:flywheel.mixins.json:PausedPartialTickAccessor,pl:mixin:APP:iceberg.mixins.json:MinecraftMixin,pl:mixin:APP:freecam.mixins.json:MinecraftMixin,pl:mixin:APP:xaeroplus.mixins.json:mc.MixinMinecraftClient,pl:mixin:APP:forge-immediatelyfast-common.mixins.json:core.MixinMinecraftClient,pl:mixin:APP:create.mixins.json:client.WindowResizeMixin,pl:mixin:APP:ars_nouveau.mixins.json:camera.MinecraftMixin,pl:mixin:APP:inventorio.mixins.json:client.MinecraftClientMixin,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:718) ~[client-1.20.1-20230612.114412-srg.jar%23390!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,pl:mixin:APP:dynamiclightsreforged.mixins.json:MinecraftClientMixin,pl:mixin:APP:rubidium.mixins.json:core.MixinMinecraftClient,pl:mixin:APP:modernfix-common.mixins.json:feature.measure_time.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:bugfix.world_leaks.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:bugfix.concurrency.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.blast_search_trees.MinecraftMixin,pl:mixin:APP:modernfix-common.mixins.json:perf.dedicated_reload_executor.MinecraftMixin,pl:mixin:APP:modernfix-forge.mixins.json:feature.measure_time.MinecraftMixin_Forge,pl:mixin:APP:bookshelf.common.mixins.json:accessors.client.AccessorMinecraft,pl:mixin:APP:balm.mixins.json:MinecraftMixin,pl:mixin:APP:railways-common.mixins.json:conductor_possession.MixinMinecraft,pl:mixin:APP:konkrete.mixin.json:MixinMinecraft,pl:mixin:APP:architectury.mixins.json:MixinMinecraft,pl:mixin:APP:ars_nouveau.mixins.json:light.ClientMixin,pl:mixin:APP:inventorio.mixins.json:client.accessor.MinecraftClientAccessor,pl:mixin:APP:flywheel.mixins.json:PausedPartialTickAccessor,pl:mixin:APP:iceberg.mixins.json:MinecraftMixin,pl:mixin:APP:freecam.mixins.json:MinecraftMixin,pl:mixin:APP:xaeroplus.mixins.json:mc.MixinMinecraftClient,pl:mixin:APP:forge-immediatelyfast-common.mixins.json:core.MixinMinecraftClient,pl:mixin:APP:create.mixins.json:client.WindowResizeMixin,pl:mixin:APP:ars_nouveau.mixins.json:camera.MinecraftMixin,pl:mixin:APP:inventorio.mixins.json:client.MinecraftClientMixin,pl:mixin:A,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:218) ~[1.20.1-forge-47.1.46.jar:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:flywheel.mixins.json:ClientMainMixin,pl:mixin:A,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) ~[fmlloader-1.20.1-47.1.46.jar:?] {}
    at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99) ~[fmlloader-1.20.1-47.1.46.jar:?] {}
    at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25) ~[fmlloader-1.20.1-47.1.46.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:108) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:78) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.9.jar:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] {}
-- Screen render details --
Details:
    Screen name: net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen
    Mouse location: Scaled: (282, 86). Absolute: (564.000000, 173.000000)
    Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2.000000

-- Affected level --
Details:
    All players: 1 total; [LocalPlayer['Zing_Dragneel'/196, l='ClientLevel', x=90.19, y=71.00, z=78.17]]
    Chunk stats: 16384, 2713
    Level dimension: minecraft:overworld
    Level spawn location: World: (48,72,112), Section: (at 0,8,0 in 3,4,7; chunk contains blocks 48,-64,112 to 63,319,127), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,-64,0 to 511,319,511)
    Level time: 3206 game time, 3206 day time
    Server brand: forge
    Server type: Integrated singleplayer server

-- Last reload --
Details:
    Reload number: 1
    Reload reason: initial
    Finished: Yes
    Packs: mod_resources, vanilla

-- System Details --
Details:
    Minecraft Version: 1.20.1
    Minecraft Version ID: 1.20.1
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 17.0.8, Microsoft
    Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft
    Memory: 1600627104 bytes (1526 MiB) / 3992977408 bytes (3808 MiB) up to 5368709120 bytes (5120 MiB)
    CPUs: 16
    Processor Vendor: AuthenticAMD
    Processor Name: AMD Ryzen 7 3700X 8-Core Processor             
    Identifier: AuthenticAMD Family 23 Model 113 Stepping 0
    Microarchitecture: Zen 2
    Frequency (GHz): 3.59
    Number of physical packages: 1
    Number of physical CPUs: 8
    Number of logical CPUs: 16
    Graphics card #0 name: NVIDIA GeForce RTX 2080 Ti
    Graphics card #0 vendor: NVIDIA (0x10de)
    Graphics card #0 VRAM (MB): 4095.00
    Graphics card #0 deviceId: 0x1e04
    Graphics card #0 versionInfo: DriverVersion=31.0.15.3734
    Memory slot #0 capacity (MB): 16384.00
    Memory slot #0 clockSpeed (GHz): 2.13
    Memory slot #0 type: DDR4
    Memory slot #1 capacity (MB): 16384.00
    Memory slot #1 clockSpeed (GHz): 2.13
    Memory slot #1 type: DDR4
    Memory slot #2 capacity (MB): 16384.00
    Memory slot #2 clockSpeed (GHz): 2.13
    Memory slot #2 type: DDR4
    Memory slot #3 capacity (MB): 16384.00
    Memory slot #3 clockSpeed (GHz): 2.13
    Memory slot #3 type: DDR4
    Virtual memory max (MB): 75172.06
    Virtual memory used (MB): 31123.88
    Swap memory total (MB): 9728.00
    Swap memory used (MB): 86.36
    JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx5G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
    Launched Version: 1.20.1-forge-47.1.46
    Backend library: LWJGL version 3.3.1 build 7
    Backend API: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 537.34, NVIDIA Corporation
    Window size: 854x480
    GL Caps: Using framebuffer using OpenGL 3.2
    GL debug messages: 
    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'forge'; Server brand changed to 'forge'
    Type: Integrated Server (map_client.txt)
    Graphics mode: fancy
    Resource Packs: vanilla
    Current Language: en_us
    CPU: 16x AMD Ryzen 7 3700X 8-Core Processor 
    Server Running: true
    Player Count: 1 / 8; [ServerPlayer['Zing_Dragneel'/196, l='ServerLevel[Testing Mods]', x=90.19, y=71.00, z=78.17]]
    Data Packs: mod:create_sa, mod:geckolib, mod:netherportalfix, vanilla, mod:dynamiclightsreforged (incompatible), mod:supermartijn642configlib (incompatible), mod:sophisticatedcore (incompatible), mod:rubidium, mod:villagernames, mod:controlling (incompatible), mod:prism (incompatible), mod:placebo (incompatible), mod:modernfix (incompatible), mod:citadel (incompatible), mod:alexsmobs (incompatible), mod:yungsapi, mod:mixinextras (incompatible), mod:bookshelf, mod:kambrik (incompatible), mod:sophisticatedbackpacks (incompatible), mod:guardvillagers (incompatible), mod:create_dragon_lib (incompatible), mod:createdieselgenerators (incompatible), mod:apotheosis (incompatible), mod:mcwdoors, mod:railways (incompatible), mod:balm, mod:cloth_config (incompatible), mod:sound_physics_remastered, mod:konkrete (incompatible), mod:athena, mod:chipped (incompatible), mod:w2w2 (incompatible), mod:mcwbridges, mod:farmersdelight, mod:mcwtrpdoors, mod:mcwfences, mod:supermartijn642corelib (incompatible), mod:bountiful (incompatible), mod:curios (incompatible), mod:patchouli (incompatible), mod:collective, mod:searchables (incompatible), mod:framedblocks, mod:attributeslib (incompatible), mod:betterstrongholds, mod:buildersaddition (incompatible), mod:resourcefullib (incompatible), mod:constructionwand, mod:cfm, mod:architectury (incompatible), mod:mcwfurnitures, mod:cupboard (incompatible), mod:chunkloaders (incompatible), mod:fastleafdecay, mod:bettermineshafts, mod:gamemenumodoption, mod:sliceanddice (incompatible), mod:inventorysorter (incompatible), mod:betteranimationscollection, mod:puzzlesapi, mod:trashslot, mod:rechiseled (incompatible), mod:jei, mod:callablehorses (incompatible), mod:createchunkloading (incompatible), mod:waystones, mod:clumps (incompatible), mod:comforts (incompatible), mod:naturescompass, mod:strawstatues, mod:dungeoncrawl, mod:rechiseledcreate, mod:create_confectionery, mod:fusion (incompatible), mod:ars_nouveau (incompatible), mod:puzzlesaccessapi, mod:forge, mod:craftingtweaks, mod:okzoomer (incompatible), mod:enchdesc (incompatible), mod:terrablender (incompatible), mod:biomesoplenty (incompatible), mod:mousetweaks, mod:jade (incompatible), mod:spectrelib (incompatible), mod:inventorio (incompatible), mod:betterfpsdist (incompatible), mod:kotlinforforge (incompatible), mod:notenoughanimations, mod:iceberg (incompatible), mod:flywheel, mod:create, mod:create_mechanical_spawner (incompatible), mod:extendedgears (incompatible), mod:legendarytooltips (incompatible), mod:gravestone, mod:polymorph (incompatible), mod:storagedrawers (incompatible), mod:immersive_paintings (incompatible), mod:freecam (incompatible), mod:entityculling, mod:canary, mod:fogoverrides (incompatible), mod:xaeroplus (incompatible), mod:xaeroworldmap, mod:xaerominimap, mod:immediatelyfast (incompatible), mod:ferritecore (incompatible), mod:puzzleslib, mod:cosmeticarmorreworked, mod:create_enchantment_industry (incompatible), mod:createaddition (incompatible), bundle, mod:betterdungeons, mod:bettervillage, mod:libraryferret, mod:create_structures, mod:lootr, mod:corpse
    Enabled Feature Flags: minecraft:bundle, minecraft:vanilla
    World Generation: Stable
    ModLauncher: 10.0.9+10.0.9+main.dcd20f30
    ModLauncher launch target: forgeclient
    ModLauncher naming: srg
    ModLauncher services: 
        mixin-0.8.5.jar mixin PLUGINSERVICE 
        eventbus-6.0.5.jar eventbus PLUGINSERVICE 
        fmlloader-1.20.1-47.1.46.jar slf4jfixer PLUGINSERVICE 
        fmlloader-1.20.1-47.1.46.jar object_holder_definalize PLUGINSERVICE 
        fmlloader-1.20.1-47.1.46.jar runtime_enum_extender PLUGINSERVICE 
        fmlloader-1.20.1-47.1.46.jar capability_token_subclass PLUGINSERVICE 
        accesstransformers-8.0.4.jar accesstransformer PLUGINSERVICE 
        fmlloader-1.20.1-47.1.46.jar runtimedistcleaner PLUGINSERVICE 
        modlauncher-10.0.9.jar mixin TRANSFORMATIONSERVICE 
        modlauncher-10.0.9.jar fml TRANSFORMATIONSERVICE 
    FML Language Providers: 
        [email protected]
        javafml@null
        [email protected]
        lowcodefml@null
    Crash Report UUID: 23d27a3f-9c31-4e1e-abbf-336aa11ff1c1
    FML: 47.1
    Forge: net.minecraftforge:47.1.46
    Flywheel Backend: GL33 Instanced Arrays

I tried removing twilight forest because its the mod that crash originally but still didn’t change anything.

Manifest configuration to serve PWA from sub-path

I try to create a vanilla HTML/JavaScript PWA which – once the resources have been cached – is fully functional offline. I publish the app using gitlab-pages, so by default one can access it under https://user.gitlab.io/project/ – a sub-path of a domain. The manifest and service worker files are located directly in this sub-path. The crucial manifest entries look like this:

{ ...
  "start_url": "https://user.gitlab.io/project/",
  "scope": "https://user.gitlab.io/project/",
... }

This should be correct as far as I understood the documentation and for Firefox/Android it works. Unfortunately it does not work for Brave/Chromium on desktop and Safari on iOS: I get a “You are offline message” if I open the PWA when the device is – well, offline. Lighthouse complains: “Does not register a service worker that controls page and start_url“.

The problem is (very likely) caused by serving from a sub-path of a domain (.../project/): Gitlab offers the option to create a unique domain which then uploads the PWA to something like https://project-user-hUuUuUuGe...hAsH.gitlab.io. Using this and adopting the manifest lets everything work as expected. One is able to use the app even without a connection to the server. But of course the URL is indigestible, so I really would like to make it work on the sup-path.

I tried theoretically valid alternative forms like

{ ...
  "start_url": "https://user.gitlab.io/project/index.html",
  "scope": "https://user.gitlab.io/project/",
...}

or

{ ...
  "start_url": "./index.html",  // assuming manifest.json to be next to index.html
  "scope": "https://user.gitlab.io/project/",
...}

each with and without the scope entry, since the fallback default should be fine. But regardless, it did not work.

Any ideas?

Request device admin permissions from user via React Native app native module?

I am trying to add device admin features in React Native app. I created a simple native module which have the following react method which is called from JS stack:

@ReactMethod
public void requestAdmin(Promise promise) {
    ComponentName deviceAdminComponentName = new ComponentName(context, SecureDeviceAdminReciever.class);
    if(!isDeviceAdmin(context, deviceAdminComponentName)) {
        context.runOnUiQueueThread(new Runnable() {
            @Override
            public void run() {
                requestAdminIntent();
                promise.resolve(true);
            }
        });

    }
}

public void requestAdminIntent() {
    ReactApplicationContext context = getReactApplicationContext();
    Intent intent = new Intent(context.getCurrentActivity().getApplicationContext(), DeviceAdminRequestActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.runOnUiQueueThread(new Runnable() {
        @Override
        public void run() {
            context.startActivityForResult(intent, DeviceAdminRequestActivity.REQUEST_DEVICE_ADMIN_PERMISSIONS,null);
        }
    });

}

In the above code I am calling a custom activity which I had to create since DeviceAdminAdd activity will not work with with flag Intent.FLAG_ACTIVITY_NEW_TASK after revising code here and react-native requires it:

https://android.googlesource.com/platform/packages/apps/Settings/+/marshmallow-dev/src/com/android/settings/DeviceAdminAdd.java

So inside the custom activity inside onCreate, I have the following implementation to execute DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN intent:

@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DevicePolicyManager devicePolicyManager = (android.app.admin.DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    ComponentName deviceAdminComponentName = null;
    deviceAdminComponentName = new ComponentName(getApplicationContext(), SecureDeviceAdminReciever.class);
    Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
    intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdminComponentName);
    intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Note: The permissions granted by you is used for applying the anti-theft features.");
    startActivity(intent);
    Log.d("Device Admin Request", "Requested to start action add device admin ... ");
}

My policies xml file @xml/device_admin_policies.xml:

<?xml version="1.0" encoding="utf-8"?>
<device-admin>
    <uses-policies>
        <disable-camera />
        <limit-password />
        <watch-login />
        <reset-password />
        <force-lock />
        <wipe-data />
        <expire-password />
        <encrypted-storage />
    </uses-policies>
</device-admin>

And manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-feature
        android:name="android.hardware.camera"
        android:required="true" />

    <uses-permission android:name="android.permission.CAMERA" />


    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_DEVICE_ADMIN" />
    <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN"
        tools:ignore="ProtectedPermissions" />

    <application
        android:name=".MainApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/AppTheme">
        <activity
            android:name=".activities.DeviceAdminRequestActivity"
            android:exported="true"
            android:permission="android.permission.BIND_DEVICE_ADMIN"/>
        <activity
            android:name=".MainActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
            android:exported="true"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name=".PowerStateReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.ACTION_SHUTDOWN" />
            </intent-filter>
        </receiver>
        <receiver
            android:name=".SecureAdminReciever"
            android:exported="true"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@xml/device_admin_policies" />

            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.app.admin.DEVICE_ADMIN_ENABLED" />
                <action android:name="android.app.admin.DEVICE_ADMIN_DISABLED" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

Now the issue I am having is that I am getting a blank activity to show up but its not showing up the device admin dialog to activate device admin for app. I set a breakpoint at startActivity(intent) line inside onCreate() for debugging it turns out that it executes startActivity(intent) and right after that it shows a blank activity but not device admin dialog. I will appreciate anyone who can help or have idea why this is happening.

How do I dynamically create charts using one javascript function?

I am using Apex Charts to visualize my data. I’ve been experimenting and although creating one function per chart seems great, I’d like to automize this. I haven’t found any documentation so far that explains how you can seamlessly create multiple charts using only one function. I keep running into errors like Element not found even though I’ve already generated <div id="chart1"></div> <div id="chart1"></div> <div id="chart1"></div> in my HTML doc.

I’m thinking that there’s sort of a conflict with the ids.

My javascript code (here I want to dynamically create 3 doughnut charts for the three elements in the list – so that if the list changes and has 10, 20, n elements, charts are automatically generated):

const list = [1, 4, 5];
    // Example datasets and labels
    const dataset1 = [30, 50, 20]; // Example dataset 1
    const labels1 = ["Label A", "Label B", "Label C"]; // Labels for dataset 1

    const dataset2 = [40, 30, 30]; // Example dataset 2
    const labels2 = ["Label X", "Label Y", "Label Z"]; // Labels for dataset 2

    const dataset3 = [10, 70, 20]; // Example dataset 3
    const labels3 = ["Option 1", "Option 2", "Option 3"]; // Labels for dataset 3


    function createContainer(list){
        const container = document.querySelector("#container");
        for(let i=0; i<list.length; i++){      
            const value = list[i];   
            const chartContent = document.createElement("div");
            chartContent.id = `chart${value}`;

           container.appendChild(chartContent);
           console.log(chartContent);
           generateChart(i);
        }
    }

    function generateChart(value){
        if(value == 1){
            renderDoughnutChart(dataset1, labels1, `chart${value}`);
        } else if (value == 4){
            renderDoughnutChart(dataset2, labels2, `chart${value}`);
        } else {
            renderDoughnutChart(dataset3, labels3, `chart${value}`);
        }
        
    }

    // Function to generate and render a doughnut chart using ApexCharts
    function renderDoughnutChart(dataset, labels, containerId) {
        const options = {
            chart: {
                type: 'donut',
                toolbar: {
                    show: true
                }
            },
            series: dataset,
            labels: labels,
        };

        const chart = new ApexCharts(document.getElementById(containerId), options);
        chart.render();
    }

    createContainer(list);

How do I correct and manage this?

Why is my React code’s try catch block not working?

MY REACT CODE IS:

import { type } from "@testing-library/user-event/dist/type";

import React, { useState } from "react";

import "./clint.css";

export default function Addtask() {
  const [task, setTask] = useState([]);

  const [text, setText] = useState("");

  const handleSubmit = async () => {
    try {
      setTask([...task, text]);

      const resp = await fetch("http://localhost:5000/addtask", {
        method: "POST",

        body: JSON.stringify(text),

        headers: { "content-type": "application/json" },
      });

      if (resp.status === 201) {
        alert("task added successfully");
      } else {
        alert("some error occurred while uploading");
      }
    } catch (error) {
      console.log(error);
    }
  };

  function change(e) {
    const ip = e.target.value;

    setText(ip);
  }

  return (
    <div>
      <h1>add user component</h1>

      <span>Add Task</span>

      <input onChange={change} placeholder="add a task" />

      <button type="submit" onClick={handleSubmit}>
        submit
      </button>

      <ul>
        {task.map((task) => (
          <li>{task}</li>
        ))}
      </ul>
    </div>
  );
}

MY NODE JS CODE IS:

const express = require("express");

const storage = require("node-persist");

const cors = require("cors");

const app = express();

app.use(express.json());

storage.init();

app.use(cors());

app.post("/addtask", async (req, res) => {
  const { task } = req.body;

  try {
    const resp = await storage.setItem(task);

    res.send("task added");
  } catch (error) {
    res.send({ message: "some error occured", error });

    console.log(error);
  }
});

app.listen(5000);

MY POSTMAN CODE IS:

{

"task": "go shop"

}

postman url is http://localhost:5000/addtask which is running in post method.

But why does my React js code’s try catch block not working?

Custom declarative Canvas components in React.js – optimization difficulties

I’m unable to understand if I’m going in the wrong direction or not when optimizing custom declarative Canvas components in React.js. The performance issue arises specifically when animating. A quick sandbox re-creation of the scenario with code:

https://codesandbox.io/s/canvas-worker-animation-ytlqqh

The main concept idea is to have a wrapping Canvas component (CanvasComponent.jsx), which wraps painting / drawing components (for ex.: an Image CanvasImage.jsx, Line …etc.), who then set their draw “instructions” to the wrapper’s drawMethods state, a Map. I’m using the Map to enforce a “declarative layering”, i.e. the second child paints over the first child, just like you’d normally expect writing HTML.
The wrapping Canvas component then runs the redraw() function every time the drawMethods state changes, which sends the “instructions” array to canvas.worker.js, which then repaints each “instruction” and updates the onscreen canvas.
All of this is fine until you start animating a couple of child x and y states – one of the components stays visible and moves with relatively low framerates and flickers, while the rest appear to be flickering so much that they are basically no longer visible. The CPU usage quickly increases in <StrictMode> even with just one element animating (from around 2% usage to 20%). It is a bit better without strict, which I understand why it is that way, however, it’s still worse than I’d expect. Some manage to create some fond 2d games with canvas, while my solution already goes nuts just by animating one component.

Would greatly appreciate it if anyone could tell me what’s wrong with my implementation, and what would I need to change. The last points I’ve read about are SharedArrayBuffer and using multiple Canvas elements, neither of which would fit since I can’t always guarantee crossOriginIsolated for the buffer, not to say that multiple Canvas drawings could add up dynamically so I’m not sure how would I dynamically reserve a proper amount of bytes to share between main and worker threads, and with the “mouse move and click events”, which could be blocked by a top Canvas layer.

Problem with sidebar hiding after clicking outside it

For the past two weeks I have been struggling with the functionality that is supposed to hide the “sidebar” when you click outside the article list. Unfortunately this does not happen and only works when clicking on the icon.

left-menu.vue:

<template>
  <aside
    v-click-outside="onClickOutside"
    class="topnav left-menu p-3"
    id="myTopnav"
    :class="{ 'left-menu--show': showAside }"
  >
    <ul class="left-menu__list">
      <li class="left-menu__list__link"><a href="#">Article 1</a></li>
      <li class="left-menu__list__link"><a href="#">Article 2</a></li>
      <li class="left-menu__list__link"><a href="#">Article 3</a></li>
      <li class="left-menu__list__link"><a href="#">Article 4</a></li>
      <li class="left-menu__list__link"><a href="#">Article 5</a></li>
    </ul>
  </aside>
</template>

<script>
import { mapMutations, mapState } from "vuex";
export default {
  data() {
    return {
      active: false,
    };
  },
  computed: {
    ...mapState("LeftMenu", ["showAside"]),
  },
  methods: {
    onClickOutside() {
      this.active = !this.active;
    },
    ...mapMutations("LeftMenu", { toggleShowAside: "toggleShowAside" }),
  },
};
</script>

<style lang="scss">
.left-menu {
  position: relative;
  width: 20%;
  display: flex;
  align-items: left;
}
.left-menu__list {
  width: 100%;
  list-style-type: none;
  letter-spacing: 1px;
}
.left-menu__list__link {
  padding: 5px 0;
}
.left-menu__list__link a {
  text-decoration: none;
  color: #b3bcc3;
  &:hover {
    color: #fff;
  }
}
.left-menu__toolbar {
  list-style-type: none;
}
.icon {
  display: none;
}
@media screen and (max-width: 992px) {
  .left-menu__list {
    font-size: 12px;
    width: 120px;
    position: fixed;
    top: 107px;
    left: -100%;
    background-color: #343a40;
    transition: 0.7s all;
  }
  .left-menu--show .left-menu__list {
    left: 0;
  }
  .left-menu__container {
    width: 20%;
  }
  .left-menu__toolbar .icon {
    float: right;
    display: block;
  }
}
</style>

aside-toggles.vue:

<template>
  <aside class="aside__tooglers__container" :class="{ responsive: showAside }">
    <b-icon
      class="aside__left__icon d-lg-none"
      @click="toggleShowAside"
      icon="list"
      aria-hidden="true"
    ></b-icon>
    <b-icon
      class="aside__right__icon d-lg-none"
      @click="toggleShowRightAside"
      icon="three-dots"
      aria-hidden="true"
    ></b-icon>
  </aside>
</template>

<script>
import { mapMutations, mapState } from "vuex";

export default {
  computed: {
    ...mapState("LeftMenu", ["showAside"]),
    ...mapState("RightMenu", ["showAside"]),
  },
  methods: {
    ...mapMutations("LeftMenu", { toggleShowAside: "toggleShowAside" }),
    ...mapMutations("RightMenu", { toggleShowRightAside: "toggleShowAside" }),
  },
};
</script>

<style>
@media screen and (max-width: 992px) {
  .aside__tooglers__container {
    padding: 15px 0;
    background: #343a40;
    display: flex;
    justify-content: space-between;
  }
  .aside__left__icon {
    padding-left: 32px;
    color: white;
  }
  .aside__right__icon {
    padding-right: 38px;
    color: white;
  }
}
</style>

left-menu.module.js:

export default {
    namespaced: true,
    state: {
        showAside: false
    },
    mutations: {
        toggleShowAside(state) {
            state.showAside = !state.showAside;
        },
    },
}

I tried using v-outside-click but it doesn’t work.
Are there any other methods ?
Please help me with an explanation.

Generating Images from a Complex DOM (Including iframes)

I’m working on an application (am owner) similar to Canva (wouldn’t be a competitor), where the “canvas” is constructed of standard DOM elements instead of the HTML canvas element. I’m currently working out how to export a canvases DOM and with the following requirements:

  1. Complex Content Handling: The exported view should accurately
    capture intricate DOM components, especially iframes.
  2. Diverse Export Formats: The solution should support various file
    types, notably png, jpg, svg, and a nice-to-have would be mp4.
  3. High-Quality Exports: The exported files should maintain high
    resolution and fidelity, closely resembling the original content.
  4. Transparent image support.

I’m looking at tools like Puppeteer and html2canvas. While both are promising,, I’m uncertain about their ability to meet the above requirements and also their ease-of-use. I’ve used html2canvas before and it was a bit of a headache.

How might platforms like Canva, which likely have similar requirements, manage such exports? This is a long shot but anyone from Canva around to answer 😀

Recommendations, insights, or suggestions for alternative methods would be greatly appreciated.

i want a field in model driven app shown if its created from the ribbon but hidden if users created from a subgrid

I have a look up field in model driven app form I want it to be shown if its created from OOTB + ribbon but hidden if users created from a subgrid.
Is there a way to accomplish this using javascript or if its any other way to do this. Much appriciated

I have a look up field in model driven app form I want it to be shown if its created from OOTB + ribbon but hidden if users created from a subgrid.
Is there a way to accomplish this using javascript or if its any other way to do this. Much appriciated

Not able to bind change or ngModelChange to ng-select using addEventListener

I have a formgroup with multiple controls like input, ng-selects etc.
Now, I want to get notified whenever user changes value of some specific inputs and ng-selects.
I don’t want to do it via valueChanges subscribe due to some reasons.

For sample scenario, I have created one input and one ng-select control and binding change event to input and ng-select using addEventListener. It’s working fine for inputs but not for ng-selects.
I have tried changing the event to ngModelChange for ng-select but still it’s not working.

Also, I wanted to pick the common elements using viewchildren via common class abc but the element list is not coming when picking via class.

Below is the code.
HTML
<form action="" [formGroup]="doomsForm"> <input class="abc" type="text" placeholder="Enter Name" formControlName="name" #qwe /> <ng-select [items]="ageArr" formControlName="age" placeholder="Enter Age" #qwe class="abc" ></ng-select> </form>

TS Code
`@ViewChildren(‘qwe’, { read: ElementRef }) commonElements!: QueryList;
@ViewChildren(‘.abc’, { read: ElementRef }) commonElements!: QueryList;
// above line for view children using .abc class is not working

ngAfterViewInit() {
    this.ValueChange();
}
ValueChange() {
const elements = this.commonElements.toArray();

// Add event listeners dynamically
elements.forEach((element, index) => {
  if (element.nativeElement.tagName === 'INPUT') {
    element.nativeElement.addEventListener('change', () => {
      // Handle change for input or ng-select elements
      this.onInputChange(element.nativeElement.value, index);
    });
  } else if (element.nativeElement.tagName === 'NG-SELECT') {
    element.nativeElement.addEventListener('ngModelChange', () => {
      this.onSelectChange(element.nativeElement, index);
      // }
    });
  }
});
}
onInputChange(value: string, index: number) {
console.log(`Input ${index + 1} value changed:`, value);
}

onSelectChange(element: any, index: number) {
console.log(`Ng-select ${index + 1} value changed:`, element.selectedItems);
}`