hardhat ethers: deploy vs deployed

In following code: console.log("Deploying contract…."); const simpleStorage = await simpleStorageFactory.deploy(); await simpleStorage.deployed(); Line 2 deploys the contract and we get hold of it. Why do we need to call deployed method in Line3? >Solution : calling deploy() will create the transaction, and you can get the contract address immediately, however this does not mean the… Read More hardhat ethers: deploy vs deployed

Regex to not match more than one trailing slash in string

Looking for a regex to not match more than 1 occurrence of a trailing slash api/v1 /api/v1 /api/2v1/21/ /api/blah/v1/ /api/ether/v1// /api/23v1/// Expected match /api/v1 /api/2v1/21/ /api/blah/v1/ What I tried: ^\/([^?&#\s]*)(^[\/{2,}\s])$ >Solution : In the pattern that you tried, the second part of the pattern can not match, it asserts the start of the string ^… Read More Regex to not match more than one trailing slash in string

Spring boot rest requestbody and @valid not working when object is null/empty

I am trying to apply not null validation on an attribute of my request which is instructedAmount but it is not working. I have a Spring Boot (V2.3.0.RELEASE) application with the following endpoints: @Validated public class TestController { @PostMapping(value = "/test/pay") public ResponseEntity<IPSPaymentResponse> validatePayt(@Valid @RequestBody InstantPaymentRequest instantPaymentRequest) { log.debug("start validatePayment method {}", instantPaymentRequest); …. The… Read More Spring boot rest requestbody and @valid not working when object is null/empty

Python functions not running correctly

I’ve written this code to convert a string to uppercase and lowercase, however when I call my functions, it doesn’t run. # take the input for the string string = input("Enter any string: ") def string_upper(up): return up.upper() print("Uppercase Output: ", string_upper(string)) def string_lower(low): return low.lower() print("Lowercase Output: ", string.lower(string)) if __name__ == "__main__": string_upper(up)… Read More Python functions not running correctly

Check whether the string contains special characters Kotlin

I need a regex that checks whether a string contains the following characters ‘ " | \ / <> ; "Team’s<>".contains("/[\"’\\/\\\\<>;|]/;") val regex = Regex(pattern = "’.*’.*\".*\\|.*\\\\.*/.*<>", options = setOf(RegexOption.IGNORE_CASE)) regex.matches(input) >Solution : You could include all the characters you’re looking for in a simple character class and escape them. [\’\"\|\\\/\<\>;] If the regex finds… Read More Check whether the string contains special characters Kotlin