NullPointerException when running in GitLab CI/CD

Question: I'm running code coverage analysis using the Clover Maven plugin on my multi-module project and on my machine all runs fine. When I push to GitLab though, the runners fail on Clover execution, with many NullPointerExceptions in the log:
253348 [ERROR] Failed to execute goal org.openclover:clover-maven-plugin:4.2.1:clover (default-cli) on project axians-framework: Execution default-cli of goal org.openclover:clover-maven-plugin:4.2.1:clover failed: java.lang.InternalError: java.lang.reflect.InvocationTargetException: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openclover:clover-maven-plugin:4.2.1:clover (default-cli) on project axians-framework: Execution default-cli of goal org.openclover:clover-maven-plugin:4.2.1:clover failed: java.lang.InternalError: java.lang.reflect.InvocationTargetException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.openclover:clover-maven-plugin:4.2.1:clover failed: java.lang.InternalError: java.lang.reflect.InvocationTargetException
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.tools.ant.BuildException: java.lang.InternalError: java.lang.reflect.InvocationTargetException
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:116)
    at org.apache.tools.ant.Task.perform (Task.java:348)
    at org.apache.tools.ant.Target.execute (Target.java:435)
    at org.apache.tools.ant.Target.performTasks (Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1364)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.createReport (CloverReportMojo.java:461)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.createAllReportTypes (CloverReportMojo.java:404)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.executeReport (CloverReportMojo.java:393)
    at org.apache.maven.reporting.AbstractMavenReport.generate (AbstractMavenReport.java:135)
    at org.apache.maven.reporting.AbstractMavenReport.execute (AbstractMavenReport.java:87)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
253358 [WARNING] null
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecutejava.lang.NullPointerException (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute
 (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main    at com.atlassian.clover.reporters.html.RenderFileAction.call (RenderFileAction.java:111)
    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call (CloverExecutors.java:91)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
    at java.lang.Thread.run (Thread.java:844)
253365 [WARNING] null
java.lang.NullPointerException
    at253362 [WARNING] null
java.lang.NullPointerException
 (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke com.atlassian.clover.reporters.html.RenderFileAction.call (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (RenderFileAction.java:111) (Method.java:564)
        atat org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call (Launcher.java:289)
 com.atlassian.clover.reporters.html.RenderFileAction.call    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (CloverExecutors.java:91)
    at (RenderFileAction.java:111)
    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415) (CloverExecutors.java:91)

    at java.util.concurrent.FutureTask.runat org.codehaus.plexus.classworlds.launcher.Launcher.main (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (Launcher.java:356)
Caused by: java.lang.InternalError: java.lang.reflect.InvocationTargetException java.util.concurrent.FutureTask.run
 (ThreadPoolExecutor.java:1167)
    at (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
     java.util.concurrent.ThreadPoolExecutor$Worker.runat java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
    at java.lang.Thread.run (ThreadPoolExecutor.java:641)
 (Thread.java:844)
at253369 [WARNING] null
 java.lang.Thread.runjava.lang.NullPointerException
    at com.atlassian.clover.reporters.html.RenderFileAction.call (Thread.java:844)
 (RenderFileAction.java:111)
    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call253370 [WARNING] null
java.lang.NullPointerException (CloverExecutors.java:91)

        atat java.util.concurrent.FutureTask.run com.atlassian.clover.reporters.html.RenderFileAction.call (FutureTask.java:264)
     (RenderFileAction.java:111)at
    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call java.util.concurrent.ThreadPoolExecutor.runWorker (CloverExecutors.java:91)
     (ThreadPoolExecutor.java:1167)at
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
    at java.util.concurrent.FutureTask.run java.lang.Thread.run (Thread.java:844)
 (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
    253371 [WARNING] null
java.lang.NullPointerException
at     java.lang.Thread.runat (Thread.java:844)
 com.atlassian.clover.reporters.html.RenderFileAction.call253372 [WARNING] null
 (RenderFileAction.java:111)java.lang.NullPointerException

    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call (CloverExecutors.java:91)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at    at sun.font.FontManagerFactory$1.run (FontManagerFactory.java:86)
    at java.security.AccessController.doPrivileged (Native Method)
    at sun.font.FontManagerFactory.getInstance (FontManagerFactory.java:74)
        at sun.font.SunFontManager.getInstance java.util.concurrent.ThreadPoolExecutor.runWorker (SunFontManager.java:251)at
     com.atlassian.clover.reporters.html.RenderFileAction.callat sun.font.FontDesignMetrics.getMetrics (FontDesignMetrics.java:264)
    at sun.java2d.SunGraphics2D.getFontMetrics (ThreadPoolExecutor.java:1167)
     (RenderFileAction.java:111)
    atat (SunGraphics2D.java:864)
    at clover.org.jfree.chart.axis.ValueAxis.findMaximumTickLabelWidth java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
    at com.atlassian.clover.util.CloverExecutors$LoggingCallable.call (CloverExecutors.java:91) java.lang.Thread.run (Thread.java:844)
 (ValueAxis.java:916)
    at clover.org.jfree.chart.axis.ValueAxis.reserveSpace (ValueAxis.java:828)
    at clover.org.jfree.chart.plot.XYPlot.calculateRangeAxisSpace
    at (XYPlot.java:3077)
    at clover.org.jfree.chart.plot.XYPlot.calculateAxisSpace java.util.concurrent.FutureTask.run (XYPlot.java:2988)
    at clover.org.jfree.chart.plot.XYPlot.draw (FutureTask.java:264) (XYPlot.java:3132)
    at java.util.concurrent.ThreadPoolExecutor.runWorker
    at clover.org.jfree.chart.JFreeChart.draw (ThreadPoolExecutor.java:1167) (JFreeChart.java:1229)
    at
    at clover.org.jfree.chart.JFreeChart.createBufferedImage java.util.concurrent.ThreadPoolExecutor$Worker.run (JFreeChart.java:1399)
    at (ThreadPoolExecutor.java:641) clover.org.jfree.chart.ChartUtilities.writeChartAsPNG
    at java.lang.Thread.run (ChartUtilities.java:211)
    at clover.org.jfree.chart.ChartUtilities.saveChartAsPNG (ChartUtilities.java:341)
    at com.atlassian.clover.reporters.util.CloverChartFactory.generateHistogramChart (Thread.java:844)
 (CloverChartFactory.java:156)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeCurrentReport (HtmlReporter.java:267)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeImpl (HtmlReporter.java:189)
    at com.atlassian.clover.reporters.CloverReporter.execute (CloverReporter.java:38)
    at com.atlassian.clover.ant.tasks.CloverReportTask.generateReports (CloverReportTask.java:435)
    at com.atlassian.clover.ant.tasks.CloverReportTask.cloverExecute (CloverReportTask.java:395)
    at com.atlassian.clover.ant.tasks.AbstractCloverTask.execute (AbstractCloverTask.java:57)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:292)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform (Task.java:348)
    at org.apache.tools.ant.Target.execute (Target.java:435)
    at org.apache.tools.ant.Target.performTasks (Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1364)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.createReport (CloverReportMojo.java:461)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.createAllReportTypes (CloverReportMojo.java:404)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.executeReport (CloverReportMojo.java:393)
    at org.apache.maven.reporting.AbstractMavenReport.generate (AbstractMavenReport.java:135)
    at org.apache.maven.reporting.AbstractMavenReport.execute (AbstractMavenReport.java:87)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:488)
    at sun.font.FontManagerFactory$1.run (FontManagerFactory.java:84)
    at java.security.AccessController.doPrivileged (Native Method)
    at sun.font.FontManagerFactory.getInstance (FontManagerFactory.java:74)
    at sun.font.SunFontManager.getInstance (SunFontManager.java:251)
    at sun.font.FontDesignMetrics.getMetrics (FontDesignMetrics.java:264)
    at sun.java2d.SunGraphics2D.getFontMetrics (SunGraphics2D.java:864)
    at clover.org.jfree.chart.axis.ValueAxis.findMaximumTickLabelWidth (ValueAxis.java:916)
    at clover.org.jfree.chart.axis.ValueAxis.reserveSpace (ValueAxis.java:828)
    at clover.org.jfree.chart.plot.XYPlot.calculateRangeAxisSpace (XYPlot.java:3077)
    at clover.org.jfree.chart.plot.XYPlot.calculateAxisSpace (XYPlot.java:2988)
    at clover.org.jfree.chart.plot.XYPlot.draw (XYPlot.java:3132)
    at clover.org.jfree.chart.JFreeChart.draw (JFreeChart.java:1229)
    at clover.org.jfree.chart.JFreeChart.createBufferedImage (JFreeChart.java:1399)
    at clover.org.jfree.chart.ChartUtilities.writeChartAsPNG (ChartUtilities.java:211)
    at clover.org.jfree.chart.ChartUtilities.saveChartAsPNG (ChartUtilities.java:341)
    at com.atlassian.clover.reporters.util.CloverChartFactory.generateHistogramChart (CloverChartFactory.java:156)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeCurrentReport (HtmlReporter.java:267)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeImpl (HtmlReporter.java:189)
    at com.atlassian.clover.reporters.CloverReporter.execute (CloverReporter.java:38)
    at com.atlassian.clover.ant.tasks.CloverReportTask.generateReports (CloverReportTask.java:435)
    at com.atlassian.clover.ant.tasks.CloverReportTask.cloverExecute (CloverReportTask.java:395)
    at com.atlassian.clover.ant.tasks.AbstractCloverTask.execute (AbstractCloverTask.java:57)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:292)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform (Task.java:348)
    at org.apache.tools.ant.Target.execute (Target.java:435)
    at org.apache.tools.ant.Target.performTasks (Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1364)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.createReport (CloverReportMojo.java:461)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.createAllReportTypes (CloverReportMojo.java:404)
    at com.atlassian.maven.plugin.clover.CloverReportMojo.executeReport (CloverReportMojo.java:393)
    at org.apache.maven.reporting.AbstractMavenReport.generate (AbstractMavenReport.java:135)
    at org.apache.maven.reporting.AbstractMavenReport.execute (AbstractMavenReport.java:87)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.lang.NullPointerException
    at sun.awt.FontConfiguration.getVersion (FontConfiguration.java:1288)
    at sun.awt.FontConfiguration.readFontConfigFile (FontConfiguration.java:225)
    at sun.awt.FontConfiguration.init (FontConfiguration.java:107)
    at sun.awt.X11FontManager.createFontConfiguration (X11FontManager.java:765)
    at sun.font.SunFontManager$2.run (SunFontManager.java:440)
    at java.security.AccessController.doPrivileged (Native Method)
    at sun.font.SunFontManager.<init> (SunFontManager.java:385)
    at sun.awt.FcFontManager.<init> (FcFontManager.java:35)
    at sun.awt.X11FontManager.<init> (X11FontManager.java:56)
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:488)
    at sun.font.FontManagerFactory$1.run (FontManagerFactory.java:84)
    at java.security.AccessController.doPrivileged (Native Method)
    at sun.font.FontManagerFactory.getInstance (FontManagerFactory.java:74)
    at sun.font.SunFontManager.getInstance (SunFontManager.java:251)
    at sun.font.FontDesignMetrics.getMetrics (FontDesignMetrics.java:264)
    at sun.java2d.SunGraphics2D.getFontMetrics (SunGraphics2D.java:864)
    at clover.org.jfree.chart.axis.ValueAxis.findMaximumTickLabelWidth (ValueAxis.java:916)
    at clover.org.jfree.chart.axis.ValueAxis.reserveSpace (ValueAxis.java:828)
    at clover.org.jfree.chart.plot.XYPlot.calculateRangeAxisSpace (XYPlot.java:3077)
    at clover.org.jfree.chart.plot.XYPlot.calculateAxisSpace (XYPlot.java:2988)
    at clover.org.jfree.chart.plot.XYPlot.draw (XYPlot.java:3132)
    at clover.org.jfree.chart.JFreeChart.draw (JFreeChart.java:1229)
    at clover.org.jfree.chart.JFreeChart.createBufferedImage (JFreeChart.java:1399)
    at clover.org.jfree.chart.ChartUtilities.writeChartAsPNG (ChartUtilities.java:211)
    at clover.org.jfree.chart.ChartUtilities.saveChartAsPNG (ChartUtilities.java:341)
    at com.atlassian.clover.reporters.util.CloverChartFactory.generateHistogramChart (CloverChartFactory.java:156)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeCurrentReport (HtmlReporter.java:267)
    at com.atlassian.clover.reporters.html.HtmlReporter.executeImpl (HtmlReporter.java:189)
    at com.atlassian.clover.reporters.CloverReporter.execute (CloverReporter.java:38)
    at com.atlassian.clover.ant.tasks.CloverReportTask.generateReports (CloverReportTask.java:435)
    253543 [WARNING] null
java.lang.NullPointerException
at     com.atlassian.clover.ant.tasks.CloverReportTask.cloverExecuteat (CloverReportTask.java:395)
    at com.atlassian.clover.ant.tasks.AbstractCloverTask.execute (AbstractCloverTask.java:57)
    at org.apache.tools.ant.UnknownElement.execute com.atlassian.clover.reporters.html.RenderFileAction.call (UnknownElement.java:292)
    ...

This is the relevant part of my .gitlab-ci.yml
verify:
  stage: verify
  tags:
    - maven
    - jdk-9
  script:
    - 'mvn clover:setup verify clover:aggregate clover:clover'

and the docker image of the runner is maven:3-jdk-9-slim.
I've tried fine-tuning the JVM memory but it fails nevertheless, and I can't find the cause of the failure. Any suggestion?
Comment: According to my knowledge nobody adapted OpenClover to Java 9 yet so there might be some problems with module system, especially if you use a 'slim' version. I'm not sure what's the difference and what slim version does contain but it seems like OpenClover tries to log something and it fails due to missing classes.
Comment: AFAIK the slim variant does not contain the Java UI stuff, nothing that Clover might use I suppose.
Comment: Not necessarily. Take a look at stacktrace: ```clover.org.jfree.chart.JFreeChart.createBufferedImage```
Clover uses varies of libraries to generate HTML reports. If you don't need them you might disable HTML report generation in favor of XML ones.
Comment: That was it: disabling HTML reports fixed the issue. Thank you!
Answer: Issue is with font configuration. See https://github.com/docker-library/openjdk/issues/73#issuecomment-284526727
On Debian, openjdk-9 is missing a dependency to libfontconfig1
Install that dependency in your Docker image and all is gonna work fine.


Score reset script

Question:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ResetButton : MonoBehaviour
{
    public static ResetButton Instance;
    public bool isGameOver = false;
    public Score score;

    public Text scoreText;
    public Button yourButton;
    internal static object instance;

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }

    // Start is called before the first frame update
    void Start()
    {
        Button btn = yourButton.GetComponent<Button>();
        btn.onClick.AddListener(TaskOnClick);

    }

    public void TaskOnClick()
    {
        ScorePanelUpdater.Score = 0;
    }

    // Update is called once per frame
    void Update()
    {
        if (isGameOver && Input.GetMouseButtonDown(0))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

        }

    }

}

