Saturday, September 4, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


How to get title in Vue.js

Posted: 04 Sep 2021 08:47 AM PDT

I sit all day and don't understand why it doesn't work. I have X-CSRF-TOKEN in the header. How do I get it? I tried it in different ways and no one method works.

Below is my Vue.js

    <script>        import axios from "axios";        export default {          name: "UploadFiles",          data() {          return{            file: ""          }        },          methods:{            selectFile(){            this.file = this.$refs.file.files[0]          },            async sendFile() {                const formData = new FormData();            formData.append('file', this.file);              await axios.post('/user/uploadImages', formData)              }            }          }          </script>  

How to add different items in ScrollView in Kivy?

Posted: 04 Sep 2021 08:47 AM PDT

i am creating an Android app that do the Daily Task application.

Actually I have stucked in a section, can you help me how to do it in Kivy?

What is my problem?

Please first of all see the UI of my application.

enter image description here

As you can see, in the white box there should be scroll view, it means user can scroll between tasks (white box section)

Now, i have created one task label with code below in kv file:

        Label:              id : add_task_status              # this is for background label              background_color: 0,0,0,0              size_hint: None,None              size: dp(220), dp(35)              pos: self.parent.width/2-110, root.winheight-200              canvas.before:                  Color:                      rgba: self.background_color                  RoundedRectangle:                      size: self.size                      pos: self.pos                      radius: [(10, 10), (10, 10), (10, 10), (10, 10)]          Label:              # this is for little boxes right side              id: task_done              background_color: root.r,root.g,root.b,root.a              size_hint: None,None              size: dp(25),dp(25)              pos: self.parent.width/2+80, root.winheight-195              canvas.before:                  Color:                      rgba: self.background_color                  RoundedRectangle:                      size: self.size                      pos: self.pos                      radius: [(7, 7), (7, 7), (7, 7), (7, 7)]          Label:              # this is for text to show in label              font_name: "fonts/Nunito-Light.ttf"              text_size: self.size              text: root.my_task              size_hint: None,None              size: dp(220), dp(35)              pos: self.parent.width/2-100, root.winheight-192    

how can i make it dynamic? when user add new task, it create a new label and add it under the before label

Many Thanks!

How to deploy Jhipster stack to AWS

Posted: 04 Sep 2021 08:46 AM PDT

I built my application using Jhipster stack with React front-end. I can run my application normally. I want to deploy my app to AWS.

I followed the guide then run jhipster aws. Everything is fine. Here is the log:

PS E:\source\vpark> jhipster aws  INFO! Using JHipster version installed globally  INFO! No custom sharedOptions found within blueprint: generator-jhipster-react-antd at C:/Users/dungreact/AppData/Roaming/npm/node_modules/generator-jhipster-react-antd  INFO! No custom commands found within blueprint: generator-jhipster-react-antd at C:/Users/dungreact/AppData/Roaming/npm/node_modules/generator-jhipster-react-antd  ? Application name: vpark  ? Environment name: vpark-env  ? Name of S3 bucket: vpark-s3  ? Database name: vpark  ? Database username: root  ? Database password: [hidden]  ? On which EC2 instance type do you want to deploy? t2.small  ? On which RDS instance class do you want to deploy? db.t2.micro  ? On which region do you want to deploy? us-west-1  Building application  Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details  > Task :bootBuildInfo  > Task :nodeSetup UP-TO-DATE  > Task :npmSetup UP-TO-DATE    > Task :npm_install    up to date, audited 1677 packages in 24s    165 packages are looking for funding    run `npm fund` for details    3 moderate severity vulnerabilities    To address all issues (including breaking changes), run:    npm audit fix --force    Run `npm audit` for details.    > Task :webapp    > vpark@0.0.1-SNAPSHOT webapp:prod  > npm run clean-www && npm run webapp:build:prod      > vpark@0.0.1-SNAPSHOT clean-www  > rimraf build/resources/main/static/app/{src,build/}      > vpark@0.0.1-SNAPSHOT webapp:build:prod  > npm run webpack -- --config webpack/webpack.prod.js --progress=profile      > vpark@0.0.1-SNAPSHOT webpack  > node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.prod.js" "--progress=profile"    assets by status 576 KiB [cached] 5 assets  assets by status 5.06 MiB [compared for emit]    assets by path content/ 1.24 MiB      assets by status 1.08 MiB [big] 2 assets    assets by path swagger-ui/ 3.77 MiB 14 assets    assets by status 5.4 KiB [emitted]      asset service-worker.js 3.61 KiB [emitted] [compared for emit] [minimized]      asset index.html 1.79 KiB [emitted] [compared for emit]    assets by path ./i18n/*.json 24.1 KiB      asset ./i18n/vi.json 12.9 KiB [compared for emit]      asset ./i18n/en.json 11.2 KiB [compared for emit]    4 assets  assets by path app/*.js 1.63 MiB    asset app/vendors.f5ebb1aa658a977e2d40.bundle.js 1.51 MiB [emitted] [immutable] [minimized] [big] (name: vendors) (id hint: commons) 1 related asset    asset app/main.e88c24c5e7a0c24765e4.bundle.js 120 KiB [emitted] [immutable] [minimized] (name: main)  Entrypoint main [big] 2.15 MiB = app/vendors.f5ebb1aa658a977e2d40.bundle.js 1.51 MiB content/main.237501a1e51be6d9143b.css 533 KiB app/main.e88c24c5e7a0c24765e4.bundle.js 120 KiB  cached modules 5.87 MiB (javascript) 551 KiB (css/mini-extract) [cached] 1510 modules  runtime modules 11 KiB 15 modules  orphan modules 37.5 KiB [orphan] 1 module  javascript modules 120 KiB    ./src/main/webapp/app/shared/reducers/locale.ts 1.21 KiB [built] [code generated]    ./node_modules/rc-field-form/es/index.js + 14 modules 114 KiB [built] [code generated]    ./node_modules/react-jhipster/lib/src/util/log-util.js 1.93 KiB [built] [code generated]    ./node_modules/postcss/lib/postcss.js 2.57 KiB [built] [code generated]    LOG from GenerateSW  <i> The service worker at service-worker.js will precache  <i>         32 URLs, totaling 3.62 MB.    WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).  This can impact web performance.  Assets:    content/images/logo.png (318 KiB)    content/images/map.png (788 KiB)    swagger-ui/swagger-ui-bundle.js (1.13 MiB)    swagger-ui/swagger-ui-es-bundle-core.js (518 KiB)    swagger-ui/swagger-ui-es-bundle.js (1.13 MiB)    swagger-ui/swagger-ui-standalone-preset.js (343 KiB)    swagger-ui/swagger-ui.js (518 KiB)    content/main.237501a1e51be6d9143b.css (533 KiB)    app/vendors.f5ebb1aa658a977e2d40.bundle.js (1.51 MiB)    WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.  Entrypoints:    main (2.15 MiB)        app/vendors.f5ebb1aa658a977e2d40.bundle.js        content/main.237501a1e51be6d9143b.css        app/main.e88c24c5e7a0c24765e4.bundle.js      webpack 5.51.1 compiled with 2 warnings in 23251 ms    > Task :processResources UP-TO-DATE  > Task :compileJava UP-TO-DATE  > Task :generateGitProperties  > Task :classes  > Task :bootWar    Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.  Use '--warning-mode all' to show the individual deprecation warnings.  See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings    BUILD SUCCESSFUL in 1m 15s  9 actionable tasks: 5 executed, 4 up-to-date    Create S3 bucket  Bucket vpark-s-3 created successfully    Upload WAR to S3  War uploaded successful    Create database  Database created successfully    Waiting for database (This may take several minutes)  Database available at jdbc:mysql://vpark.culndou2fn7b.us-west-1.rds.amazonaws.com:3306/vpark    Verifying ElasticBeanstalk Roles    Create/Update application  Environment vpark-env created successfully      force .yo-rc.json    No change to package.json was detected. No package manager install will be executed.  Congratulations, JHipster execution is complete!  Sponsored with ❤️  by @oktadev.  

