Pip wont let me install user local packages with --user any more, shows...
I have used --user in the past to not have to deal with virtualenvs in the past, but I cant seem to do it now, presumably on a different python version..$ pip install --user esphomeerror:...
View ArticleComment by Karthik T on How to get device locale in react native (iOS)?
As of ios 14, both AppleLocale and AppleLanguages seem to be defined. Would recommend picking AppleLanguages first now, since that supports the app specific prefered languages feature. and use optional...
View ArticleComment by Karthik T on How to get device locale in react native (iOS)?
As of ios 14, both AppleLocale and AppleLanguages seem to be defined. Would recommend picking AppleLanguages first now, since that supports the app specific prefered languages feature. and use optional...
View ArticleWhy is git autosquash not working as expected? [closed]
UpdateMy company adds a prefix to the commit history which i had gotten so used to, I didn't see it but of course git would, and that was causing the issue. Removing that prefix fixed my...
View ArticleAnswer by Karthik T for Why is git autosquash not working as expected?
It is likely my companies hook that adds a prefix to the commit message.Edit: Leaving this here.. My company adds a prefix to the commit history which i had gotten so used to, i didnt see it but of...
View ArticleAnswer by Karthik T for Implications of using "auto" to iterate over a C++...
This code uses 2 new features from C++11 standard the auto keyword, for type inference, and the range based for loop.Using just auto this can be written as (thanks Ben)for (auto it=mymap.begin();...
View ArticleAnswer by Karthik T for Perl - How to suppress output from a forked child...
perl -e 'exec("ls >/dev/null")'Works for me atleast. Trying 2>&1This convoluted mess works as wellperl -e 'exec("ls >&2 2>&1 1>/dev/null")'Even this works, thought it...
View ArticleAnswer by Karthik T for Speed up SQL statement to find condition parameter...
If you are using a prepared statement, I believe you can move the preparation step out of the loop to make it much faster.sql = 'select count(*) from (select 1 from emp where salary<=? limit ?)'#...
View ArticleReturning multiple values in Ruby, to be used to call a function
Is it possible to return multiple values from a function?I want to pass the return values into another function, and I wonder if I can avoid having to explode the array into multiple valuesMy problem?I...
View ArticleAnswer by Karthik T for How to iterate over a C++ STL map data structure...
This code uses 2 new features from C++11 standard the auto keyword, for type inference, and the range based for loop.Using just auto this can be written as (thanks Ben)for (auto it=mymap.begin();...
View ArticleAnswer by Karthik T for assigning derived class pointer to base class pointer...
If you are adamant that this function should NOT be a part of base, you have but 2 options to do it.Either use a pointer to derived classderived* pDerived = new derived();pDerived->myFunc();Or...
View ArticleAnswer by Karthik T for How to find the intersection of two STL sets?
You haven't provided an output iterator for set_intersectiontemplate <class InputIterator1, class InputIterator2, class OutputIterator>OutputIterator set_intersection ( InputIterator1 first1,...
View ArticleAnswer by Karthik T for How to create change listener for variable?
This is one of the many reasons to hide variables behind setter/getter pairs. Then, in the setter you can notify your listener that this variable has been modified in the appropriate way. As the others...
View ArticleAnswer by Karthik T for Pass array by reference in Java
This might be an unpopular way of thinking about it, but being from a C/C++ side myself, it made it easier for me.In Java, objects are reference types. Meaning that the actual object is on the heap...
View ArticleAnswer by Karthik T for Why can't I reinterpret_cast uint to int?
From C++11 Standard(N3376) 5.2.10.1 this document, page 101:Conversions that can be performed explicitly using reinterpret_cast are listed below. Noother conversion can be performed explicitly using...
View ArticleAnswer by Karthik T for How to install and use log4perl?
The typical way to install packages for perl is to use cpan or its variations (cpanm, cpanp, etc). If it is packaged by your distro thats easier/faster, but if it is not, you would still be able to do...
View ArticleBounded Type Parameters in C++, any reason for the lack of it?
Java and I guess C#(and others) support Bounded Type Parameters which lets us restrict what types may be used in template classes/functions. I am curious if there is a reason, official or otherwise,...
View ArticleAnswer by Karthik T for Write the definition of a function, isReverse
The return value is wrong because you are checking only 1 value from each array, not all of them. What you want to do is something like this.for (i=0;i<size;i++){ if(!(array1[i] ==...
View ArticleAnswer by Karthik T for Why is dynamic_cast evil or not ? Should I use...
This is EXACTLY the wrong place to use dynamic_cast. You should be using polymorphism. Each of the Animal classes should have a virtual function, say, process and here you should just call...
View ArticleAnswer by Karthik T for how to call same module method as instance method and...
I cant imagine this is a good design.. but you can try to both include and extend the module into the class. include adds the methods as instance methods and...
View Article