on-internet

Saving M-PESA callback data

I am trying to save M-PESA callback data, when a user has paid with Lipa Na M-PESA. I need to save the CheckoutRequestID, with a decoded username from token, then if the payment is successful the callback URL needs to update the associated CheckoutRequestID from MySQL with the amount, from there it needs to update the user's wallet with the new value. Currently, the code works well, but I cannot save. When I try to access the username or any value, the callback doesn't return any data. Here is the Lipa Na M-PESA code and the STK Callback code. Lipa Na M-PESA code router.get('/stk', middleware.

Join the discussion →

Why does performing modulo on a float not give the expected result?

Can someone give me an explanation on why this is happening in PHP: echo (0.29*100)%100 // result 28 It's probably very simple but logically I do not see any explanation. Probably how PHP works in the background. I was trying to get the first two decimal positions of a number when I ran into this case. Result should be 29 naturally. If I round the multiplication the result is fine: echo (round(0.29*100))%100 // result 29

Join the discussion →

Getting “Failed to connect to the bus: Could not parse server address” error when launch Chrome in CentOS using puppeter

I am trying to launch Chrome in CentOS using puppeteer but got errors like this: [8012:8039:1220/204633.586208:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix") [8012:8039:1220/204633.586325:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix") [8012:8039:1220/204633.595443:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of

Join the discussion →

How do you open multiple markdown previews at the same time in VS Code?

In VSCode, as you can see here, opening a md file in preview mode will replace a current preview instead of adding another preview. You can only ever have one markdown preview open at a time. How can I instead get the alternative behavior, where opening a md file in preview mode adds a brand new preview tab no matter what?

Join the discussion →

Errors object is not being updated properly on input

coming into a new codebase here and it's also my first time using Formik and Yup so I will try to be as concise as possible, but bear with me. I have some forms that were built with Formik and use a validation schema provided by Yup. I also have a useState variable to indicate whether or not an item is present in Yup's errors object that is used to prevent the user from continuing to the next form until the error is fixed. The validation works correctly initially, as when an invalid input is provided, the corresponding error is shown in the errors object. However, if I type something valid int

Join the discussion →

How to determine the number of constrained CPUs within a Docker container? For use with make -j

Docker supports a --cpus option which constrains a container to using a certain proportion of the host's computing resource. For example, --cpus 2.5 will allocate computing resource equivalent to approximately two and a half of the host's CPU capability. This allocation seems to be somewhat "logical" rather than physical, in that a container running eight processes but with --cpus 1.0 tends to run each process on a separate CPU but limited to approximately 12.5%. This is fine, I suppose. The problem is that I am not able to find a way for a process within a constrained container to determine h

Join the discussion →

Sorting higher header of a table in two groups

I have the following data table tests0 GROUP mean0 stderr0 mean7 stederr7 diff.std.mean p.value <fct> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 test1_score_T0 cltr 53.0 2.24 55.7 2.95 -2.76 0.0333 2 test1_score_T0 tr 47.5 2.82 54.5 3.13 -6.97 0.000197 3 test2_score_T0 cltr 59.0 2.16 59.5 2.36 -0.555 0.362 4 test2_score_T0 tr 60.5 1.68 66.8 1.86 -6.35 0.0000000278 5 test3_score_T0 cltr 41.1 1.77 41.0 1.83 0.0847 0.908 6 test3_score_T0 tr 41.3 1.17 46.8 1.61 -5.53 0.0000210 7 test4_score_T0 cltr 68.7 2.93 71.5 2.68 -2.85 0.0424 8 test4_score_T0 tr 65.8 2.41 75.1 2.39 -9.24 0.000000658 Since I

Join the discussion →

Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported] Spring MVC

I created a sample crud operations application using Spring Mvc, Hibernate, Maven. All my operations are working fine. I got a problem on update method. I dont know where I went wrong. I referred this article. https://java2blog.com/spring-mvc-hibernate-mysql-crud-example/ Add,delete, display methods are working fine. Here is the issue I am getting when I try to update. WARNING: Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported] I do not know what's wrong. Please help output Controller Class: package com.spring.controller; import java.

Join the discussion →

How to return to the same scroll position when going back using useNavigate() or useLocation() react-router

When clicking on a specific pokemon, the user can show details of the pokemon. When the user clicks the back button to see all pokemon, I want them to continue in the exact same scroll position/pokemon, where they first clicked. How to achieve this? Here is the pokedex component, where the user can click on each pokemon: import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { ScrollArrow } from './utils/scrollArrow'; import { Container, Card, Col, Row, Spinner } from 'react-bootstrap'; const Pokedex = () => { const [pokemon, setPokemon] = useState([]); co

Join the discussion →

How to install "Code With Me" plugin with Android Studio

Code With Me plugin from JetBrains now works with Android Studio. However each version of the plugin is compatible with a specific build of Android Studio according to this page. However, Android Studio download page lists only releases. How can I easily find out build number of each Android Studio version, so I could download a version that's compatible with Code With Me plugin?

Join the discussion →

"npm install @azure/msal-browser @azure/msal-angular@latest" but nothing inside of node_modules

I'm trying to include Azure AD for the login, but after running npm install @azure/msal-browser @azure/msal-angular aswell as npm install @azure/msal-browser @azure/msal-angular@latest no new entries in the node_modules folder can be seen. So when trying to import the modules import { MsalModule } from '@azure/msal-angular'; import { PublicClientApplication } from '@azure/msal-browser'; I get the warning TS2307: Cannot find module '@azure/msal-browser' or its corresponding type declarations When running the commands it seems to install everything (I run it where the frontend is located, also t

Join the discussion →

Azure Databricks error- The output of the notebook is too large. Cause: rpc response

Error Message - job failed with error message The output of the notebook is too large. Cause: rpc response (of 20972488 bytes) exceeds limit of 20971520 bytes Details: We are using databricks notebooks to run the job. Job is running on job cluster. This is a streaming job. Job started failing with above mentioned error. We do not have any display(), show(), print(), explain method in the job. We are not using awaitAnyTermination method in the job as well. We also tried adding "spark.databricks.driver.disableScalaOutput true" to the job but it still did not work. Job is failing with same error.

Join the discussion →

How to compute the between-group mean difference?

By starting from this code, I would like to compute the between 7-time-point difference: data <- out %>% group_by(tests0, GROUP) %>% summarise( all = list(across(starts_with("score")) %>% { tibble( means = data.frame(map(., ~ mean(.x, na.rm = TRUE)) %>% set_names(., str_replace(names(.), "\\D+", "mean"))), stderrs = data.frame(map(., ~ std.error(.x, na.rm = TRUE)) %>% set_names(., str_replace(names(.), "\\D+", "stederr"))), ttest1 = data.frame(possibly(~ reduce(., ~ t.test(.x, .y, paired = TRUE))["estimate"], NA)(.)), ttest2 = data.frame(possibly(~ reduce(., ~ t.test(.x, .y, paired = TRUE))["p

Join the discussion →

Create a columns conditioned to two possible levels contained in another column

I have the following dataset out # A tibble: 1,356 x 7 ID GROUP Gender Age Education tests score <dbl> <chr> <dbl> <dbl> <dbl> <chr> <dbl> 1 1 TRAINING 1 74 18 ADAS_CogT0 56.7 2 1 TRAINING 1 74 18 ROCF_CT0 89 3 1 TRAINING 1 74 18 ROCF_IT0 7.9 4 1 TRAINING 1 74 18 ROCF_RT0 7.09 5 1 TRAINING 1 74 18 PVF_T0 478.1 6 1 TRAINING 1 74 18 SVF_T0 78 7 1 TRAINING 1 74 18 ADAS_CogT7 65 8 1 TRAINING 1 74 18 ROCF_CT7 09 9 1 TRAINING 1 74 18 ROCF_IT7 8.7 10 1 TRAINING 1 74 18 ROCF_RT7 66.1 If I would like to create a column where in place of the tests ending with T0 would corresponf the value score0 whereas

Join the discussion →

Is there a way to iterate over a list in Playwright and click over each element?

I'm trying to iterate over a list of dynamic elements with Playwright, I've tried a couple of things already, but none have been working: await this.page.locator('li').click(); const elements = await this.page.locator('ul > li'); await elements.click() await this.page.$$('ul > li').click(); await this.page.click('ul > li'); const divCounts = await elements.evaluateAll(async (divs) => await divs.click()); this.page.click('ul > li > i.red', { strict: false, clickCount: 1 },) const elements = await this.page.$$('ul > li > i.red') elements.forEach(async value => { console.log(value) await this.pag

Join the discussion →

Converting two couple 2 columns into a long format dataset: how to do?

I have tried to manipulate the original dataset I had as follows. db%>% mutate(GROUP = fct_recode(GROUP, CONTROL = "CONTROLLO")) %>% to_long(keys = c("tests0", "tests7"), values =c("score0", "score7"), grep("T0$", names(.), value = TRUE), grep("T7$", names(.), value = TRUE)) %>% as_tibble %>% mutate(Gender = factor(Gender, levels = c(1, 0), labels = c("M", "F")), across(c(tests0, tests7), factor)) And I have obtained the following dataset # A tibble: 200 × 13 subj GROUP Gender Age EX testa_score_T1 testb_score_T1 testc_score_T1 testd_score_T1 tests0 <chr> <fct> <fct> <int> <int> <dbl> <dbl> <d

Join the discussion →

NetSuite Restlet OAuth 2.0 Non-expiring Token (Now OA1.0)

Quick question here, as I'm just dipping my toes into NetSuite Rest integrations for the first time. I have a standard Oauth2.0 flow successfully authenticating with Access Token/Refresh token, but the access tokens expire after 3600 seconds. The system I'm working with to talk to NetSuite only wants to do an Access Token as they don't have Refresh/Access flows yet. Is there a way to increase the expiry of the access token from NetSuite to 24 hours or even longer? Every day I can run a scheduled process from NetSuite to "subscribe" to the other system and provide them with the required Access

Join the discussion →

Apex specialist superbadge challenge 4

I am stuck on creating the test class for the challenge 4 in a propper way. Here is my MaintenanceRequestHelper class. Here is the error I got: Challenge Not yet complete... here's what's wrong: The 'MaintenanceRequest' trigger did not achieve 100% code coverage via your test methods. Make sure to 'Run All' tests in the Developer Console at least once before attempting to verify this challenge. Can anyone help? I am new in Salesforce and I am not so clear with the testing methods yet. Thank you in Advance! public with sharing class MaintenanceRequestHelper { public static void updateWorkOrders

Join the discussion →

Not able to debug Azure Functions in Visual Studio Code

I am trying to do this tutorial to run azure function app using vs code. I am able to run it locally, but not debug it. When I browse to http://localhost:7071/api/category, I am getting the response. But I place a breakpoint(see the above image on line 11), it is supposed to stop, but does not. I see a difference in the image shown here in the docs with mine. Contrast to that, I see a square in my case (see below). Does this make a difference? Update Azure Function core tools are already installed. Still the problem Update 2 Its probably the version of Azure Function Core Tools At least with C

Join the discussion →

Simultaneously creating instance and class methods with the same name in a ruby class

Is there a way for me to simultaneously create a class and an instance method in a ruby class that have the same name? I have a version of this created in the class Foo class Foo def self.bar "hello world" end def bar self.class.bar end end While this works, is there a more elegant way of achieving this? Right now, I would have to duplicate ~10 methods as instance and class methods.

Join the discussion →

Set the configuration file using dataclass such that some variables can be mutable and some variables are immutable

I would like to write a configuration file for the AWS services e.g.: BucketName, job name, etc such that the file is configurable by the user if required. These are some of the works I have carried using the dataclasses. Setting the frozen=True to dataclass, all the variables are immutable. from dataclasses import dataclass @dataclass(frozen=True) class AWSConfiguration: bucket = {"bucket_name": "s3:///abc/"} jobqueue = {"job_def_name": "aws_service"} writing a value to variable of the class: AWSConfiguration().jobqueue = "a" It throws the following error: FrozenInstanceError: cannot assign t

Join the discussion →

Regex to match anything not between HTML brackets, and after matching another string

I have an HTML document which I need to match text in one block, and then match text in another block and put it into a capture group. I am using PCRE regex. The first match will be a static match and stay the same. In the first block this is >Match-Me-First< The second match to be put into a capture group will change. In the second block this is >put-me-into-capture-group< I have the regex to match anything between ><, but I do not know how to have it match Match-Me-First, and then to the negative lookahead to do the capture group. Regex to match anything between <>: (?![^<]*>)(\w+) First blo

Join the discussion →

React app hot-loader (auto-refresh) only works when starting the frontend/backend servers separately not using concurrently?

I'm building a react app where I seed data to a mongoDB database and again fetch that data from that database and render the data to the UI. In this case in the Paintings.js component. However when changes are made to this component the hot-load is activated a spinner is shown but after a few seconds the data is no longer visible in the UI. Only when manually refreshing the page. Sometimes there is this error: 'Proxy error: Could not proxy request /paintings from localhost:3000 to http://localhost:5000/' I'm running react 17.0.2, scripts 4.0.3 I reinstalled create-react-app, installed nodemon

Join the discussion →

Validation rule formula for empty picklist field

I am trying to define a set of actions for a user based on salesforce picklists. I have a main field called fHCM2__Reason__c that is a picklist containing multiple absence reason types - Sickness, Annual Leave etc I then have a related field called Annual_Leave_includes_a_trip_abroad__c that is a picklist with two possible options - Yes or No I want to define that if a user selects "Annual Leave" from the fHCM2__Reason__c picklist they cannot leave the field Annual_Leave_includes_a_trip_abroad__c blank and have to choose Yes or No. Currently I have the below: ISPICKVAL(fHCM2__Reason__c, "Annua

Join the discussion →

$wpdb DELETE SQL from root

I'm trying to delete transients from the db each day using a cron. I currently have this in a file in the root of my site: <?php include_once("wp-load.php"); global $wpdb; $wpdb->show_errors(); $wpdb->query("DELETE FROM `".$wpdb->prefix."options` WHERE `option_name` LIKE ('_transient_%')"); $wpdb->print_error(); ?> It does nothing and prints out this: WordPress database error: [] DELETE FROM 123_options WHERE option_name LIKE ('transient%') Any pointers?

Join the discussion →

How to add types to spread component props

Is it possible to ensure type safety with components that are composed of others? For example, if I want to build a special kind of input with certain validation, etc that should extend my base input. BaseInput.svelte <script lang="ts"> export let value = ''; // + a lot more props </script> <input bind:value ... /> AgeInput.svelte - this extends BaseInput <script lang="ts"> import BaseInput from './BaseInput.svelte' export let {...inputProps}: /* Can we spread and infer BaseInput props? */; </script> <BaseInput {...inputProps} type="number" /> Can we infer the BaseInput props?

Join the discussion →

Horizontal bars with stars realative to each pairwise comparison into boxplots

I'm trying reporting into the following plot some multiple pairwise comparison. In order to this I have just scripted down the following code p <- ggboxplot(data, x = "TREATMENT", y = "Feature1", color = "SESSION", palette = "npg", facet.by = "SESSION", short.panel.labs = FALSE) # Use only p.format as label. Remove method name. p + stat_compare_means( aes(label = paste0("p = ", ..p.format..)) )+ stat_compare_means(method = "t.test", label.y = 40)+ # Add global p-value stat_compare_means(aes(label = ..p.signif..), method = "t.test", ref.group = "TRT-A") Just by using the showing horizontal bars

Join the discussion →
Older stories