Using find command in bash script

Welcome to bash. It’s an old, dark and mysterious thing, capable of great magic. 🙂 The option you’re asking about is for the find command though, not for bash. From your command line, you can man find to see the options. The one you’re looking for is -o for “or”: That said … Don’t do this. Storage like this may work for simple … Read more

MIN and MAX in C

Where are MIN and MAX defined in C, if at all? They aren’t. What is the best way to implement these, as generically and type safe as possible (compiler extensions/builtins for mainstream compilers preferred). As functions. I wouldn’t use macros like #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)), especially if you plan to deploy your code. Either … Read more

Categories C

How do I create an array of strings in C?

If you don’t want to change the strings, then you could simply do When you do it like this you will allocate an array of two pointers to const char. These pointers will then be set to the addresses of the static strings “blah” and “hmm”. If you do want to be able to change the actual string content, … Read more

How to loop backwards in python?

range() and xrange() take a third parameter that specifies a step. So you can do the following. Which gives But for iteration, you should really be using xrange instead. So, Note for Python 3 users: There are no separate range and xrange functions in Python 3, there is just range, which follows the design of Python 2’s xrange.

Pytorch tensor to numpy array

There are 4 dimensions of the tensor you want to convert. : means that the first dimension should be copied as it is and converted, same goes for the third and fourth dimension. ::-1 means that for the second axes it reverses the the axes