Then I open Elastic Beanstalk console. Enviroment is green but Platform (Tomcat 8.5 with Java 8 running on 64bit Amazon Linux) is Deprecated.

I tried to open the application address http://xxx.us-west-1.elasticbeanstalk.com/ and it just show HTTP Status 404 – Not Found

HTTP Status 404 – Not Found  Type Status Report    Message The requested resource [/] is not available    Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.    Apache Tomcat/8.5.63  

I don't know where is wrong. I can't find other tutorial about this

pH measurement without using aurdino

Posted: 04 Sep 2021 08:46 AM PDT

I am making a project on pH measurement and I'm not allowed to buy a pH sensor also the use of aurdino is prohibited so I'm going to make the pH probe but the silver wire is difficult to buy , so is there any alternative or way to do it.

Error when i configure spring boot app as eureka server and client at same time

Posted: 04 Sep 2021 08:46 AM PDT

I am developing a spring boot app and i want it to be a eureka server and eureka client at same time, to achieve that i modified application.properties file :

server.port=8761  eureka.client.register-with-eureka=true  eureka.client.fetch-registry=false  

these properties allow the app to register as eureka client to the eureka server( which is the same app ). It works fine, but when i shutdown the application i get this error

2021-09-04 15:55:25.421  INFO 8860 --- [on(5)-127.0.0.1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...  2021-09-04 15:55:25.437  INFO 8860 --- [on(5)-127.0.0.1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.  2021-09-04 15:55:25.445  INFO 8860 --- [on(5)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...  2021-09-04 15:55:28.447  INFO 8860 --- [on(5)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : Unregistering ...  2021-09-04 15:55:32.580  INFO 8860 --- [on(5)-127.0.0.1] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/} exception=java.net.ConnectException: Connection refused: connect stacktrace=com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187)      at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123)      at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27)      at com.sun.jersey.api.client.Client.handle(Client.java:652)      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)      at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)      at com.sun.jersey.api.client.WebResource$Builder.delete(WebResource.java:591)      at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.cancel(AbstractJerseyEurekaHttpClient.java:77)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:91)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:120)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.DiscoveryClient.unregister(DiscoveryClient.java:972)      at com.netflix.discovery.DiscoveryClient.shutdown(DiscoveryClient.java:948)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeDestroyMethods(InitDestroyAnnotationBeanPostProcessor.java:347)      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeDestruction(InitDestroyAnnotationBeanPostProcessor.java:177)      at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:242)      at org.springframework.beans.factory.support.DisposableBeanAdapter.run(DisposableBeanAdapter.java:235)      at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.destroy(GenericScope.java:390)      at org.springframework.cloud.context.scope.GenericScope.destroy(GenericScope.java:136)      at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:258)      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587)      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559)      at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1152)      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520)      at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1145)      at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1111)      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1080)      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:171)      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1026)      at org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar$SpringApplicationAdmin.shutdown(SpringApplicationAdminMXBeanRegistrar.java:160)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at java.base/sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:260)      at java.management/com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:193)      at java.management/com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:175)      at java.management/com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)      at java.management/com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)      at java.management/com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)      at java.management/com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)      at java.management/com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)      at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)      at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)      at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)      at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)      at java.base/java.security.AccessController.doPrivileged(Native Method)      at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)      at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)      at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)      at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)      at java.base/java.security.AccessController.doPrivileged(Native Method)      at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)      at java.base/java.lang.Thread.run(Thread.java:834)  Caused by: java.net.ConnectException: Connection refused: connect      at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)      at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)      at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)      at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)      at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)      at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)      at java.base/java.net.Socket.connect(Socket.java:608)      at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)      at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)      at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)      at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134)      at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)      at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118)      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173)      ... 83 more    2021-09-04 15:55:32.581  WARN 8860 --- [on(5)-127.0.0.1] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failed with message: java.net.ConnectException: Connection refused: connect  2021-09-04 15:55:36.710  INFO 8860 --- [on(5)-127.0.0.1] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=java.net.ConnectException: Connection refused: connect stacktrace=com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187)      at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123)      at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27)      at com.sun.jersey.api.client.Client.handle(Client.java:652)      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)      at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)      at com.sun.jersey.api.client.WebResource$Builder.delete(WebResource.java:591)      at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.cancel(AbstractJerseyEurekaHttpClient.java:77)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:121)      at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:80)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:120)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74)      at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71)      at com.netflix.discovery.DiscoveryClient.unregister(DiscoveryClient.java:972)      at com.netflix.discovery.DiscoveryClient.shutdown(DiscoveryClient.java:948)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeDestroyMethods(InitDestroyAnnotationBeanPostProcessor.java:347)      at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeDestruction(InitDestroyAnnotationBeanPostProcessor.java:177)      at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:242)      at org.springframework.beans.factory.support.DisposableBeanAdapter.run(DisposableBeanAdapter.java:235)      at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.destroy(GenericScope.java:390)      at org.springframework.cloud.context.scope.GenericScope.destroy(GenericScope.java:136)      at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:258)      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587)      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559)      at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1152)      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520)      at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1145)      at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1111)      at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1080)      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:171)      at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1026)      at org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar$SpringApplicationAdmin.shutdown(SpringApplicationAdminMXBeanRegistrar.java:160)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at java.base/sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:260)      at java.management/com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:193)      at java.management/com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:175)      at java.management/com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)      at java.management/com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)      at java.management/com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)      at java.management/com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)      at java.management/com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)      at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)      at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)      at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.base/java.lang.reflect.Method.invoke(Method.java:566)      at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)      at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)      at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)      at java.base/java.security.AccessController.doPrivileged(Native Method)      at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)      at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)      at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)      at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)      at java.base/java.security.AccessController.doPrivileged(Native Method)      at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)      at java.base/java.lang.Thread.run(Thread.java:834)  Caused by: java.net.ConnectException: Connection refused: connect      at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)      at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)      at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)      at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)      at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)      at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)      at java.base/java.net.Socket.connect(Socket.java:608)      at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)      at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)      at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)      at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134)      at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:605)      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:440)      at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118)      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173)      ... 84 more    2021-09-04 15:55:36.711  WARN 8860 --- [on(5)-127.0.0.1] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failed with message: java.net.ConnectException: Connection refused: connect  2021-09-04 15:55:36.724 ERROR 8860 --- [on(5)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_UNKNOWN/host.docker.internal:8761 - de-registration failedCannot execute request on any known server    com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server      at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[eureka-client-1.10.14.jar:1.10.14]      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71) ~[eureka-client-1.10.14.jar:1.10.14]      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74) ~[eureka-client-1.10.14.jar:1.10.14]      at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.10.14.jar:1.10.14]      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71) ~[eureka-client-1.10.14.jar:1.10.14]      at com.netflix.discovery.DiscoveryClient.unregister(DiscoveryClient.java:972) ~[eureka-client-  ...    

So how we can avoid first error mentioned in this post ?

(Data Structures: Linked List) Move odd items to the back of list

Posted: 04 Sep 2021 08:45 AM PDT

I am supposed to implement a function void moveOddItemsToBack(LinkedList *ll) that moves all odd integers to back of the linked list ll.

It is able to compile and run, however the numbers are not in the right order and I am unsure why :( The code I have written is as shown:

void moveOddItemsToBack(LinkedList *ll)  {      ListNode *cur = ll-> head;      int orgsize = ll->size;       index =0;           //check for empty list      if (cur == NULL) return;        //if list not empty, traverse entire list      while (orgsize > 0){            //if odd no          if (cur->item %2 !=0){          insertNode(ll, ll->size, cur->item);  //insert the odd number into last item on list          cur = cur -> next;          removeNode(ll, index); //remove the odd number in the original index          }            //if not odd no, just continue traversing list          else cur = cur -> next;            orgsize--;   //original size decreases every while loop so as to inspect the original nodes' integers and not the integers i added to the back of list          index++;  //index increases by 1 everytime i move my cur ptr to the next node      }  }  

Main code given:

#include <stdlib.h>    //////////////////////////////////////////////////////////////////////////////////    typedef struct _listnode  {      int item;      struct _listnode *next;  } ListNode;         // You should not change the definition of ListNode    typedef struct _linkedlist  {      int size;      ListNode *head;  } LinkedList;           // You should not change the definition of LinkedList      //////////////////////// function prototypes /////////////////////////////////////    // You should not change the prototype of this function  void moveOddItemsToBack(LinkedList *ll);    void printList(LinkedList *ll);  void removeAllItems(LinkedList *ll);  ListNode * findNode(LinkedList *ll, int index);  int insertNode(LinkedList *ll, int index, int value);  int removeNode(LinkedList *ll, int index);    //////////////////////////// main() //////////////////////////////////////////////    int main()  {      LinkedList ll;      int c, i, j;      c = 1;      //Initialize the linked list 1 as an empty linked list      ll.head = NULL;      ll.size = 0;          printf("1: Insert an integer to the linked list:\n");      printf("2: Move all odd integers to the back of the linked list:\n");      printf("0: Quit:\n");        while (c != 0)      {          printf("Please input your choice(1/2/0): ");          scanf("%d", &c);            switch (c)          {          case 1:              printf("Input an integer that you want to add to the linked list: ");              scanf("%d", &i);              j = insertNode(&ll, ll.size, i);              printf("The resulting linked list is: ");              printList(&ll);              break;          case 2:              moveOddItemsToBack(&ll); // You need to code this function              printf("The resulting linked list after moving odd integers to the back of the linked list is: ");              printList(&ll);              removeAllItems(&ll);              break;          case 0:              removeAllItems(&ll);              break;          default:              printf("Choice unknown;\n");              break;          }      }      return 0;  }  

Function removeNode given:

      ListNode *pre, *cur;        // Highest index we can remove is size-1      if (ll == NULL || index < 0 || index >= ll->size)          return -1;        // If removing first node, need to update head pointer      if (index == 0){          cur = ll->head->next;          free(ll->head);          ll->head = cur;          ll->size--;            return 0;      }        // Find the nodes before and after the target position      // Free the target node and reconnect the links      if ((pre = findNode(ll, index - 1)) != NULL){            if (pre->next == NULL)              return -1;            cur = pre->next;          pre->next = cur->next;          free(cur);          ll->size--;          return 0;      }        return -1;  }  

Function insertNode given:

int insertNode(LinkedList *ll, int index, int value){        ListNode *pre, *cur;        if (ll == NULL || index < 0 || index > ll->size)          return -1;        // If empty list or inserting first node, need to update head pointer      if (ll->head == NULL || index == 0){          cur = ll->head;          ll->head = malloc(sizeof(ListNode));          ll->head->item = value;          ll->head->next = cur;          ll->size++;          return 0;      }          // Find the nodes before and at the target position      // Create a new node and reconnect the links      if ((pre = findNode(ll, index - 1)) != NULL){          cur = pre->next;          pre->next = malloc(sizeof(ListNode));          pre->next->item = value;          pre->next->next = cur;          ll->size++;          return 0;      }        return -1;  }  

RPI: Ansible: no package available for docker-ce

Posted: 04 Sep 2021 08:45 AM PDT

I am trying to install docker-ce via ansible remotely on a Raspberry Pi 4. Basically, I am using the steps below to add the docker apt repository and then installing docker-ce.

- name: Add Docker apt key    apt_key:      url: https://download.docker.com/linux/raspbian/gpg      id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88    - name: Add Docker apt repository    apt_repository:      repo: deb [arch=armhf] https://download.docker.com/linux/raspbian {{ docker_release }} stable      filename: docker    - name: Install docker    apt:      name: docker-ce      state: present  

Unfortunately, this ends in:

TASK [docker : Install docker] *****************************************************************************************************  fatal: [piconf-1]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}  

Interestingly, a simple sudo apt-get install docker-ce works without any problems, but not through ansible.

Is there anything missing? How can I further debug the problem do see what is going on?

How to get a json element using "JSONObject" class [duplicate]

Posted: 04 Sep 2021 08:45 AM PDT

Here is the json text:

{      "coord": {          "lon": 37.6156,          "lat": 55.7522      },      "weather": [{              "id": 803,              "main": "Clouds",              "description": "broken clouds",              "icon": "04d"          }      ],      "base": "stations",      "main": {          "temp": 9.45,          "feels_like": 6.72,          "temp_min": 8.41,          "temp_max": 11.24,          "pressure": 1009,          "humidity": 70,          "sea_level": 1009,          "grnd_level": 991      },      "visibility": 10000,      "wind": {          "speed": 5.48,          "deg": 304,          "gust": 10.37      },      "clouds": {          "all": 82      },      "dt": 1630768287,      "sys": {          "type": 2,          "id": 2009195,          "country": "RU",          "sunrise": 1630723217,          "sunset": 1630772239      },      "timezone": 10800,      "id": 524901,      "name": "Moscow",      "cod": 200  }  

How can I get the "description" value(broken clouds)? Thank you in advance

C-style arrays do not work with records anymore

Posted: 04 Sep 2021 08:47 AM PDT

I was previously using this contrived code

record Foo(int bar[]) {}  

which is making use of the C-style array-notation. And it compiled fine in Java 15.

Now, all of the sudden, with the official release of records in Java 16, it does not compile anymore. Here is the output from jshell:

jshell> record Foo(int bar[]) {}  |  Error:  |  legacy array notation not allowed on record components  |  record Foo(int bar[]) {}  |                    ^  

Why did it compile in Java 15, was this a bug? Out of curiousity, why is it not supported in records, while being supported anywhere else in Java?

I am using javac from Adoptium (based on OpenJDK).

Decouple front end from Laravel?

Posted: 04 Sep 2021 08:45 AM PDT

I started using laravel and blade, with alpine.js for interactivity.

Eventually, my blade components were becoming messy with some that worked with JS and others that were pure PHP.

My question is, if I were to decouple, and create a laravel api and a JS front end (e.g. nuxt), what other advantages / disadvantages would this have over a Laravel and blade setup?

How to find a element pushed with Enzyme

Posted: 04 Sep 2021 08:46 AM PDT

I've a simple test to check the insertation of input values.

I've defined my variables:

const button = wrapper.find('#send-category')  const input = wrapper.find('#input-category')  const categoryList = wrapper.find('#category-list')  const value = 'Test Value'  

I've simulated the change and click function:

input.simulate('change', { target: { value } })  button.simulate('click')  

When I run the test, the expect fails. Expect:

expect(categoryList.children().first().text().trim()).toBe(value)  

When I debug the variable to access the html element, the value is not found in the element

console.log(categoryList.debug())  

Some advices?

Get the number of comments that are at least one hour apart

Posted: 04 Sep 2021 08:46 AM PDT

I want to get the number of comments that are at least one hour apart. I wrote this query and it works fine.

SELECT COUNT(`c`.`id`) `count`  FROM `comments` `c`  WHERE `user_id` = '28' AND (TIMESTAMPDIFF(SECOND, (      SELECT MAX(`created_at`)      FROM `comments`      WHERE `user_id` = '28' AND `created_at` < `c`.`created_at`  ), `c`.`created_at`) > 3600 OR TIMESTAMPDIFF(SECOND, (      SELECT MAX(`created_at`)      FROM `comments`      WHERE `user_id` = '28' AND `created_at` < `c`.`created_at`  ), `c`.`created_at`) IS NULL)  

But as you can see, this statement is repeated two times:

    SELECT MAX(`created_at`)      FROM `comments`      WHERE `user_id` = '28' AND `created_at` < `c`.`created_at`  

How can I write it cleaner?

SQL Fiddle

Only getting one set of values looping through and array with PHP

Posted: 04 Sep 2021 08:45 AM PDT

I'm using this code to try to loop through an array in PHP

$url='https://api.hubapi.com/form-integrations/v1/submissions/forms/e053ea53-0dae-4cbb-8343-f4ad7bbcaecd?hapikey=8b9998be-1082-4520-a503-c981bab5c57f';  $result = file_get_contents($url);  $arrays = json_decode($result,true);    foreach($arrays['results'][0]['values'] as $item) {      echo $item['value'];       }  

I'm only getting one set of values when there should be two

Output: GermanyADP, ECM IntroPMI Document Solutions, Inc.Munichhttp://www.pmi-ny.comOctober 241200Webinarthis is a testbob@hotmail.comLink to partner event

These are the second set of values. Where is the first?

" Bottom : 0px ; " not working Nor " position : sticky ; " working

Posted: 04 Sep 2021 08:45 AM PDT

Basically, I want to position the div class i.e the navigation bar "basehead" to the bottom of the parent element i.e "header" and make it sticky at that position so that if the webpage is scrolled, the navigation bar appears at the top at every instant.

    /* Parent Element */      .header{          height: 500px;          background-color: #e260b1;          position: relative;      }      /* Element to be stiked at bottom of parent element */      .basehead{          width: 100%;          background: #333333;          height: 60px;          position: sticky;          bottom: 0px;      }  

Rounded image as background of item list

Posted: 04 Sep 2021 08:47 AM PDT

I have a ListView and I want to items have image background with rounded corner, like in new YouTube Music app for Wear OS. Any ideas how to do that? Example

Singleton with multiple inheritance

Posted: 04 Sep 2021 08:46 AM PDT

I've been trying to find a singleton implementation where:

  • I can have a class Application which is abstract
  • And there can be multiple classes derived from Application, for example SampleApplication and OtherSampleApplication.
  • But I only want one instance of Application, whatever the actual type is, so I've been trying to make it a singleton.

Here's my current Singleton implementation:

template<class T>  class Singleton  {  public:      static T& GetInstance()      {        static T instance;        return instance;      }        Singleton(Singleton const&) = delete;      Singleton(Singleton&&) = delete;      Singleton& operator=(Singleton const&) = delete;      Singleton& operator=(Singleton&&) = delete;    protected:      Singleton() = default;      virtual ~Singleton() = default;  };  

Then, for the derived classes, I've tried a number of things:

  1. class Application : public Singleton<Application> with class SampleApplication : public Application
    This will not work because we're trying to create an Application instance instead of a SampleApplication.
  2. class Application : public Singleton<Application> with class SampleApplication : public Application, public Singleton<SampleApplication>
    This doesn't compile because the GetInstance() is ambiguous. I tried to work around this with virtual inheritance but couldn't get it to compile.
  3. class Application with class SampleApplication : public Application, public Singleton<SampleApplication>
    Doesn't meet the "requirements" I listed above because we can have another singleton of another derived class.

Does anyone know a way to accomplish this?

Why std::unique_ptr prevents the access to the object being destroyed?

Posted: 04 Sep 2021 08:47 AM PDT

As far as I see the code below correct:

#include <iostream>  #include <functional>    struct A  {      std::function<void ()> func;            int value = 5;            ~A() { func(); }  };    int main()  {      A* p_a = new A();      p_a->func = [&p_a]() { std::cout << p_a->value; };      delete p_a;      return 0;  }  

but the following code is not and results in a segmentation fault:

int main()  {      std::unique_ptr<A> p_a = std::make_unique<A>();      p_a->func = [&p_a]() { std::cout << p_a->value; };      p_a = {};      return 0;  }  

std::unique_ptr clears its internal pointer first and then deletes the object and thus prevents the access to the object being destroyed.

What is it for? What is the logic behind this?

C++ random number same sequence every time

Posted: 04 Sep 2021 08:45 AM PDT

I wrote this to generate a random password:

#include <iostream>  #include <fstream>  #include <string>  #include <cstdlib>  using namespace std;    string read(string value) { //read value      ifstream input;      int olength;      string line = "", output = "";      size_t pos;      bool a = true;      int i = 0;      input.open("pg_options.txt");      if (!input.is_open()) {          cout << "pg_options.txt missing.";          return "error";      }      while (getline(input, line)) {          pos = line.find(value);          if (pos != string::npos) {              while (a == true) {                  if (line[i] == '=') {                      i++;                      break;                  }                  else {                      i++;                  }              }              olength = line.length() - value.length() - 1;              for (int i2 = 0; i2 < olength; i2++) {                  output += line[i];                  i++;              }          }      }      input.close();      return output;  }    char randupper() { //generate random upper case character      char uppercase[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };      int i = rand() % 26;      return uppercase[i];  }    char randlower() { //generate random lower case character      char lowercase[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };      int i = rand() % 26;      return lowercase[i];  }    char randspecial() { //generate random special character      char special[7] = { '!', '#', '$', '%', '&', '*', '?' };      int i = rand() % 7;      return special[i];  }    char randnumbers() { //generate random number      char numbers[10] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };      int i = rand() % 10;      return numbers[i];  }    void generate() { //generate the password      string output = "";      int i1=0, digits = 0, upper = 0, lower = 0, special = 0, numbers = 0;      digits = stoi(read("digits")); //get digits      if (read("include_upper_case") == "true") { //determine number of upper case characters          upper = rand() % (digits / 2) + 1;          digits -= upper;      }      if (read("include_lower_case") == "true") {          lower = rand() % (digits / 2) + 1;          digits -= lower;      }      if (read("include_special_characters") == "true") {          special = rand() % (digits / 2) + 1;          digits -= special;      }      if (read("include_numbers") == "true") {          numbers = digits;      }      else { //if numbers not included          if (read("include_upper_case") == "true") {              upper += digits;          }          else if (read("include_lower_case") == "true") {              lower += digits;          }          else if (read("include_special_characters") == "true") {              special += digits;          }          else {              cout << "error generating, please check your options.";              return;          }      }      for (int i = 0; i < stoi(read("digits")); i++) {          i1 = rand() % 4;          if (i1 == 0) { //if uppercase              if (upper > 0) {                  output += randupper();                  upper--;              }              else {                  i--;              }          }          else if (i1 == 1) {              if (lower > 0) {                  output += randlower();                  lower--;              }              else {                  i--;              }          }          else if (i1 == 2) {              if (special > 0) {                  output += randspecial();                  special--;              }              else {                  i--;              }          }          else if (i1 == 3) {              if (numbers > 0) {                  output += randnumbers();                  numbers--;              }              else {                  i--;              }          }      }      cout << output;  }    int main() {      generate();      return 0;  }  

pg_options.txt:

include_special_characters=true  include_upper_case=true  include_lower_case=true  include_numbers=true  digits=10  

However, it generates the same thing every time it runs, that is HM*nfx375g, so it has same sequence of random numbers. (in generate(), upper is always 2, lower is always 4, special is always 1, numbers is always 3...) Is there a function that can generate different random numbers every time?

undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status )(

Posted: 04 Sep 2021 08:47 AM PDT

Not able to run this file. If any problem is in the code please help to resolve.

C:\Users\mriga\Documents\DEV\C++\Projects\covid pjt> cd "c:\Users\mriga\Documents\DEV\C++\Projects\covid pjt\" ; if ($?) { g++ functions.cpp -o functions } ; if ($?) { .\functions }  c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16'  collect2.exe: error: ld returned 1 exit status*  

FIRST FILE covid.h

#include<iostream>  #include <stdio.h>  #include <stdlib.h>  #include<string>  #include<time.h>  #include<vector>  #include <sstream>  #include <iomanip>  #include <fstream>  #define _USE_MATH_DEFINES  #include<math.h>  #include<complex>  #include <valarray>  using namespace std;  /*  Estimating the COVID-19 evolution  using the Logistic Model, A Xavier Jr, March 2020  */  //maximum number of iterations  const int max_iter = 10000;  class tools {  ;  public:  float Ncases(int jx, float Kx, float Ax, float rx);  float dNcases(int jx, float Kx, float Ax, float rx);  float K(float C1, float C2, float C3);  float A(float m, float jx, float C1, float C2, float C3);  float r(float m, float C1, float C2, float C3);  float dNdK(int tx, float Kx, float Ax, float rx);  float dNdA(int tx, float Kx, float Ax, float rx);  float dNdr(int tx, float Kx, float Ax, float rx);  };  /*  Class Least Squares Steepest Descent  DATA contains the series of input data  dDATA containg the daily number of cases  C1, C2 and C3 are the three  numbers M(k-2m), M(k-m) and M(k) for calculating  the input guess of the Logistic model  tp - time of maximum number of daily cases (Eq. 6)  Cp - number of cases at tp, equal to K/2  NcLog, dNcLog - contain the forecast of the model  for the total and the daily number of cases  Logistic() and dLogistic() updates  NcLog and dNcLog with the model forecast  */  class LSSD{  ;  public:  int EndTime;  float C1, C2, C3, Kg, Ag, rg, kg, mg;  float tp, Cp;  float varN;  vector<float> DATA, dDATA;  vector<float> NcLog, dNcLog;  tools FF;  float VarNcases();  void Logistic();  void dLogistic();  float dRdK();  float dRdA();  float dRdr();  bool FindInitialGuess(int m, int k);  void steepestdescent(float alpha, float dKx, float dAx, float drx);  // Input and output  void readinputfile(string filenamex);  void writeoutput(string filenamex);  void writeprediction(string filenamex);  };  

SECOND FILE functions.cpp

#include "COVID.h"  /*  Read input file filenamex and save into DATA[] and dDATA[]  */  void LSSD::readinputfile(string filenamex) {  string line;  vector<string> lines;  int linecounter = 0;  string field;  ifstream myfile(filenamex); //to open the file (convert to *char)  if (myfile.is_open()) {  cout << "->>>> Open input file::" << filenamex << endl;  while (getline(myfile, line)) {  if (line.substr(0, 1) != "#") { //skip lines starting with #  lines.push_back(line); //saves valid line in lines  }  }  myfile.close();  }  for (int i = 0; i < lines.size(); i++) {  field = lines[i].substr(lines[i].find(";") + 1, lines[i].length());  DATA.push_back((float)stof(field));  }  //Find the daily difference keeping the same size of the original data  dDATA.push_back(DATA[1] - DATA[0]); //value 0 = value 1  for (int i = 1; i < lines.size(); i++) {  dDATA.push_back(DATA[i] - DATA[i - 1]);  }  }  /*  writing model and input data (including daily change)  for the data time span  */  void LSSD::writeoutput(string filenamex) {  ofstream myfile(filenamex); //opens file  cout << "Saving output::" << filenamex << endl;  myfile << "day, Ncsimul, Ncases, dNcsimul, dNcases "<< endl;  for (int i = 0; i < DATA.size(); i++) {  myfile << i+1 << "," << NcLog[i] << "," << DATA[i] << ","  << dNcLog[i] << "," << dDATA[i] << endl;  }  myfile.close(); //closes file  }  /*  writing model and input data (including daily change)  up to EndTime  */  void LSSD::writeprediction(string filenamex) {  ofstream myfile(filenamex); //opens file  cout << "Saving prediction file::" << filenamex << endl;  myfile << "day, Ncsimul, dNcsimul" << endl;  for (int i = 0; i < EndTime; i++) {  myfile << i+1 << "," << NcLog[i] << "," << dNcLog[i] << endl;  }  myfile.close(); //closes file  }  /*  NcLog vector contains the Logistic model (vector of EndTime-1 elements)  */  void LSSD::Logistic() {  for (int i = 0; i <= EndTime; i++) {  NcLog.push_back(FF.Ncases(i, Kg, Ag, rg));  }  }  /*  dNcLog vector contains the derivative of the  Logistic model (vector of EndTime-1 elements)  */  void LSSD::dLogistic() {  for (int i = 1; i <= EndTime; i++) {  dNcLog.push_back(FF.dNcases(i, Kg, Ag, rg));  }  }  /*  Eq. (2)  */  float tools::Ncases(int jx, float Kx, float Ax, float rx) {  return Kx / (1 + Ax*exp(-rx*jx));  }  /*  Eq. (3)  */  float tools::dNcases(int jx, float Kx, float Ax, float rx) {  return Kx*Ax*rx*exp(-rx*jx) / ((1 + Ax*exp(-rx*jx))*(1 + Ax*exp(-rx*jx)));  }  /*  First relation in Eq. (12)  */  float tools::K(float C1, float C2, float C3) {  return C2*(C1*C2 - 2 * C1*C3 + C2*C3) / (C2*C2 - C3*C1);  }  /*  Second relation in Eq. (12)  */  float tools::A(float m, float jx, float C1, float C2, float C3) {  float partial, exponent;  exponent = (jx - m) / m;  partial = (C3 - C2)*(C2 - C1) / (C2*C2 - C3*C1);  partial *= pow((C3*(C2 - C1) / (C1*(C3 - C2))), exponent);  return partial;  }  /*  Third relation in Eq. (12)  */  float tools::r(float m, float C1, float C2, float C3) {  return log(C3*(C2 - C1) / (C1*(C3 - C2))) / m;  }  /*  First relation in Eq. (11)  */  float tools::dNdK(int tx, float Kx, float Ax, float rx) {  return 1 / (1 + Ax*exp(-rx*tx));  }  /*  Second relation in Eq. (11)  */  float tools::dNdA(int tx, float Kx, float Ax, float rx) {  return -Kx*exp(-rx*tx) / ((1 + Ax*exp(-rx*tx))*(1 + Ax*exp(-rx*tx)));  }  /*  Third relation in Eq. (11)  */  float tools::dNdr(int tx, float Kx, float Ax, float rx) {  return rx*Kx*Ax*exp(-rx*tx) / ((1 + Ax*exp(-rx*tx))*(1 + Ax*exp(-rx*tx)));  }  /*  To find the initial parameter before optimization  The initial guess is (Kg, Ag,, rg) using mg and kg externally given  */  bool LSSD::FindInitialGuess(int mx, int kx) {  bool retval;  mg = (float) mx;  kg = (float) kx;  C1 = DATA[kg - 2 * mg];  C2 = DATA[kg - mg];  C3 = DATA[kg];  cout << "An initial guess for the Logistic model was found..." << endl;  //Initial guess  Kg = FF.K(C1, C2, C3);  Ag = FF.A(mg, kg, C1, C2, C3);  rg = FF.r(mg, C1, C2, C3);  //Kg has to be larger than the last data entered  if ((Ag < 0) || (Kg < DATA[DATA.size()-1]) ) {  cout << "It wasnt possible to find a solution..." << endl;  retval = false;  }  else {  cout << "K(0)=" << Kg << endl;  cout << "A(0)=" << Ag << endl;  cout << "r(0)=" << rg << endl;  //Find the time of maximum daily cases  tp = log(Ag) / rg;  Cp = Kg / 2;  cout << "Estimated time constant::" << 1 / rg << " days" << endl;  cout << "Estimated time of maximum::" << tp  << " days after the initial day" << endl;  cout << "Estimated maximum cases at end time::" << Kg << endl;  retval = true;  }  return retval;  }  //calculating the s2 (Eq. 8) for the model and data  float LSSD::VarNcases() {  float temp=0;  float N;  for (int i = 0; i < DATA.size(); i++) {  N = FF.Ncases(i, Kg, Ag, rg);  temp += (DATA[i] - N)*(DATA[i] - N);  }  return temp / DATA.size();  }  /*  Derivative of s2 with respect to K, Eq. 10  */  float LSSD::dRdK() {  float temp = 0;  float N, dN;  for (int i = 0; i < DATA.size(); i++) {  N = FF.Ncases(i, Kg, Ag, rg);  dN = FF.dNdK(i, Kg, Ag, rg);  temp += (DATA[i] - N)*dN;  }  return -2.*temp / DATA.size();  }  /*  Derivative of s2 with respect to A, Eq. 10  */  float LSSD::dRdA() {  float temp = 0;  float N, dN;  for (int i = 0; i < DATA.size(); i++) {  N = FF.Ncases(i, Kg, Ag, rg);  dN = FF.dNdA(i, Kg, Ag, rg);  temp += (DATA[i] - N)*dN;  }  return -2.*temp / DATA.size();  }  /*  Derivative of s2 with respect to r, Eq. 10  */  float LSSD::dRdr() {  float temp = 0;  float N, dN;  for (int i = 0; i < DATA.size(); i++) {  N = FF.Ncases(i, Kg, Ag, rg);  dN = FF.dNdr(i, Kg, Ag, rg);  temp += (DATA[i] - N)*dN;  }  return -2.*temp / DATA.size();  }  /*  minimize the residue s2 and find a better estimate for K, A and r  using the Steepest Descent method.  The iteration parameters are given externaly by alphax, dKx, dAx and drx  */  void LSSD::steepestdescent(float alphax, float dKx, float dAx, float drx) {  float R0,R;  float dK, dA, dr, alpha;  int iter = 0;  alpha = alphax; //acceleration parameter  dK = dKx;  dA = dAx;  dr = drx;  //Find the initial dispersion  R0 = VarNcases();  for (int j = 0; j < max_iter; j++) {  //calculating the gradients  Kg -= dRdK()*dK*alpha;  Ag -= dRdA()*dA*alpha;  rg -= dRdr()*dr*alpha;  R = VarNcases();  //if the actual dispersion is smaller than the previous  //update previous value  if (R < R0) {  R0 = R;  cout << '\r' << "iter " << j << " K=" << Kg <<  " A=" << Ag << " r=" << rg << " Residue= " << R;  iter = j;  }  else  break;  }  cout << endl << "Converged values" << endl;  cout << "===========================" << endl;  cout << "K(" << iter << ")=" << Kg << endl;  cout << "A(" << iter << ")=" << Ag << endl;  cout << "r(" << iter << ")=" << rg << endl;  tp = log(Ag) / rg;  Cp = Kg / 2;  cout << "Time constant::" << 1 / rg << " days" << endl;  cout << "Final time of maximum daily cases::" << tp  << " days after the initial day" << endl;  cout << "Final expected maximum number of cases::" << Kg << endl;  }  

Reading Array Values of C

Posted: 04 Sep 2021 08:44 AM PDT

I want to read 10 values of an array in C language. How can I read them without using a for loop? For example in MATLAB we have such a thing:

a = [7 9 5; 6 1 9; 4 3 2];

b = a(:;1:2); => b = [7 9; 6 1; 4 3];

Do we have sth. like this in C?

Regex in Geany matching everything inside divs [duplicate]

Posted: 04 Sep 2021 08:47 AM PDT

I use Geany 1.29 editor IDE on Debian. I'm trying make regex to match everything in html code between <div id="columnLeft">...</div> tags including div tags itself. There are a lot of nested divs and new lines inside target div id, and also, it seems Geany regex syntax have some specific, that I can't define. I don't know how to match recursively the closing outer DIV.(its sixth from target opening div). I tried this pattern, but it doesn't work: (<div id=\"columnLeft\">)(.*?)(<\/div>)

Here is an example.

Can anybody specify correct syntax here?

How can I check if a dependency exists in a remote repository?

Posted: 04 Sep 2021 08:46 AM PDT

I tried with dependency:get or dependency:copy, but those goals will also resolve from my local repo.

Next I tried to make a simple download from https://repo.company.com/repo/<path-to-group>/<artifactId>/<version>/<artifactId>-<version>.pom, but that fails because of missing permissions. I guess that's why I tried to use a plugin, in order to use the existing maven credentials.

Context: Writing a deployment script that should avoid overwriting existing artifacts in our company repo.

Is locking required when reading and writing tuple headers in MVCC?

Posted: 04 Sep 2021 08:45 AM PDT

Several locks are introduced in MySQL, among which SELECT ... FROM is a consistent read, a snapshot of the read data and no lock is set (unless the transaction level is SERIALIZABLE) (https://dev.mysql.com/doc/refman/5.7/en/innodb-locks-set.html)

The snapshot (MVCC) is implemented in MySQL by adding a header (including transaction version and pointer) and logical visibility rules to the tuple

But we always emphasize the design principle of the visibility rule, but ignore the fact that reading and writing to the tuple Header are two mutually exclusive actions, which can only be avoided by locking.

So how does the sentence of consistent read without lock understand? Is it just that there is no lock in a broad sense? How is the atomic reading and writing of the tuple Header designed? Is there any performance overhead? Is there any information available in this regard?

two or more for loops time complexity

Posted: 04 Sep 2021 08:46 AM PDT

If we assume the statements inside of a for loop is O(1).

for (i = 0; i < N; i++) {      sequence of statements  }  

Then the above time complexity should be o(n) another example is:

for (i = 0; i < N; i++) {      for (j = i+1; j < N; j++) {          sequence of statements      }  }  

the above time complexity should be o(n^2)

It seems like one for loop symbolize n times However, I've seen some discussion said that it's not simply like this Sometimes there are 2 for loops but it doesn't mean the time complexity must be o(n^2)

Can somebody give me an example of two or more for loops with only O(n) time complexity (with explanation will be much better)???

thymeleaf passing param from a form to a controller

Posted: 04 Sep 2021 08:45 AM PDT

Im making an app where i have users and some of them have a role Mentors. Users can choose a mentor, who will in time add a personal program and food regime for the user. So far im printing all the users, having the Mentor role in an html file, but i cant seem to pass the parameter for the in the post method.I want to send the user id(currently the id of the mentor) to the controller. So far the object inside the form in the html where i said th:object="${user}" and th:field="*{id}" reffers to the plain model.addAttribute("user", new User()); I've added to the controller.This way it always returns id-null

Required request parameter 'id' for method parameter type Long is present but converted to null  org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'id' for method parameter type Long is present but converted to null  
    import java.util.ArrayList;  import java.util.List;  import java.util.Optional;    import javax.persistence.*;     @Entity  @Table(name = "users")  public class User {             @Id      @GeneratedValue(strategy = GenerationType.IDENTITY)      private Long id;             @Column(nullable = false, unique = true, length = 45)      private String email;             @Column(nullable = false, unique = true, length = 45)      private String username;             @Column(nullable = false, length = 64)      private String password;             @Column(name = "first_name", nullable = false, length = 20)      private String firstName;             @Column(name = "last_name", nullable = false, length = 20)      private String lastName;            @Column(name = "age", nullable = false, length = 20)      private int age;            @Column(name = "sex")      private String sex;            @Column(name = "mentor_id", nullable = true)      private Long mentorid;                    @OneToOne(cascade = CascadeType.ALL)      @JoinColumn(name="account_id")      private accountInfo accountinfo;      public User() {}            @OneToMany(mappedBy="user")      private List<Blog> blogs= new ArrayList<Blog>();            @ManyToOne(optional = false,fetch = FetchType.LAZY)      @JoinColumn(name="role_id")          private UserRole role;            @OneToOne(mappedBy = "user")      private PersonalProgram personalprogram;           public Long getId() {          return id;      }        public void setId(Long id) {          this.id = id;      }        public String getEmail() {          return email;      }        public void setEmail(String email) {          this.email = email;      }        public String getPassword() {          return password;      }        public void setPassword(String password) {          this.password = password;      }        public String getFirstName() {          return firstName;      }        public void setFirstName(String firstName) {          this.firstName = firstName;      }        public String getLastName() {          return lastName;      }        public void setLastName(String lastName) {          this.lastName = lastName;      }        public String getUsername() {          return username;      }        public void setUsername(String username) {          this.username = username;      }      public accountInfo getAccountinfo() {          return accountinfo;      }      public void setAccountinfo(accountInfo accountinfo) {          this.accountinfo = accountinfo;      }        public List<Blog> getBlogs() {          return blogs;      }        public void setBlogs(List<Blog> blogs) {          this.blogs = blogs;      }        public UserRole getRole() {          return role;      }        public void setRole(UserRole role) {          this.role = role;      }        public int getAge() {          return age;      }        public void setAge(int age) {          this.age = age;      }        public String getSex() {          return sex;      }        public void setSex(String sex) {          this.sex = sex;      }        public Optional<Long> getMentorid() {          return Optional.ofNullable(mentorid);      }        public void setMentorid(Long mentorid) {          this.mentorid = mentorid;      }        public PersonalProgram getPersonalprogram() {          return personalprogram;      }        public void setPersonalprogram(PersonalProgram personalprogram) {          this.personalprogram = personalprogram;      }                }  

this is my user class

<!DOCTYPE html>  <html xmlns:th="http://www.thymeleaf.org">  <head>      <meta charset="ISO-8859-1">      <title>List of Trainers</title>      <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css" />      <script type="text/javascript" src="/webjars/jquery/jquery.min.js"></script>      <script type="text/javascript" src="/webjars/bootstrap/js/bootstrap.min.js"></script>      <script>      function getUser(userid) {          $.ajax({              url: "/trainers/choose?userId="+userid,              type: "get",                        });      }      </script>  </head>  <body>  <div class="container text-center">            <div>          <h1>List of Trainers</h1>      </div>             <div>          <table class="table table-striped table-bordered">              <thead class="thead-dark">                  <tr>                      <th>First Name</th>                      <th>Last Name</th>                      <th>Age</th>                      <th>Email</th>                      <th></th>                  </tr>              </thead>              <tbody>                  <tr th:each="user,index: ${listUsers}">                      <td  th:text="${user.firstName}">First Name</td>                      <td th:text="${user.lastName}">Last Name</td>                      <td th:text="${user.age}">Age</td>                      <td th:text="${user.email}">Email</td>                      <td>                                                                                                     <form th:action="@{/trainers/choose}"  th:object="${user}" method="post">                                  <input type="hidden" th:field="*{id}" />                                  <button type="submit">Choose</button>                              </form>                                                                                                                                          </td>                  </tr>                                 </tbody>          </table>                </div>  </div>  </body>  </html>  

and this is my html

and i guess the controllers handler about the post Method going to look something like this

 @RequestMapping(value="trainers/choose", method = RequestMethod.POST)          public String processTrainersChoose (@RequestParam Long mentorid) {  

and the get method for visualising the html page is

@GetMapping("/trainers")      public String listTrainers(Model model) {          List<User> listUsers = userRepo.findAllByRole(userRoleRepo.findByName("ROLE_MENTOR"));          model.addAttribute("listUsers", listUsers);          model.addAttribute("user", new User());                               return "trainers";      }      ```       

Calculating beta in pine script : what am I doing wrong?

Posted: 04 Sep 2021 08:47 AM PDT

I've written the following pine script code to calculate the beta ratio but I'm getting a result that seems too small to me. I've checked the definition of beta on numerous sites and everything seems correct. What am I doing wrong?

//@version=4  study("BETA")    change = roc(close, 1)    spx_close = security("SPX", timeframe.period, close)  spx_change = roc(spx_close, 1)    var sym_chg_arr = array.new_float(0)  var spx_chg_arr = array.new_float(0)    array.push(sym_chg_arr, change)  array.push(spx_chg_arr, spx_change)    covariance = array.covariance(sym_chg_arr, spx_chg_arr)  variance = array.variance(sym_chg_arr)    beta = covariance / variance    plot(beta, color=color.yellow, linewidth=2, histbase=0)  hline(0)  

Adding a link to one of the definitions of beta I used to implement the code above https://www.investopedia.com/ask/answers/102714/how-do-you-calculate-beta-excel.asp

How to check SSL expiry in Azure VMs using Azure Powershell Runbooks

Posted: 04 Sep 2021 08:46 AM PDT

I need to check SSL expiry for all Azure VMS in a subscription, using powershell and runbooks in Azure what's the best way of doing this?

How to use blurha.sh with new Next.JS Image Component

Posted: 04 Sep 2021 08:46 AM PDT

Any idea how to use, in Next.JS 11, the new blur placeholder from Image component as announced on https://nextjs.org/blog/next-11#image-placeholders ?

<Image   src={banner}   alt={name}   layout="responsive"   width={1920}   height={675}   quality={100}   placeholder="blur"   blurDataURL={bannerBlurHash} // Here bannerBlurHash code as data url ?   priority  />  

Cheers,

How to reverse order output of a MySQL query

Posted: 04 Sep 2021 08:44 AM PDT

I have a basic write to and retrieve SQL database PHP "thing" and I want to have the output in descending order. How do I do that?

For example, the last entry is shown first, then the entry before that, then the entry before that, etc. The first entry ever is last.

How can unrar a file with python

Posted: 04 Sep 2021 08:45 AM PDT

How can I extract a .zip or .rar file using Python?

No comments:

Post a Comment