Categories
Development

Developing a number guessing game

I’m supposed to randomize numbers between 10 – 20, depending on what the user chooses. The user is then supposed to guess the number that’s been randomized. The program is supposed to tell the user if he/she’s close or not. It’s also supposed to start again when the “ However I have no idea how […]

Categories
Development

In Vault identify host to which particular lease id is related to, when multiple lease id’s are present

I am testing vault authentication using AppRole auth method, for the dockerhub login from multiple servers. when multiple servers authenticate against vault & get their respective leases for the token, now i need to know which lease id is related to what host, so that whenever i wanted to revoke a lease for particular server, […]

Categories
Development

C# Moving selected mail items to external directory

Can anyone provide an example of how to move selected inbox items to an external directory on the computer for example C:/Mails I am not able to get the function to run after I have selected the mails into a folder on button click I have tried the following code but i am not able […]

Categories
C++ Development

Better alternatives to assert(false) in C/C++

Currently, I write assert(false); at places that my code is never supposed to reach. One example, in a very C-ish style, is: int findzero( int length, int * array ) { for( int i = 0; i < length; i++ ) if( array[i] == 0 ) return i; assert(false); } My compiler recognizes that the […]

Categories
Development

Find occurrences where a comma is separated by numbers using regex

I need to find occurrences where a comma is separated by a number on either side. For example: SampleString =’A,B,C, 1, 2, 3, 4, G’ I need to replace the commas with all space before and after comma with just a comma(no space). I need to do this only if the comma is separating numbers. […]

Categories
Development

Given a condition, modify values of a dataframe

I have a dataframe that contains codes with one letter and three digits maximum, ex: A478. Some codes only have one or two digits, but I need to put a point before all values that have three digits, to transform them in the form: A213 to A21.3 In short, I need to transform the df […]

Categories
Development

Persistent error… “The connection was not closed. The connection’s current state is open.”

I am trying to run the code behind a button in a WPF application that “updates” the employee information in the SQL Server database from the forms checkboxes and textboxes. I keep getting the error at the line “command.ExecuteNonQuery();” that the connection state isn’t closed, but I have tried everything. I’ve changed and added connection.Open(); […]

Categories
Development

Unit testing an async method containing a Timer

In .NET Core, background tasks are implemented as IHostedService. This is my hosted service: public interface IMyService { void DoStuff(); } public class MyHostedService : IHostedService, IDisposable { private const int frequency; private readonly IMyService myService; private Timer timer; public MyHostedService(IMyService myService, Setting s) { this.myService = myService; frequency = s.Frequency; } public void Dispose() […]

Categories
Development

Why can’t Eclipse find my ModuleA from within my ModuleB

I’m using Eclipse 20190614-1200, with gradle 5.6.2. I have several projects in my Eclipse workspace, each with their own module. They were all imported from a gradle (5.6.2) project with a subproject for each module. They’re generally in a foo.bar.<something> package, where the something varies as one would expect. package foo.bar.baz; // from module foo.bar.qux […]

Categories
Development

Running raw update query of mongo with mongoTemplate

I’m trying to update fields of embedded documents. Object that I want to update is “product” with “_id” : “5d7897cebc8ea8463c3e8d99” (deepest object in structure below in both “modifiers.values” objects: “modifiers[0].values[1].product.code” and “modifiers[1].values[2].product.code”). Let’s say to change “product.code” from “444” to “000000”. Running query with db shell is successfull, but with mongoTemplate it fails. This is […]