I make a quiz game and I want my score to reset when you touch the button reset score. The quiz have different score scripts for 20 questions ( after you finish the first 20 questions , you start another quiz with different score for the next 20 questions ) I want a code that works with a specific Score script ( not to reset all scores from the game in the same time)
ScorePanel16:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class ScorePanel16 : MonoBehaviour
{
    // better if you can already reference this via Inspector
    [SerializeField] Text text;

    void Awake()
    {
        if (!text) text = GetComponent<Text>();

        // it's always save to remove listeners before adding them
        // makes sure it is added only once
        GameInstance16.OnScoreChanged -= OnScoreChanged;
        GameInstance16.OnScoreChanged += OnScoreChanged;

        // invoke once now with current value
        OnScoreChanged(GameInstance16.Score);
    }

    private void OnDestroy()
    {
        GameInstance16.OnScoreChanged -= OnScoreChanged;
    }

    private void OnScoreChanged(int newValue)
    {
        text.text = "Score: " + newValue;
    }
}

GameInstance15:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public static class GameInstance15
{
    // Start is called before the first frame update
    private static int _score = 0;

    // have an event to register listeners
    public static event Action<int> OnScoreChanged;

    // public property
    public static int Score
    {
        get { return _score; }
        set
        {
            _score = value;

            // invoke an event to inform all registered listeners
            OnScoreChanged?.Invoke(_score);
        }
    }
}

Score16:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Score16 : MonoBehaviour
{
    public Text scoreText;
    public Button button;

    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(gameObject);

        if (!button) button = GetComponent<Button>();
        button.onClick.AddListener(() => { GameInstance16.Score++; });

        GameInstance16.OnScoreChanged -= OnScoreChanged;
        GameInstance16.OnScoreChanged += OnScoreChanged;

        // invoke once now with current value
        Debug.LogFormat("Current Score: {0}", GameInstance16.Score);
        OnScoreChanged(GameInstance16.Score);

    }

    private void OnDestroy()
    {
        GameInstance16.OnScoreChanged -= OnScoreChanged;
    }

    private void OnScoreChanged(int newValue)
    {
        scoreText.text = "Score: " + newValue;
    }

    // These two make not much sense .. since the value already was public
    // you wouldn't need methods for this
    // anyway now you could directly do it on GameInformation instead
    public void AddScore(int s)
    {
        GameInstance16.Score += s;
    }

    public int GetScore()
    {
        return GameInstance16.Score;
    }
}

Comment: You really shouldn't be defining a separate set of classes for each quiz... You should be able to have a [game manager](https://stackoverflow.com/questions/13730112/unity-singleton-manager-classes) that has a list of `GameInstance`s like `List quizInstances;` , so you can do `quizInstances[i].Score`. So, you could reset the scores as necessary with `quizInstances[i].Score = 0;`. Each `Score` and `ScorePanel` object should have an int field `public int quizIndex;` that tells it what quiz it's in, so it can modify `GameManager.instance.quizInstances[quizIndex].Score` as needed.
Comment: I add a new script @Ruzihm tell me if it is what u said , but I have an error
Comment: I called it ResetButton instead Game Manager
Answer: After a completing a quiz(with 20) questions. Save and add the score in PlayerPref using PlayerPrefs.SetInt("totalScore",score);  If you like to reset before completing just clear currentScore.Else if you completed the game ,then score=PlayerPrefs.GetInt("totalScore")+currentScore;.In next line again set the score
using PlayerPrefs.SetInt("totalScore",score);

Score reset script


Como especificar a demanda no lpSolveAPI em R?

Question: Eu estou tentando otimizar o lucro por 4 produtos diferentes, um que lucra 600reais/unidade  outro que lucra 550/unidade outro que lucra  400/unidade e outro que lucra 300/unidade.
Porem a demanda pelo x1 = 50 pelo x2 = 50 pelo x3 = 80 e pelo x4 = 120.
Como eu especifico a demanda individual de cada dentro do lpSolveAPI??
library(lpSolveAPI)
lprec <- make.lp(0,4) #numero de linhas e de variaveis de decisao
lp.control(lprec,sense='max') #maximzar ou minimizar
set.objfn(lprec, c(600, 550, 400, 300)) # funcao objetivo
add.constraint(lprec, c(31540, 40000, 29600, 14700), "<=", 108000) #restricao 1
add.constraint(lprec, c(36290,22500,42550,7350), "<=", 110000) #restricao 2
add.constraint(lprec, c(19000, 11250,11840,16800), "<=", 60000) #restricao 3

solve(lprec) #resolver ppl
get.objective(lprec) #funcao objetivo resolvida
get.variables(lprec) #qto de cada variavel otimiza o sistema
get.constraints(lprec)
lprec

Answer: O pacote lpSolveAPI aceita restrições de três tipos, "<=", ">=" e "=". Creio que na pergunta a demanda deve ser entendida com demanda máxima, não como demanda fixa. Então as restrições a serem usadas serão de menoridade, "<="
#x1 = 50, pelo x2 = 50, pelo x3 = 80 e pelo x4 = 120
add.constraint(lprec, 1, "<=", 50, indices = 1) #restricao 4a
add.constraint(lprec, 1, "<=", 50, indices = 2) #restricao 4b
add.constraint(lprec, 1, "<=", 80, indices = 3) #restricao 4c
add.constraint(lprec, 1, "<=", 120, indices = 4) #restricao 4d

