Categories
Linux Mastering Development

Editing a file based on a pattern appearance

I have a file that contains text and numbers like this: state(1, s(1,a), [s(1,b)]). state(1, s(1,b), [s(1,a)]). state(1, s(2,a), [s(2,b)]). state(1, s(2,b), [s(2,a)]). state(1, s(3,a), [s(3,b)]). state(1, s(3,b), [s(3,a)]). state(1, s(4,a), [t(1), t(2)]). state(1, s(5,a), [t(1), t(3)]). state(1, s(6,a), [s(6,b)]). state(1, s(6,b), [s(6,a)]). …so on I want the numbering with in s(x,y) to change as […]

Categories
Mastering Development

String comparison in Databricks Spark SQL

select distinct promo_name ,case when substring(promo_name,instr(promo_name, "P0"),2) = "P0" then 0 when substring(promo_name,instr(promo_name, "P1"),2) = "P1" then 1 When substring(promo_name,instr(promo_name, "P01"),3) = "P01" then 1 when substring(promo_name,instr(promo_name, "P2"),2) = "P2" then 2 When substring(promo_name,instr(promo_name, "P02"),3) = "P02" then 2 when substring(promo_name,instr(promo_name, "P3"),2) = "P3" then 3 when substring(promo_name,instr(promo_name, "P03"),3) = "P03" then 3 when substring(promo_name,instr(promo_name, […]

Categories
Mastering Development

How to use autoplot to label/ shade an area for the hours that correspond for each day for change point graph?

I have created series of change point graphs with the data specified by the Github source underneath the R code. For each graph (negative, neutral positive) shows a time length by hours, which differs somewhat, as I have removed data points less than 10% (in the "Percent" column). For negative it spans from the 5th […]

Categories
Mastering Development

R conditional loop to replace vallues

I am looking to conditionally replace values in a column and I think a loop is what I need. Though I know on a basic level how loops work, I have little experience using them so I struggle with wrapping my head around the order of operations. Using the dataframe df <- structure(list(player = c(“p1”, […]

Categories
Mastering Development

Replace underscore with white spaces and make the first letter of the name and the surname to upper case

i want to replace _ (underscore) with white spaces and make the first letter of the name and the surname to upper case while printing the nameList in searchKeyword method. #include <stdio.h> #include <stdlib.h> #include <string.h> void searchKeyword(const char * nameList[], int n, const char keyword[]) { int i,name=0; char *str; const char s[2] = […]

Categories
Development

Time difference in execution of MySQL joins

I had a queries in which there was left joins were used and it was taking 30 seconds to complete the execution and return the dataset on mysql terminal. But when I have changed it to join its execution time has been reduced significantly from 30 to 12 seconds. I know this is too much […]

Categories
Development

doesn’t compile code with Include AzureIoThub.h on esp8266 device

I’m trying to connect my esp8266 device to azure IOT hub, and from my understanding the way to go is to use the official AzureIoThub library (as distributed on library manager) but somewhy any code with this included library doesn’t compile. I get the following errors upon including the library. Arduino: 1.8.9 (Windows Store 1.8.21.0) […]

Categories
Development

alternate way to execute stored proc using simplejdbccall

Unable to execute a stored procedure by using named parameters. The SQL Server profiler for my execution showed a lengthy SQL including the null values. Is there any other way I can execute the stored procedure preferably using spring-jdbc which creates readable sql something similar to shown below under Expected? I tried to build SimpleJdbcCall […]

Categories
Development

Python pandas dataframe and list merging

I currently have a pandas DataFrame df: paper reference 2171686 p84 r51 3816503 p41 r95 4994553 p112 r3 2948201 p112 r61 2957375 p32 r41 2938471 p65 r41 … Here, each row of df shows the relationship of citation between paper and reference (where paper cites reference). I need the following numbers for my analysis: Frequency […]

Categories
Development

openmp benchmarking parallel computations

I’m trying to benchmark computing f(x) while varying the number of threads with every iteration. f(x) = c * ln(x) * cos(x) n=10000000 for (int pp = 2; pp<17; pp++) { p = pp; int chunk = n/p; //acts like floor omp_set_num_threads(p); double start_parallel = omp_get_wtime(); //start parallel #pragma omp parallel shared(tt,chunk) private (i) { […]