Categories
Mastering Development

Azure Storage Blobs client library for .NET causing memory leak on Linux

We have a service that generates messages and writes them to an append blob, this works fine on windows machine, but the same code published and running on a linux machine will cause a memory leak on the process even though the actual memory consumed is very small (by printing GC.GetTotalMemory). I have created a […]

Categories
Mastering Development

Count in reduceByKey function in spark

I am trying to find count per id. My code is: final JavaDStream<ConsumerRecord<String, String>> stream = KafkaUtils.createDirectStream(javaStreamingContext, LocationStrategies.PreferConsistent(), ConsumerStrategies.<String, String>Subscribe(topics, kafkaParams)); stream.map(record -> record.value()) .mapToPair(new PairFunction<String, Integer, String>() { private static final long serialVersionUID = -5130418696584666474L; @Override public Tuple2<Integer, String> call(String t) throws Exception { // TODO Auto-generated method stub return new Tuple2<Integer, String>(Integer.parseInt(t.split(“,”)[0]), t.split(“,”)[1]); […]

Categories
Mastering Development

Capitalize each individual letter in a word and return on a new line in Python

I’m having some trouble iterating through a word and trying to capitalize each individual letter to be returned on a new line. How would I go about doing this? Example: Enter a word: hello Output: Hello hEllo heLlo helLo hellO

Categories
Mastering Development

select columns based on row values of another dataset

So I have two dataframes dfA and dfB. I want to select several columns of dfA based on the rows in dfB. This is how my dfA looks like: index abandoned dismiss yes train tram go 0 0.5 9.1 1.4 2.5 2.5 5.6 1 2.4 3.2 1.8 4.9 9.3 3.2 2 1.5 5.7 3.9 2.1 […]

Categories
Mastering Development

Best way to generate JSON dynamically

I am testing REST APIs. Each API consumers the different type of JSON payload. I don’t want to fill all input manually. So, I want to generate JSON dynamically (e.g. read values from a text file and fill in JSON structure) and then pass the generated JSON as Request Body in API. What is the […]

Categories
Mastering Development

Writing log in file and display it on console at the same time

here is my logback-spring.xml file: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <appender name=”DEBUG_FILE” class=”ch.qos.logback.core.rolling.RollingFileAppender”> <filter class=”ch.qos.logback.classic.filter.ThresholdFilter”> <level>DEBUG</level> </filter> <file>./target/log/app-debug.log</file> <rollingPolicy class=”ch.qos.logback.core.rolling.TimeBasedRollingPolicy”> <fileNamePattern>./log/target/app-debug.log-%d.gz</fileNamePattern> <maxHistory>7</maxHistory> </rollingPolicy> <encoder> <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{32} – %msg%n</pattern> </encoder> </appender> <appender name=”ERROR_FILE” class=”ch.qos.logback.core.rolling.RollingFileAppender”> <filter class=”ch.qos.logback.classic.filter.ThresholdFilter”> <level>ERROR</level> </filter> <file>./target/log/app-error.log</file> <rollingPolicy class=”ch.qos.logback.core.rolling.TimeBasedRollingPolicy”> <fileNamePattern>./target/log/app-error.log-%d.gz</fileNamePattern> <maxHistory>7</maxHistory> </rollingPolicy> <encoder> <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{32} – %msg%n</pattern> </encoder> </appender> <root level=”DEBUG”> […]

Categories
Mastering Development

Why doesn’t this code work for deleting a node in C/C++

struct node{ int elem ; node* next; }; typedef node* list; void RemoveAll(int x, list&l){ list copy = l; list q; while (l != NULL){ if (l -> elem == x){ q = l; l = l -> next; delete q; } else l = l -> next; } l = copy; } I would […]

Categories
Mastering Development

Why putStrLn of zio didn’t output

Why putStrLn in flatMap followed by a result statement didn’t get effectively write to stdout? object Mgr extends App { def main1(args: Array[String]) = getStrLn.flatMap { s => putStrLn(s) // Why this did not write to console? UIO.succeed(s) } override def run(args: List[String]): URIO[zio.ZEnv, Int] = main1(Array()).fold(_ => 1, { x => println(x) // only […]

Categories
Mastering Development

sending keys to a difficult element in selenium (Python)

I’m using selenium. The source code of the element is: <input tabindex=”5″ class=”buttonStyle” onclick=”submitForm(‘SEARCH’,”);return false” type=”submit” value=”Search”> The code I use: driver.find_element_by_xpath(“//input[@type=’submit’]”).click(); I used the XPATH checker on internet explorer (the favourite page named MRI). It shows the target element. However the above code does not work. I’m using Jupyter Notebook, Selenium and Internet Explorer […]

Categories
Mastering Development

if statement string checking with casefold python

This is a simple program to check how old you are but I don’t understand why it’s not working. I know it’s something to do with the .casefold(), because when I take it out it works, but I don’t want to have to add an if statement for every single capitalization possibility for each month. […]