Agora resolve-se o problema tal como está na pergunta. As soluções serão dadas por get.variables(lprec).
solve(lprec) #resolver ppl
#[1] 0

get.objective(lprec) #funcao objetivo resolvida
#[1] 1948.62

get.variables(lprec) #qto de cada variavel otimiza o sistema
#[1] 2.6654343 0.5221156 0.0000000 0.2073184

Verificar estas soluções multiplicando os coeficientes da função objetivo pelo vetor solução.
c(600, 550, 400, 300) %*% get.variables(lprec)
#        [,1]
#[1,] 1948.62


How to add one long scrollable image into HTML/CSS?

Question: (Beginner question)
Hello, I'm trying to create a site that has one long image as a background that you can scroll. Nothing fancy, just one image of 1920x3740 of which you can only see a viewport-sized section of. I added an image to clarify what I mean.

I've tried using multiple divs under each other of 1920x1080, and chopped the image up to fit correctly, which kind of worked, but they wouldn't stay 16x9 so the edges of each image didn't match up. Now what i've got is one big image but I can't scroll it.
HTML:

CSS:
.bgImageFull{
  background-image: url(../images/LandingPage/NEW_TAHIN_IMAGE_FULL.jpg);
  height: 100%;
  width: 100%;
  background-repeat: no-repeat;
  background-size: cover;
}

This also goes before but I don't think it does anything for my issue:
*{
  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}

html, body{
  height: 100%;
  font-family: 'functionPro';
}

Answer: .bgImageFull {
    background-image: url(../images/LandingPage/NEW_TAHIN_IMAGE_FULL.jpg);
    height: 3740px;
    width: 100%;
    background-repeat: no-repeat;
    background-size: cover;
}

Height: 100%; Could be what's messing this up for you.
It might be better to specify the actual height of your image in the image's class. 100% is just going to cover the available height of the parent element.
Comment: Wow, how come I didn't think of this yet?! TYSM! It scales from 1080p width to infinity, but the only problem is that it won't go lower while displaying the full width of the image. Which in this case actually isn't too bad, but do you know how I would do that?
Comment: Sorry! I just fixed it. I used a height of 200vw, so the height would be relative to the current viewport width. But thanks for the insights, im a complete beginner on stack overflow so what you've just suggested will definitely help.in the future. Thanks again!
Comment: Edit to first comment: Hmm upon further inspection, it works well enough for normal screens, but when I scale the window up, the bottom of the image is cut off because the height is fixed. The full image should always remain visible. Weirdly I can't find much about this problem on the internet...
Comment: I could also be misunderstanding what you're attempting to do. It seems like you're trying to create a responsive layout of some kind. Do you have any screenshots for reference?
Comment: Adding a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) might help too


Not able to print the filenames in a gridview

Question: I am trying to create a page in ASP.NET which allows me to see the list of all the files in my Files directory. I want to show only the filenames and allow user to edit the files later.
I have tried this approach here for getting all the filenames and making a datatable then binding that to a gridview. This is my code.
protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            DataRow row;
            dt.Columns.Add("FileNames",typeof(string));
            string path = Server.MapPath("~/Files");
            DirectoryInfo di = new DirectoryInfo(path);
            foreach (FileInfo fi in di.GetFiles()) {
                row = dt.NewRow();
                row["FileNames"] = fi.ToString();
                dt.Rows.Add(row);
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
            }

I am not able to understand what is the problem here. When I run the page I see an empty GridView with just a header row with the title of FileName but not the names of the files. I have checked there are files in my "Files" folder and using response.write() I am also able to print those names but not able to show it in a gridview.
Here is my Gridview code
 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
           <Columns>
               <asp:TemplateField HeaderText="FileNames">
                   <EditItemTemplate>
                       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                   </EditItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label1"  runat="server"></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
           </Columns>
       </asp:GridView>

Help me understand this approach and show me the way to print the names in gridview.
Answer: You have two issues
First this:
fi.ToString();

But, "fi" is a file info type. You need to use/pull the file name, like this:
fi.Name (for file name)
fi.FullName (for full file name)

And, you have to as the other poster noted to use Eval() expressions.
You can have the grid automatic create the columns. So, with this markup:

  <asp:GridView ID="GridView1" runat="server" CssClass="table table-hover">
  </asp:GridView>

Then say this code:
   protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack) {
            LoadFiles();
        }
    }

    public void LoadFiles()
    {
        MyTable.Columns.Add("Date", typeof(string));
        MyTable.Columns.Add("File Size", typeof(string));
        MyTable.Columns.Add("File Name", typeof(string));
        MyTable.Columns.Add("FullFile", typeof(string));

        var strFolder = Server.MapPath("~/Scripts");

        DirectoryInfo MyDir = new DirectoryInfo(strFolder);
        FileInfo[] MyFiles = MyDir.GetFiles("*.*");

        foreach (FileInfo MyFile in MyFiles)
        {
            // Dim oneRow As DataRow = MyTable.Rows.Add
            DataRow oneRow;
            oneRow = MyTable.NewRow();

            oneRow["Date"] = MyFile.LastAccessTime.ToShortDateString();
            oneRow["File Size"] = (int)(MyFile.Length / (double)1024) + " KB";
            oneRow["File Name"] = MyFile.Name;
            oneRow["FullFile"] = MyFile.FullName;

            MyTable.Rows.Add(oneRow);
        }

        GridView1.DataSource = MyTable;
        GridView1.DataBind();
    }

OutPut:

If you want to drop in (have controls) on the gridview, then you can of course use template fields. You can use databoundfield like this:
NOTE the AutoGeneratecolumns = false now
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CssClass="table table-hover">
   <Columns>
     <asp:BoundField DataField="Date" HeaderText="Date" ItemStyle-Width="100px" />
     <asp:BoundField DataField="File Name" HeaderText="ID" />
     <asp:BoundField DataField="FullFile" HeaderText="ID" />
     <asp:BoundField DataField="File Size" HeaderText="Size" ItemStyle-Width="100px" />
   </Columns>
  </asp:GridView>

The output would be much identical to the first example.
Adding a button to the above, we could thus click on a row, get the information.
So, our markup becomes like this say. We don't really have to add the columns if we auto generate, but lets do so, and thus we can control placement of controls (such as our view button).
So, now here is the complete mark-up and code used:

            <asp:GridView ID="GridView1" runat="server" CssClass="table table-hover" AutoGenerateColumns="false">

                <Columns>
                <asp:BoundField DataField="Date" HeaderText="Date" ItemStyle-Width="100px" />
                <asp:BoundField DataField="File Name" HeaderText="File Name" />
                <asp:BoundField DataField="FullFile" HeaderText="Full File" />
                <asp:BoundField DataField="File Size" HeaderText="Size" ItemStyle-Width="100px" />

                    <asp:TemplateField HeaderText="View">
                        <ItemTemplate>
                            <asp:Button ID="cmdView" runat="server" Text="View"
                                CommandName="Select"
                                OnClick="cmdView_Click"/>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
             </asp:GridView>

