C dynamically growing array

I can use pointers, but I am a bit afraid of using them. If you need a dynamic array, you can’t escape pointers. Why are you afraid though? They won’t bite (as long as you’re careful, that is). There’s no built-in dynamic array in C, you’ll just have to write one yourself. In C++, you … Read more

Parsing JSON with Unix tools

There are a number of tools specifically designed for the purpose of manipulating JSON from the command line, and will be a lot easier and more reliable than doing it with Awk, such as jq: You can also do this with tools that are likely already installed on your system, like Python using the json module, and so … Read more

srand(time(0)) and random number generation

srand() gives the random function a new seed, a starting point (usually random numbers are calculated by taking the previous number (or the seed) and then do many operations on that number to generate the next). time(0) gives the time in seconds since the Unix epoch, which is a pretty good “unpredictable” seed (you’re guaranteed your seed … Read more

strcpy vs strdup

strcpy(ptr2, ptr1) is equivalent to while(*ptr2++ = *ptr1++) where as strdup is equivalent to (memcpy version might be more efficient) So if you want the string which you have copied to be used in another function (as it is created in heap section) you can use strdup, else strcpy is enough.

Pod status as `CreateContainerConfigError` in Minikube cluster

I am trying to run Sonarqube service using the following helm chart. So the set-up is like it starts a MySQL and Sonarqube service in the minikube cluster and Sonarqube service talks to the MySQL service to dump the data. When I do helm install followed by kubectl get pods I see the MySQL pod status as running, but the Sonarqube pos status shows as CreateContainerConfigError. I reckon … Read more

How to replace ” \ ” with ” \\ ” in java

Don’t use String.replaceAll in this case – that’s specified in terms of regular expressions, which means you’d need even more escaping. This should be fine: Note that the backslashes are doubled due to being in Java string literals – so the actual strings involved here are “single backslash” and “double backslash” – not double and quadruple. replace works on simple … Read more

How to run SQL script in MySQL?

I want to execute a text file containing SQL queries, in MySQL. I tried to run source /Desktop/test.sql and received the error: mysql> . \home\sivakumar\Desktop\test.sql ERROR: Failed to open file ‘\home\sivakumar\Desktop\test.sql’, error: 2 Any idea on what I am doing wrong?

anaconda/conda – install a specific package version

There is no version 1.3.0 for rope. 1.3.0 refers to the package cached-property. The highest available version of rope is 0.9.4. You can install different versions with conda install package=version. But in this case there is only one version of rope so you don’t need that. The reason you see the cached-property in this listing is because it contains the string “rope”: “cached-p rope erty” py35_0 means that you need python version 3.5 for this … Read more