Now our code:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            LoadFiles();
        }
    }

    public void LoadFiles()
    {
        DataTable MyTable = new DataTable();

        MyTable.Columns.Add("Date", typeof(string));
        MyTable.Columns.Add("File Size", typeof(string));
        MyTable.Columns.Add("File Name", typeof(string));
        MyTable.Columns.Add("FullFile", typeof(string));

        var strFolder = Server.MapPath("~/Scripts");

        DirectoryInfo MyDir = new DirectoryInfo(strFolder);
        FileInfo[] MyFiles = MyDir.GetFiles("*.*");

        foreach (FileInfo MyFile in MyFiles)
        {
            // Dim oneRow As DataRow = MyTable.Rows.Add
            DataRow oneRow;
            oneRow = MyTable.NewRow();

            oneRow["Date"] = MyFile.LastAccessTime.ToShortDateString();
            oneRow["File Size"] = (int)(MyFile.Length / (double)1024) + " KB";
            oneRow["File Name"] = MyFile.Name;
            oneRow["FullFile"] = MyFile.FullName;

            MyTable.Rows.Add(oneRow);
        }

        GridView1.DataSource = MyTable;
        GridView1.DataBind();
    }

    protected void cmdView_Click(object sender, EventArgs e)
    {
        Button btn = (Button)sender;
        GridViewRow gvR = (GridViewRow)btn.Parent.Parent;

        Response.Write("
 File name selected = " + gvR.Cells[2].Text + "
");

    }

And now our output:
And note how we can now click on any row. I clicked on 2nd row for this screen shot:

Note the cool trick to get the grid row with one click - don't hve to use data item index change and all that non-sense.
Just drag + drop in the asp .net button into grid view (inside the template), and then add the click event as I did.
FYI: Note that you MUST include the CommandName="Select". This will cause the row index position to change - if you don't include that, then our simple button click will NOT get/see the current grid row selected. So, don't forget that all important command. Do note that using CommandName="Select" WILL ALSO trigger the GV index changed event, but this way we just use the simple button event - and thus don't care much.
Edit ------------------------
there is some question about me having used btn.parent.Parent to get the slected grid row. The issue is that I just felt like using the button click event, but we did not have to.
The above will STILL work, but I suggest REMOVE the button click event stub, and place the code here:
   protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow gvR = GridView1.SelectedRow;

        Response.Write("
 File name selected = " + gvR.Cells[2].Text + "
");

    }

Comment: This is exactly what I needed. Thank you for helping me. There is just one thing if you can explain (or guide me to a resource which can help me to understand) what is the code on onClick event means. Especially parent.parent
Comment: I just like to drop in a button, and then have click event with code behind for that button. I just think this is less hassle. When you click any control with events, then "sender = ALWAYS the control you clicked on". The first parent to button I think "grid row cell, and then next parent step up is the grid row - which we want.  Because of CommandName = "select" then grid view SelectedIndexChanged event will fire. You probably would be less confused and better to use the Gridview event SelectedIndexChanged. Code would be identical to button code without having to get/use sender and .parent.
Comment: So try doing this with Gridview selected index changed. I might even edit this post to remove that confusing part.
Comment: see my new edit - I show how to remove the button click code - just put your code as per the final edit here - they both will work the same, but for a more general code approach - use the selected index changed event as my edit shows. (you thus will NOT have ANY event stub code for the button - but the magic CommandName="Select" will still fire the index change event.
Answer: You need to give the fieldname to bind the control, something like this -
<EditItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FileName") %>'></asp:TextBox>
</EditItemTemplate>


Defining factories that know their own class and look up the values

Question: I have a validator class that defines valid events for objects of type Foo and Bar. Each Foo object has attributes alert_events, window_events and user_events, and each Bar object has state_events and user_events.
class EventListConformanceValidator
  VALID_EVENTS = {
    foo: {
      alert_events: {
        onAlertLoad: String,
        onAlertUnload: String,
      },
      window_events: {
        onWindowLoaded: Array,
      },
      user_events: {
        onLoginStatusChanged: String,
      },
    },
    bar: {
      state_events: {
        onAborted: Float,
      },
      user_events: {
        skipClicked: nil
      }
    }
  }
end

I want to dynamically generate factories using FactoryBot which will populate the correct event types for each attribute. For example, for alert_events, only events with type onAlertLoad or onAlertUnload should be created.
Naively, I could write the following:
class Event
  attr_accessor :type
end

FactoryBot.define do
  factory :event do
    type { nil }
  end

  factory :alert_event do
    type { ["onAlertLoad", "onAlertUnload"].sample }
  end

  factory :window_events do
    # and so on ...
  end
end

But obviously that'd be a lot of repetition. Instead I want a single source of truth, and source the definitions from the Hash VALID_EVENTS. Also, there is the problem that user_events can exist both for Foo and Bar, so I cannot use user_events alone, as it'd be ambiguous.
So I tried to dynamically generate factories foo_alert_event, foo_window_event etc.:
EventListConformanceValidator::VALID_EVENTS.each do |klass, attribute_hash|
    attribute_hash.keys.map(&:to_s).uniq.each do |attribute|
      factory_name = (klass.to_s + "_" + attribute.to_s.singularize).to_sym

      factory factory_name, class: Event, parent: :event do
        type { "how do I get the event types to sample?" }
      end

    end
end

But inside the dynamic evaluation of type, I don't know how I could refer to the actual factory class name (foo/bar) or attribute name (alert_events etc.) so I can look up the keys in VALID_EVENTS.
How could I achieve that?
Answer: It sounds like you want something like this (however I don't understand what you are trying to achieve)
VALID_EVENTS = {
  foo: {
    alert_events: {
      onAlertLoad: String,
      onAlertUnload: String,
    },
    window_events: {
      onWindowLoaded: Array,
    },
    user_events: {
      onLoginStatusChanged: String,
    },
  },
  bar: {
    state_events: {
      onAborted: Float,
    },
    user_events: {
      skipClicked: nil,
    },
  },
}.freeze

class Event
  attr_accessor :type
end

FactoryBot.define do
  VALID_EVENTS.each do |klass, attribute_hash|
    attribute_hash.each do |name, events|
      factory_name = "#{klass}_#{name.to_s.singularize}".to_sym
      types = events.keys.map(&:to_s)

      factory factory_name, class: Event do
        type { types }
      end
    end
  end
end

describe "SO" do
  it "works" do
    klass = build(:foo_alert_event)
    expect(klass.type).to eq(["onAlertLoad", "onAlertUnload"])
  end
end

rspec
SO
  works

Finished in 0.94792 seconds (files took 3.25 seconds to load)
1 example, 0 failures

Comment: That doesn't work, as `{ types }` is resolved at runtime and not during the creation of the factory. I can look at `self` within the brackets and see the object being created, but I can't infer its type. It's always just `Event`. (But maybe I need to create new classes for each event.)
Comment: It's true that it is resolve during runtime, but still variables that were accessible when the block was created will be accessible inside the block.
I just verified this. Will update the answer with my code...
Comment: Huh. Then whatever I've been trying didn't work for some other reason. Thanks for the answer – I'll check Monday.


Java runtime error: java.lang.ClassCastException: main.Scrapper$aktie cannot be cast to java.lang.Comparable

Question: I get this error:
java.lang.ClassCastException: main.Scrapper$aktie cannot be cast to java.lang.Comparable

when I'm trying to create a class that I have defined myself. What can I do to fix it? The data is always the right type, so that's not the problem, I have tried to parse them in to variables before putting them in the class but I still get the same error
package main;

import java.util.ArrayList;
import java.util.PriorityQueue;

import javax.swing.JOptionPane;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class Scrapper extends Thread {

    private String address;
    private ArrayList<String> name;
    private ArrayList<String> ranInfo;
    public PriorityQueue<aktie> aktier;
    public boolean runner;

    public Scrapper(String webAddress) {
        address = webAddress;
        runner = true;
    }

    public class aktie {
        public aktie(String aktieNamn, float senaste, float sIP, float eÅP, int totBV, float esK, float dA, int aÄ, String börsNamn) {
            this.namn = aktieNamn;
            this.senaste = senaste;
            this.skillnadIProcent = sIP;
            this.ettÅrProcent = eÅP;
            this.totalBörsvärde = totBV;
            this.enskildKostnad = esK;
            this.direktAvkastning = dA;
            this.antalÄgare = aÄ;
            this.vilkenBörs = börsNamn;
            this.newAktie = true;
        }
        public String namn;
        public float senaste;
        public float skillnadIProcent;
        public float ettÅrProcent;
        public int totalBörsvärde;
        public float enskildKostnad;
        public float direktAvkastning;
        public int antalÄgare;
        public String vilkenBörs;
        public boolean newAktie;

        public boolean equal(aktie input) {
            if  (input.namn.equals(namn) &&
                input.senaste == senaste &&
                input.skillnadIProcent == skillnadIProcent &&
                input.ettÅrProcent == ettÅrProcent &&
                input.totalBörsvärde == totalBörsvärde &&
                input.enskildKostnad == enskildKostnad &&
                input.direktAvkastning == direktAvkastning &&
                input.antalÄgare == antalÄgare &&
                input.vilkenBörs.equals(vilkenBörs)) {
                return true;
            }
            return false;
        }
    }

    public void run() {
        name = new ArrayList<String>();
        ranInfo = new ArrayList<String>();
        aktier = new PriorityQueue<aktie>();
        while(runner) {
            Document namnSidan = null;
            Document sidan = null;
            try {
                namnSidan = Jsoup.connect(address).get();
                sidan = Jsoup.connect(address).get();
            } catch(Throwable t) {
                Start.log(t.toString());
            }
            Elements nmList = namnSidan.select("td");//td, table
            for(int i = 0; i < nmList.size(); i++) {
                String[] temper = nmList.get(i).toString().split("");
                if(temper.length > 1) {
                    String[] tm = temper[1].split(" ");
                    if(!tm[0].equals(" 	") && tm.length > 1) {
                        name.add(tm[0]);
                    }
                }
            }
            Elements values = sidan.select("td");
            for(int i = 1; i < values.size(); i++) {
                String[] splitted = values.get(i).toString().split(" ");
                String[] fixed = splitted[0].split(">");
                if(!fixed[fixed.length-1].equals("</td") && !fixed[fixed.length-1].equals(" </td")) {
                    String rätt = fixed[fixed.length-1].substring(1, fixed[fixed.length-1].length());
                    String[] pars = rätt.split(" ");
                    if(1 < pars.length) {
                        ranInfo.add(pars[0] + pars[1]);
                    } else if(rätt.equals("-")) {
                        ranInfo.add("0.0f");
                    } else {
                        String[] cutt = rätt.split(",");
                        if(cutt.length > 1) {
                            ranInfo.add(cutt[0] + "." + cutt[1]);
                        } else {
                            ranInfo.add(rätt);
                        }
                    }
                }
            }
            int counter = 0;
            for(int i = 0; i < name.size(); i++) {
                aktier.add(new aktie( //<- error happens here
                        name.get(i),
                        Float.parseFloat(ranInfo.get(counter++)),
                        Float.parseFloat(ranInfo.get(counter++)),
                        Float.parseFloat(ranInfo.get(counter++)),
                        Integer.parseInt(ranInfo.get(counter++)),
                        Float.parseFloat(ranInfo.get(counter++)),
                        Float.parseFloat(ranInfo.get(counter++)),
                        Integer.parseInt(ranInfo.get(counter++)),
                        ranInfo.get(counter++)));
            }
            try {
                Thread.sleep(120000);
            } catch(Throwable t) {}
        }
    }
}

Answer: First of all, you should not implement something like "public boolean equal(aktie input)" but override the existing equals(Object obj) method.
Second, you need to implement comparable on aktie, since priorityQueue  expects a Comparable implementation, or, if you do not want to do that, you have to implement a Comparator and give it to your PriorityQueue.
Third, if you plan on working with money values, DO NOT use float or double since they are just APPROXIMATED values!!! Either use int, long or BigDecimal.
Lastly, if you seek help from others, make it a bit more obvious for them by pointing out where the exception is thrown right in your description.
Comment: Thx for the help, can i solve the problem by just checking the values on by one in the code instead of implementing a method for it? why would i not use floats when the input from the webbsite is floats? And yes i will try to make it better next time, its my second question so still tring to learn how to do it properly
Comment: Whatever website you are refering to, im sure you get your data via some  web API, and your data contains values like "1.23" or "253.24" or whatever, these are NOT floats or doubles because of decimal places, and if you assign them to double or float you will loose precision, e.g. a float of 1 is not exactly 1 but more rather 0.9999999999. Obviously this will cause huge problems when working with monetary values.
Comment: Considering implementation of compare method, what exactly do you want to achieve by putting your elements to a PriorityQueue, instead of a regular Queue, which would not require a Comparator or Comparables?
Comment: Well thats preatty weird, didnt know floats where "broken". Im just using proirityqueue instead of queue, my teacher (not a very good one) have learned us to us priorityqueue but havent shown us the queue, used it instead of a list so i could poll the first element when i used it. And im not using a webb api, im doing webscraping on a website that got the info
Comment: But even if the float are as u say, if its 0,000.....1 wrong. Isnt that better then to make 1,48264 to 1?
Comment: float and double are not broken, they are meant for scientific calculatations where approximations are ok, and when you use int instead of float you obviously dont round from 1,34$ to 1$, but represtent it as 134 cents. Then again you dont have to do that, just use BigDecimal which is 100% accurate. And obviously you dont need the priority queue so just use the a standard queue where you dont need to compare your elements.
Comment: And then please accept the answer after you got way more help than your problem acctually required.


Como mesclar linhas?

Question: Como posso mesclar duas ou mais **Linhas x Coluna** da consulta abaixo?
select cast(OS.CreateDate as date) as DtMovimentacao, OS.Id as NrOS, OS.Description Origem, OSI.Description as ItemSaida, OSI.Quantity as QtdSaida,
OSE.Description, OSE.Quantity, OSE.Notes
from Asset_WorkOrders OS
join Asset_WorkOrderOtherCost OSI
on OSI.WorkOrderId = OS.Id
join
(
    select OS.WorkOrderId, OSI.Description,OSI.Quantity,OSI.Notes from Asset_WorkOrders OS
    join Asset_WorkOrderOtherCost OSI
    on OSI.WorkOrderId = OS.Id
    where TypeId = 56
)OSE
on OSE.WorkOrderId = OS.Id
where OS.Id = 147412
and OS.TypeId = 34

Precisava que o resultado ficasse assim.

Isso na query ou através do Report Server.
Comment: Você quer que uma linha tenha N informações de ItemSaida e QtdSaida?
Comment: Exatamente, algo que limpe o campo caso ele seja idêntico os outros deixando apenas um...
Answer: EDIT: Com SQL acho que a única forma é verificar as informações que são diferentes entre as linhas e usar o FOR XML PATH naquela coluna, no exemplo a seguir usei na coluna "Description"
select cast(OS.CreateDate as date) AS DtMovimentacao, OS.Id AS NrOS,
Origem = (SELECT OS2.Description + CHAR(10)
FROM Asset_WorkOrders OS2
WHERE OS.Id = OS2.Id
  and OS.TypeId = OS2.TypeId
FOR XML PATH(''))
OS.Description as Origem,

OSI.Description as ItemSaida, OSI.Quantity as QtdSaida,
OSE.Description, OSE.Quantity, OSE.Notes
from Asset_WorkOrders OS
join Asset_WorkOrderOtherCost OSI
on OSI.WorkOrderId = OS.Id
join
(
    select OS.WorkOrderId, OSI.Description,OSI.Quantity,OSI.Notes from Asset_WorkOrders OS
    join Asset_WorkOrderOtherCost OSI
    on OSI.WorkOrderId = OS.Id
    where TypeId = 56
)OSE
on OSE.WorkOrderId = OS.Id
where OS.Id = 147412
and OS.TypeId = 34

Como você não incluiu informações das tabelas, pode ter algum inconsistência no resultado da coluna Origem, neste caso tem incluir na subquery alguns JOINs ou validações no WHERE.
Comment: Mas assim ainda iria trazer a informação nas duas linhas só que agora agrupada em uma coluna só
Comment: Também não é isso né ? você quer que o resultado da query Mescle colunas na planilha do Excel ?
Comment: Não na planilha do `Excel`, mas da forma que o `Excel` faz, isso na `query` ou no report server.
Comment: Com o XML PATH você incluir uma quebra de linha CHR(10) após cada palavra, mesmo assim a linha seria uma só, mas na coluna que usar esta função os dados estariam um em baixo do outro, acho que a melhor solução pode estar no Report Server, não sei usa-lo.

Como mesclar linhas?


How to combine two Active Directory domains

Question: I have two Windows 2008 R2 AD servers.
The first, xyz.com is in a large city with fast internet.  There are approximately 12 users.
The second, foo.xyz.com, is in the middle of the bush on a satellite link, there are approximately 20 users.
The two servers are not connected to each other in any way.
I have a third office in a small town with slow internet access.  I will soon be adding a server in that office, which has 7 users.
My goal is to combine all of them somehow and setup Dfs.
I'm inexperienced in AD management and looking for guidance.  I would like to start with connecting my two current servers.
Thanks
Comment: you will still get answers from members here if this question gets closed, but I am making a recommendation to close it.  Simply because: "This question is ambiguous, vague, incomplete, **overly broad**, or rhetorical and cannot be reasonably answered in its current form."  Your question is really about 20 questions and a large project vs. a support question that can be answered here on SF.  It would be better to engage SF on specific questions you have during the project.
Comment: Yes, I see how broad it is now.  Although, it was helpful to me.
Answer: You use ADMT (Active Directory Migration Tool) for restructuring and merging domains, however, with your lack of familiarity with AD (sorry I don't mean to sound condescending,) and given how long it would take you to learn ADMT, and how few users you have, the quickest thing for you to do would probably be just migrate all the workstations into a new domain manually.
Edit to elaborate some more - I would suggest USMT (User State Migration Tool) for migrating user profiles over to the new domain, but as with ADMT, its usefulness really shines in large migration projects. For a small number of users, you could probably just use Windows Easy Transfer to transfer user profiles... even if migrating user profiles isn't even essential to you, it will probably make your end users happier and would be an easy win for you.
Answer: What are you trying to solve with DFS? And how would you like to "combine" them?
I'm making an assumption that these domains are in separate forests since they are not currently connected in any way. If you want to do DFS replication, you will not be able to do so across forests.
If you want a single namespace for DFS and have users access files in the other domains, you can do so without DFS and setup trusts. You will probably want to setup a site-to-site VPN in order to maintain that trust remains in place.
You could look at migrating the multiple domains into a single domain (either a new one or into an existing one). You might still have other issues with the sites depending on the stability of the internet links and you would still need to setup either a private network separately or over VPN tunnels.
Bottom line, if you don't know enough about AD at this point, you may want to find a good consultant to work with you on all the pros/cons of all the various options and find a solution that works best for you (and do some knowledge transfer along the way).


Possibility problems.

Question: The questions ask: what are the possibility of picking a positive real number less than or equal to 3 from all the numbers less than  10, AND the possibility of picking a positive real number JUST LESS THAN 3 from all the numbers less than 10.
The part of the problem that troubles me is how to evenly divide up a range of numbers.
Comment: I just edited my question
Answer: The probability of picking exactly 3 is zero. And
$$P(0< x\le 3) = P(0<x<3) + P(x=3) = P(0<x<3)+0$$
So they will have the same answer. Now what is the probability of picking a number in the interval $(0,3)$ given they you;re selecting from $(0,10]$?
Comment: 3/10 Right? Easy if it is equal to 10
Comment: Yes thats correct
Comment: But the problem is different
Comment: Do you mean $P(0<x\le 3 \ \text{and} \ 0<x< 3)$?
Comment: Or do you mean pick one number followed by picking another number?
Comment: Sorry it is less than 10
Answer: Assuming the uniform distribution $u$ on $(0,10]$, it is respectively
  $$u((0,3]) = \int_{(0,3]} u(dx) = \int_{(0,3]} \frac{dx}{10} = \frac{3}{10} $$
and
  $$u((0,3)) = \int_{(0,3)} u(dx) = \int_{(0,3)} \frac{dx}{10} = \frac{3}{10}\;. $$
This is the same probability, as the difference is just the probability to pick exactly 3, which is an event of probability 0.
Comment: The uniform distribution on $(0,10]$ puts 0 probability on any singleton, finite set, or even countable sets. (You have uncountably many elements in $(0,10]$, each of them having "the same probability of appearing": each fixed element has probability 0, but the probability of an interval $(a,b)$ or $[a,b]$ is $b-a$)
Comment: Why does the probability of 3 equal 0?
Comment: Technically it is close to zero right?
Comment: No, exactly zero.

Possibility problems.


How to find same values in dictionary and assign a new item with averaging of duplicate values?

Question: I have a text file with movie details,structure like this;

ID
Rating
Title
Genre

0
4.5
Amelie (Fabuleux destin d'Amélie Poulain, Le) (2001)
Comedy|Romance|Thriller

1
3.0
Die Hard (1988)
Action|Crime|Thriller

2
4.0
Star Wars: Episode VI - Return of the Jedi (1983)
Action|Adventure|Sci-Fi

3
3.5
Fugitive, The (1993)
Thriller

4
4.5
Fugitive, The (1993)
Thriller

5
2.5
Amelie (Fabuleux destin d'Amélie Poulain, Le) (2001)
Comedy|Romance|Thriller

I want to find the same movies and save them as a new item by taking the average rating of the movies I found.
For example;
Fugitive is duplicated on the list. Average rating: 4.0
<code>{'580': ['4.0', 'Jurassic Park (1993)', ['Action', 'Adventure', 'Sci-Fi', 'Thriller']],
 '264': ['4.0', 'Mask, The (1994)', ['Action', 'Comedy', 'Crime', 'Fantasy', 'Thriller']],
 '370': ['4.5', "Amelie) (2001)", ['Comedy', 'Romance', 'Thriller']],
 '312': ['3.0', 'Die Hard (1988)', ['Action', 'Crime', 'Thriller']],
 '166': ['3.5', 'Fugitive, The (1993)', ['Thriller']],
 '195': ['4.5', 'Fugitive, The (1993)', ['Thriller']]}
</code>
I have saved each line in the file as an item in the dictionary. How can I find and average the same items? Thanks.
Comment: https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples
Answer: Read the file with pandas, then group by 'Title' and compute the mean of the column 'Rating'


Bootstrap Tooltip not appearing

Question: I've passed all the Stack Overflow, tried literally anything.
The tooltip doesn't working.
Can you please help me !!!
<!DOCTYPE html>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

        <button class="btn btn-default" rel="tooltip" title="hello" data-placement="bottom">Hello World</button>

Comment: Include bootstrap.js file after jquery.js
Answer: Based on dfsq's comment - Add the jQuery js file before the bootstrap js file.

The Bootstrap JS file is based on jQuery.
Therefore in order to make sure everything works - this is the order to add the script tag calls in the  tag.

Bootstrap Tooltip not appearing


correct way of using a throw try catch error handling

Question: I have come accross to this function below and I am wondering wether this is the right way of using the error handling of try/catch.
public function execute()
{
    $lbReturn = false;
    $lsQuery = $this->msLastQuery;
    try
    {
        $lrResource = mysql_query($lsQuery);

        if(!$lrResource)
        {
            throw new MysqlException("Unable to execute query: ".$lsQuery);
        }
        else
        {
            $this->mrQueryResource = $lrResource;
            $lbReturn = true;
        }

    }
    catch(MysqlException $errorMsg)
    {
        ErrorHandler::handleException($errorMsg);
    }
    return $lbReturn;
}

Comment: Looking at the code, I would say that the author of this function only threw the exception so that he could log it using an already existing logging functionality.
Answer: No. Throwing an exception in this case is simply a GOTO, but with a (slightly) prettier face.
Answer: Codewise it is correct/works, However the power of try-catch is that when an Exception is thrown from deep down in one of the functions you're calling.
Because of the "stop execution mid-function and jump all the way back to the catch block".
In this case there are no deep-down exceptions therefore I would write it like this:
(Assuming there is a function "handleErrorMessage" in the ErrorHandler.)
public function execute() {
    $lsQuery = $this->msLastQuery;
    $lrResource = mysql_query($lsQuery);

    if(!$lrResource) {
         ErrorHandler::handleErrorMessage("Unable to execute query: ".$lsQuery);
         return false;
    }
    $this->mrQueryResource = $lrResource;
    return true;
}

Which I find more readable.
Comment: Thanks for your commment.

What would be if I would replace  ErrorHandler::handleErrorMessage($errorMsg); with the throw statement?
Would that be incorrect?
Comment: That would cause the function execute() to be aborted and jump to a catch block(if any) outside of the execute function. Which dramatically changes the behaviour of the function. If this new behaviour is "incorrect" is up to you.
Answer: Why have a call to ErrorHandler::handleException here anyway?
Just throw the exception, but never catch it. Then in the global initialization code for your app have a function with the following signature:
function catchAllExceptions(Exception $e)

Then call:
set_exception_handler('catchAllExceptions');

This will cause all uncaught excpetions to be passed as an argument to catchAllExceptions(). Handling all uncaught exceptions in one place like this is good, as you reduce code replication.
Answer: Well it is not really a good implementation since you throw the exception and you look for that exception in catch. So the answer of Visage is true.

You should use a global error handler instead of a tr-catch usage like in your code.
If you are not sure of the type of the error and occurance but want to continue the execution of the code although an exception had occured, then a try-catch block will help.


Extending linear functional in non-unique way

Question: I'm trying to find an example of when the extension of a functional in the Hahn-Banach theorem is not necessarily unique. I'm looking at the space of continuous functions on $[0,1]$ and I'm trying to find a subspace and a functional defined on the subspace that has two different norm preserving extensions.
So far I've thought about the subspace of polynomials, but then the only linear functionals I can think of are things like $f(p) = p(0)$ or $f(p) = \|p(x)\|_{\infty}$ but I can't think of any non-unique way to extend these.
Comment: Polynomials are dense in the continuous functions so there are unique extensions of this bounded linear functional (the second one you give is not linear) to the continuous functions (you can work this out explicitly or see it as a special case of a proposition from topology which tells us that continuous functions into a Hausdorff space, here $\mathbf R$ or $\mathbf C$, are determined by their values on a dense subspace of the domain). Maybe try out on a 1-dimensional subspace instead.
Comment: I meant to say there is a unique extension.
Comment: Maybe the result mentioned [here](http://math.stackexchange.com/questions/50154/reference-for-the-range-of-possible-values-in-hahn-banach-theorem) can, in some situations, help to find out whether there is only one extension.
Comment: To give a specific example, any sequence which is not [almost convergent](http://en.wikipedia.org/wiki/Almost_convergent_sequence) can be assigned different values for different [Banach limits](http://en.wikipedia.org/wiki/Banach_limit). Banach limits are simply extensions of $\lim$ to the space $\ell_\infty$ which are shift-invariant. See also [here](http://math.stackexchange.com/questions/80564/show-that-liminf-n-to-inftyx-n-le-alphax-le-limsup-n-to-inftyx-n-f).
Comment: It seems that the example I have suggested in the above comment is unnecessarily complicated.
Answer: What about the subspace
$$S=\{f\in C(0,1); f(0)=f(1)\}$$
and the functional $T\colon f \mapsto f(0)$ defined on $S$.
The you have two extensions $T_0\colon f\mapsto f(0)$ and $T_1\colon f\mapsto f(1)$.
For these functionals we have $\|T\|=\|T_1\|=\|T_2\|=1$.
In fact, for every $a\in[0,1]$ we have an extension $T_a\colon f\mapsto af(0)+(1-a)f(1)$ with $\|T_a\|=1$.
Answer: The following is true:

If $X$ is a Banach space, then each Hahn-Banach (norm preserving) extension is unique iff the unit ball of $X^{\ast}$ is strictly convex.

In particular, this would be true for a Hilbert space. Furthermore, there is an interesting theorem of Phelps (See this) which relates this property for a fixed subspace to a best approximation property of the annihilator of that subspace in $X^{\ast}$.
Comment: An interesting result. Here are some posts from this site where this was mentioned: http://math.stackexchange.com/questions/769619/when-is-the-closed-unit-ball-b-in-the-dual-space-strictly-convex, http://math.stackexchange.com/questions/827816/uniqueness-of-hahn-banach-extension-for-convex-dual-spaces, http://math.stackexchange.com/questions/332350/hilbert-spaces-and-unique-extensions-of-linear-functions


Complement of half spaces covering boundary of a convex body is a polytope

Question: I have the following problem about compact convex sets.
Let $K\subset\mathbb{R}^n$ be a compact convex set with nonempty interior. Assume that $A_1,\dots,A_m$ are open half spaces that cover $\partial K$ and set $P:=\mathbb{R}^n\setminus \bigcup_{i=1}^m A_i$. Show that $P$ is a subset of $K$ and hence $P$ is a polytope.
I was trying to show that if $x\notin K$ then there exists some $A_i$ so that $x\in A_i$. Even though this fact is intuitively true, but I am not sure how to make it rigorous. I guess we need something like $\partial K$ ''enclosing'' $K$ and the condition that $K$ has interior point somewhere.
Can someone help me? Thanks for any hint!
Comment: I have several issues with the problem presentation. When you say that $A_1,\ldots,A_m$ cover $\partial K$, do you mean $\partial K\subseteq\bigcup_{i=1}^mA_i$, or do you mean $\forall i,\ \partial K\subseteq A_i$?
Also in the case $m=1$, with $K\subseteq A_1$, I believe that $P\cap K=\emptyset$.
Answer: I think this assertion is wrong. Consider any compact convex set $K$ and then take one halfspace $A_1$ which contains all of $K$ and all of $\partial K$ (which exists since $K$ is compact). Now $P$ is a closed halfspace and non-empty and $K \cap P = \emptyset$, so $P$ is not a subset of $K$.


Reseting device list on Apple Developer account

Question:
I want to add a new device UDDID to the developer device list. It is showing the reset option.

What will happen if I click the reset button?
Will I lose all the devices connected to the list?
Will this affect any apps or certificate or profile currently working?
Do I have to add all the devices back manually?
I am sharing IPA through diawi.com website, currently, the device
connected to this account is working fine when I share an IPA. Will the reset affect this?
How many deices can be removed at a time.
Answer: No by resetting you can reselect the needed device.
it will show all available device and you can select which all device is needed.
no issue for the certificates or provision profiles.


How to validate numbers in a webform custom composite element

Question: I have a Webform with a custom composite, and there I have a element which type is Number and i want to validate this element.
If I check required when the field is empty it show a message that the field is required, but if I put letters in the field show the same message when it should be that the field is not valid because it has letters.
I know how to do this with a textfield element but this element is not inside the custom composite with a regular expression . And even if i change the custom composite element from Number to Textfield I can not do it this, can not be validated individually.
Answer: You can add regular expressions for elements in a custom composite by going to the General tab of the custom composite, then adding your regular expression in the custom properties field for an element within the Custom composite settings section.
This link may be of use:
https://www.drupal.org/project/webform/issues/3162515
Answer: Instead of putting validations just create a number type field. And inside the number field of the custom composite element, you can not enter the letters, only numbers can be entered so no concept/need for validating against letters.


Hiding table ID's in a website

Question: I'm building a php website with lots of jquery / ajax.  Basically the site is a simple blog and I display the last 10 database entries and their corresponding headlines on the front page.  The user is then able to click a headline (where it's rerouted to site.com/blog?cid=76) and then view the full blog entry.
basically, is there any database security risk with displaying the 76 which corresponds to the blog_id in the database?  Should I be making things more secure and if so how would I go about doing that?
Comment: Short answer: No. I'm sure someone less asleep than me will be kind enough to provide a long answer.
Comment: I'm not sure I understand.  Why would this be a security issue if your users could access this site anyway?
Comment: I don't see any security issue, though it'd be nice from a UX/SEO POV if the URL was the article title rather than a number
Comment: sorry, I should clarify: is there any database security risk by doing this?
Answer: There is no security issue.
It is similar to telling us what id this post has:
stackoverflow.com/questions/11379226/hiding-table-ids-in-a-website
All it does is tell the user which post it is.
Answer: The way you implemented it forces you to pass the id of the blog entry anyway: be it in POST or in a GET request. If the application is secure enough there shouldn't be a problem with passing the id. The only thing you could do would be to make the id a little bit more obscurely passed in the GET request:
Something like: site.com/blogs/disp/76 for instance
Comment: +1 for suggesting friendlier URLs. The OP should look into mod-rewrite, or CMSs (almost all of which automate this sort of URL window dressing).
Comment: if I may ask, what does CMS stand for?
Answer: Yes there are risks. You need to know about und understand SQL injection. PHP offers a couple of methods that you can use to help prevent this type of attack.
This site offers a good explanation of SQL injection and methods to help prevent it:
http://rosstanner.co.uk/2012/01/php-mysql-preventing-mysql-injection/
Comment: SQL injection is a risk associated with bad code that allows direct, unbound injunction of post/GET vars into SQL, not a risk associated with IDs being referenced in URLs
Comment: OP stated in a comment that he meant risks with database. He means referencing ID in a database table.

Hiding table ID's in a website


Shared preprocessing macro definition among multiple sub-projects, i.e. shared libraries

Question: I have a project with multiple sub-projects. One sub-project for executable and the rest for shared libraries. Each sub-project has its own *.pro file.
I need to define a compiler preprocessing macro, but I don't want to repeat defining it in each *.pro file. Is it possible to share a macro definition among multiple sub-projects?

My sample preprocessing macro:
#define PI 3.1415926

Adding to *.pro files:
DEFINES += "PI=\"3.1415926\""

Comment: Did you consider to use a `*.pri` file and include it in your `.pro` files?
Comment: Possible duplicate of [Qt: \*.pro vs \*.pri](https://stackoverflow.com/questions/8358627/qt-pro-vs-pri)
Answer: You can define your macro in a .pri file (config.pri, for example) and include this .pri file in each .pro files for your sub-projects.
config.pri
DEFINES += "PI=\"3.1415926\""

sub_project.pro
include (/path/to/config.pri)

This forces you to modify each sub-projects .pro files though.
Comment: Well, [looks like](https://stackoverflow.com/q/8358627/3405291) there is not much technical difference between `*.pro` and `*.pri`
Comment: Yes indeed. I was not aware of this .pri naming convention (https://wiki.qt.io/Including_.pro_Files). I'm editing the answer.
Comment: As @vahancho suggested in a comment, the `*.pri` files are usually used for this purpose, right?
Comment: still it is a convention to use .pri instead of pro for `include` directives


Função de agrupamento calculando erradamente

Question: Estou tentando escrever uma função em python que toma dois vetores, elimina duplicatas no primeiro e soma os dados correspondentes no segundo.
Meio que tentando emular a seguinte consulta MySQL:
SELECT `Price`, sum(`Volume`) FROM `Dataset` GROUP BY `Price`

Meu código está assim:
def Group(X, Y):
  temp = dict.fromkeys(X, [0, 0])
  L = range(len(X))

  for i in L:
    print('BEFORE: i=%s, temp=%s, temp[X[i]]=%s, X=%s, X[i]=%s, Y=%s, Y[i]=%s' %(i, temp, temp[X[i]], X, X[i], Y, Y[i]))

    temp[X[i]][0] += Y[i]
    temp[X[i]][1] += 1

    print('AFTER: i=%s, temp=%s, temp[X[i]]=%s, X=%s, X[i]=%s, Y=%s, Y[i]=%s' %(i, temp, temp[X[i]], X, X[i], Y, Y[i]))

  return temp

Ao chamar a função, ela deveria responder assim:
>>> a = [1, 1, 2]
>>> b = [3, 4, 5]
>>> Group(a, b)
BEFORE: i=0, temp={1: [0, 0], 2: [0, 0]}, temp[X[i]]=[0, 0], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=3
AFTER: i=0, temp={1: [3, 1], 2: [0, 0]}, temp[X[i]]=[3, 1], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=3
BEFORE: i=1, temp={1: [3, 1], 2: [0, 0]}, temp[X[i]]=[3, 1], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=4
AFTER: i=1, temp={1: [7, 2], 2: [0, 0]}, temp[X[i]]=[7, 2], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=4
BEFORE: i=2, temp={1: [7, 2], 2: [5, 1]}, temp[X[i]]=[5, 1], X=[1, 1, 2], X[i]=2, Y=[3, 4, 5], Y[i]=5
AFTER: i=2, temp={1: [7, 2], 2: [5, 1]}, temp[X[i]]=[5, 1], X=[1, 1, 2], X[i]=2, Y=[3, 4, 5], Y[i]=5
{1: [7, 2], 2: [5, 1]}

Mas está respondendo assim:
>>> a = [1, 1, 2]
>>> b = [3, 4, 5]
>>> Group(a, b)
BEFORE: i=0, temp={1: [0, 0], 2: [0, 0]}, temp[X[i]]=[0, 0], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=3
AFTER: i=0, temp={1: [3, 1], 2: [3, 1]}, temp[X[i]]=[3, 1], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=3
BEFORE: i=1, temp={1: [3, 1], 2: [3, 1]}, temp[X[i]]=[3, 1], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=4
AFTER: i=1, temp={1: [7, 2], 2: [7, 2]}, temp[X[i]]=[7, 2], X=[1, 1, 2], X[i]=1, Y=[3, 4, 5], Y[i]=4
BEFORE: i=2, temp={1: [7, 2], 2: [7, 2]}, temp[X[i]]=[7, 2], X=[1, 1, 2], X[i]=2, Y=[3, 4, 5], Y[i]=5
AFTER: i=2, temp={1: [12, 3], 2: [12, 3]}, temp[X[i]]=[12, 3], X=[1, 1, 2], X[i]=2, Y=[3, 4, 5], Y[i]=5
{1: [12, 3], 2: [12, 3]}

Já na 1ª execução do laço a função erra, pois quero que ela acrescente o valor em Y[0] somente em temp[1][0], e não em temp[2][0] também.
Alguém consegue enxergar o que estou fazendo de errado?
Desde já agradeço!

[RESOLVIDO]
Quero sinceramente agradecer mais uma vez pelas dicas e respostas valiosas! A solução que escolhi/encontrei foi:
def Group(X, Y, isSum):
    temp = dict.fromkeys(X, (0, 0))
    for i in range(len(X)):
        temp[X[i]] = (temp[X[i]][0] + Y[i], temp[X[i]][1] + 1)
    if not isSum:
        for i in temp:
            temp[i] = temp[i][0] / temp[i][1]
    return temp

E a resposta da máquina foi:
>>> a = [1, 1, 2, 3, 4]
>>> b = [5, 6, 7, 7, 8]
>>>
>>> Group(a, b, True)
{1: (11, 2), 2: (7, 1), 3: (7, 1), 4: (8, 1)}
>>> Group(b, a, False)
{8: 4.0, 5: 1.0, 6: 1.0, 7: 2.5}
>>>

Na verdade queria duas funções em uma, para emular estas duas queries:
SELECT `Price`, SUM(`Volume`) FROM `Dataset` GROUP BY `Price` ;
SELECT `Volume`, AVG(`Price`) FROM `Dataset` GROUP BY `Volume` ;

Peço desculpas ter apresentado apenas metade do problema.
Abraço a todos!

[RESOLVIDO 2]
Ai vai um complemento, com dados reais do problema:
Dataset = [
    # Tempo, Volume e Preço do par BTCUSD em [https://www.bitfinex.com/]
    (1426502898, 0.01, 292.76),
    (1426503160, 0.01, 292.77),
    (1426503169, 0.0224, 292.77),
    (1426503180, 0.304111, 292.77),
    (1426503188, 0.026, 292.77),
    (1426503194, 0.388, 292.77),
    (1426503287, 0.01, 292.76),
    (1426503287.14286, 0.202, 292.7),
    (1426503287.28571, 0.7082, 292.77),
    (1426503287.42857, 1.12, 292.75),
    (1426503287.57143, 2.57392822, 292.76),
    (1426503287.71429, 3.095, 292.77),
    (1426503287.85714, 7, 292.77),
    (1426503292, 0.22, 292.7),
    (1426503320, 0.5, 292.78),
    (1426503340, 0.5, 292.78),
    (1426503358, 0.5, 292.78),
    (1426503377, 0.01, 292.76),
    (1426503377.5, 0.49, 292.78),
    (1426503378, 0.01, 292.75),
    (1426503384, 0.01, 292.76),
    (1426503385, 0.1, 292.78),
    (1426503394, 0.01, 292.76),
    (1426503395, 0.5, 292.78),
    (1426503399, 0.01, 292.76),
    (1426503402, 0.01, 292.76),
    (1426503407, 0.01, 292.76),
    (1426503414, 0.181549, 292.78),
    (1426503414.5, 0.318451, 292.78),
    (1426503415, 0.01, 292.76)
]

partition = lambda data, pos: [i[pos] for i in data]

def Group(X, Y, isSum):
    temp = dict.fromkeys(X, (0, 0))
    for i in range(len(X)):
        temp[X[i]] = (temp[X[i]][0] + Y[i], temp[X[i]][1] + 1)
    if not isSum:
        for i in temp:
            temp[i] = temp[i][0] / temp[i][1]
    return temp

E a resposta da máquina foi:
>>>
>>> Group(partition(Dataset, 2), partition(Dataset, 1), True)
{292.77: (11.553711, 8), 292.78: (3.09, 8), 292.76: (2.6639282199999985, 10), 292.75: (1.1300000000000001, 2), 292.7: (0.42200000000000004, 2)}
>>> Group(partition(Dataset, 1), partition(Dataset, 2), False)
{0.304111: 292.77, 1.12: 292.75, 2.57392822: 292.76, 3.095: 292.77, 0.181549: 292.78, 0.5: 292.78, 7: 292.77, 0.026: 292.77, 0.202: 292.7, 0.01: 292.76000000000005, 0.1: 292.78, 0.388: 292.77, 0.318451: 292.78, 0.49: 292.78, 0.0224: 292.77, 0.22: 292.7, 0.7082: 292.77}
>>>

Answer: O problema com seu código é que você está usando um objeto mutável como valor padrão do seu dicionário. Quando você faz:
temp = dict.fromkeys(X, [0, 0])

Você espera que ele crie uma lista [0, 0] diferente para cada chave em X, certo? Mas não é isso que ocorre, ele está usando a mesma lista para todos os elementos! Aí, naturalmente, ao modificar uma delas se modifica as outras também...
Um meio de solucionar é usando uma tupla, que é imutável:
temp = dict.fromkeys(X, (0, 0))

...

temp[X[i]] = (temp[X[i]][0] + Y[i], temp[X[i]][1] + 1)

De todo modo por que em vez disso não usar o método groupby do Python?
>>> from itertools import groupby
>>>
>>> a = [1, 1, 2]
>>> b = [3, 4, 5]
>>>
>>> temp = {}
>>> for g,e in groupby(sorted(zip(a,b)), lambda x: x[0]):
...   e = list(e)
...   temp[g] = [sum(x[1] for x in e), len(e)]
...
>>> temp
{1: [7, 2], 2: [5, 1]}

Explicando:

O zip(a,b) relaciona cada elemento de a com seu elemento correspondente de b, i.e. [(1,3), (1,4), (2,5)];

O sorted é necessário, pois o groupby só funciona corretamente se a lista estiver ordenada segundo a chave de agrupamento. A ordenação padrão é suficiente, pois ele compara primeiro pelo primeiro elemento (a chave) e em seguida pelo segundo.

O groupby agrupa essa lista pelo primeiro elemento; g então é o elemento da lista a, e e é um iterador sobre os pares agrupados;
Para cada agrupamento, eu calculo a soma dos itens da lista b nesse agrupamento e o número desses itens, associando-os ao seu elemento g.


Module Broken Link – installation fails

Question: The ›Broken Link‹ module yields an ›unexpected error‹ during installation. Afterwards everything seems to be fine and the module is listed as installed, but a node Administration->Configuration->System->Broken Link is missing.
What am I missing?
The error seems to be:
<code>Type    php
Date    Thursday, February 17, 2022 - 10:39
User    me
Location    https://mydomain.at/admin/modules
Referrer    https://mydomain.at/admin/modules
Message     Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "user.private_tempstore". in Drupal\Component\DependencyInjection\Container->get() (line 156 of /var/www/drupal-9.3.6/core/lib/Drupal/Component/DependencyInjection/Container.php).
Severity    Error
Hostname    myhost
Operations
</code>
Comment: I'm voting to close this question because it's a bug report for a contributed module and needs to be handled in the issue queue on Drupal.org.
Answer: When you have a problem with a module, the first place to look is the module's issue queue.
Sometimes there are a lot of issues to search through, but in this case, the error is described in the first issue.
You can download the patch in the issue and apply it to fix the problem.
Comment: Thanks! (And especially for the ›issue‹-hint! Can't yet upvote.)

Module Broken Link – installation fails


Arranging $100$ balls.

Question:
There are $100$ balls numbered $n_{1}, n_{2}, n_{3}\cdots \cdots n_{100}$ .
   They are arranged in all possible ways . How many arrangements
  would be there in which $n_{28}$ ball will always be before $n_{29}$ ball
  and the two of them will be adjacent to each other ?

$a.)\ \dfrac{99!}{2!} \\
b.)\ 99!2! \\
\color{green}{c.)\ 99! }\\
d.)\ \text{none of these } \\$
I arranged $\{\cdots \cdots n_{28},n_{29}\}$
Total ways $(100-2)!=98!$.
But
Answer given in book is $99!$.
I look for a short and simple way.
I have studied maths up to $12$th grade.
Comment: You can glue these two balls together, and then you're just arranging 99 objects in order.
Answer: Let suppose that $n_{28}$ is first and $n_{29}$ is second.  Then there are $98!$ ways to arrange the other balls.  Now, $n_{28}$ can be placed in any of the positions from $1$ to $99$.  So the total number of possibilites is $99\cdot 98!=99!$.
Answer: HINT:
Let's rephrase the question:

There are $27$ balls numbered $n_{1},n_{2},n_{3},\dots,n_{27}$
There are $71$ balls numbered $n_{30},n_{31},n_{32},\dots,n_{100}$
There is $1$ ball numbered $n_{2829}$

Altogether, there are $27+71+1$ balls. How many arrangements are there?
Answer: We can imagine $n_{28}-n_{29}$ glued together as one object. Then it is like we have 99 balls and the total permutations are $99!$

Arranging $100$ balls.


Custom UIToolbar too close to the home indicator on iPhone X

Question: I have a custom UIToolbar that I'm showing when the tab bar is hidden. The toolbar buttons are too close to the home indicator on iPhone X:
let toolbar = UIToolbar()
let height = tabBarController?.tabBar.frame.height
toolbar.frame = CGRect(x: 0, y: view.bounds.height - height, width: view.bounds.width, height: height)
toolbar.autoresizingMask = [.flexibleWidth, .flexibleTopMargin]
view.addSubview(toolbar)

Buttons are too close to the home indicator

This is what I want it to look like (Mail app) ^
Since this is a custom view, I know that I can change the y position and move it to start at the bottom of safe area but I'd rather move the buttons. I'm using plain UIBarButtonItem with flexible space in between.
Comment: Answered  [here](https://stackoverflow.com/a/46684504/7576100)
Comment: How did you resolve this issue? can you help ?
Comment: @Shah Instead of using `UIToolbar`, I ended up creating my own `UIView` with a horizontal stack view.
Comment: Got it. Thanks a bunch
Answer: In iOS 11, Apple is deprecating the top and bottom layout guides and being replaced with a single safe area layout guide.
So use Safe Area Layout Guides to move the view above from the home indicator.
Using Storyboard :

Go to Storyboard and in the Interface Builder Document section
Tick the Use Safe Area Layout Guides check box
Then change the Bottom Constraint to be relative to the Safe Area

Now the views are aligned above the Home Indicator.
OR By way of Coding,
   toolbar.translatesAutoresizingMaskIntoConstraints = false

   NSLayoutConstraint.activate([
        toolbar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
        toolbar.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
        toolbar.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
        toolbar.heightAnchor.constraint(equalToConstant: 50)
        ])

See this article for Positioning Content Relative to the Safe Area
Comment: The user wants to extend the height of the toolbar while aligning content at the top of the bar. This answer offsets the entire bar up away from the safe area. While this is helpful for other scenarios, this is explicitly the outcome the user did not want.
Comment: I am hiding the tab bar and showing the toolbar when the user clicks a button. Just like what the Photos app does when you click on "Select". If I constrain the toolbar to the safe area, its bottom will be aligned with the top of the hidden tab bar (which means that there will be a gap of the size of the tab bar, between the toolbar and the bottom of the view).
Answer: You shouldn't need to set an explicit height or size to get this to work, simply take advantage of the layoutMarginsGuide and the UIBarPositioningDelegate protocol, which is adopted by UIToolbarDelegate.
First, layout your toolbar so that it's pinned to the bottom of the view's layoutMarginsGuide.
let constraints = [
    toolbar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
    toolbar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
    toolbar.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor)
]
NSLayoutConstraint.activate(constraints)

This will get the toolbar aligned to the safe area on iOS 11+ devices, but you'll need to do one last thing to get the toolbar to extend its background all the way to the bottom of the view. To get that simply conform to UIToolbarDelegate in your class, set yourself as the toolbar's delegate, implement the function position(for: UIBarPositioning) -> UIBarPosition, and return the value .bottom.
The default value for UIToolbar's barPosition is bottom, so this last step may not be necessary in most use cases.
After doing this, you should see your toolbar lay out its items relative to the safe area while extending the background all the way to the bottom of the view, just like you see in Mail and Safari.
The beauty of using layoutMarginsGuide over safeAreaLayoutGuide in this case is that the layoutMarginsGuide insets the layout margins by the safe area by default. Because you don't directly refer to the safe area, your code is backwards compatible all the way to iOS 9 without having to use availability checks.
Answer: I ran into this problem also.  My solution was to use a generic UIView to account for the bottom safeAreaInset and then add the toolbar as a subview of that view.
private func addToolbar(_ toolbar: UIToolbar, toView view: UIView) {
    toolbar.frame = CGRect(
        x: 0,
        y: 0,
        width: view.frame.size.width,
        height: 0
    )
    toolbar.sizeToFit() // This sets the standard height for the toolbar.

    // Create a view to contain the toolbar:
    let toolbarParent = UIView()
    toolbarParent.frame = CGRect(
        x: 0,
        y: view.frame.size.height - toolbar.frame.size.height,
        width: toolbar.frame.size.width,
        height: toolbar.frame.size.height
    )

    // Adjust the position and height of the toolbar's parent view to account for safe area:
    if #available(iOS 11, *) {
        toolbarParent.frame.origin.y -= view.safeAreaInsets.bottom
        toolbarParent.frame.size.height += view.safeAreaInsets.bottom
    }

    toolbarParent.addSubview(toolbar)
    view.addSubview(toolbarParent)
}

Answer: Apple's apps like Mail, Reminders, Calendar, they use UIViewController.setToolbarItems(_:animated:)
let navigationController: UINavigationController = .init(rootViewController: ViewController())
navigationController.setToolbarHidden(false, animated: false)

@MainActor final class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        setToolbarItems([.init(image: .init(systemName: "camera.aperture"), style: .plain, target: self, action: #selector(foo(_:)))], animated: false)
    }
}


Injeção de Dependência no .NET Core

Question: Estou migrando um projeto WebAPI com .NET Framework 4.6 para .NET Core.
Nesse meu projeto eu uso o Unity para fazer Injeção de Dependência:
var container = new UnityContainer();
DependencyResolver = new UnityDependencyResolver(container);
container.RegisterType<IUserService, UserService>();

No .NET Core não consegui utilizar o Unity da mesma forma que eu fazia no .NET 4.6 e achei uma solução para utilizar dessa forma, colocando no meu Startup.cs
// DI Containers Registration
services.AddTransient<IUserService, UserService>();

Qual seria a melhor prática hoje em .NET Core para Injeção de Dependência, vale a pena usar algum componente como StructureMap, CastleWindsor.
Answer: Após pesquisas encontrei um material interessante, segue exemplos:
Podemos injetar dependência no .NET Core da seguinte forma:
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();

    services.AddSingleton<IRenderSingleton, RenderSingleton>();

    services.AddScoped<IRenderScoped, RenderScoped>();

    services.AddTransient<IRenderTransient, RenderTransient>();
}

Nesse exemplo de código têm 3 tipos de ciclo de vida que podem ser utilizado:

Singleton (que me garante um única referencia dessa classe no ciclo de vida de uma aplicação),
Transient (sempre gerará uma nova instância para cada item encontrado que possua tal dependência, ou seja, se houver 5 dependências serão 5 instâncias diferentes) e
Scoped(essa diferente da Transient que garante que em uma requisição seja criada um instância de um classe onde se houver outras dependências, seja utilizada essa única instância pra todas, renovando somente nas requisições subsequentes, mas, mantendo essa obrigatoriedade).

Injeção de Dependência no .NET Core