Quantcast
Channel: User Karthik T - Stack Overflow
Browsing latest articles
Browse All 40 View Live

Comment by Karthik T on What does #x inside a C macro mean?

@DrewBuckley fixed!

View Article



Comment by Karthik T on How to install curl 7.34 or later on Amazon linux old...

One option seems to be the city-fan repo found in other answers, which is warned against by redhat.

View Article

Comment by Karthik T on Passing an array to the Javascript Date constructor,...

This is awesome! Works natively atleast in FFox

View Article

Comment by Karthik T on ansible wget then exec scripts => get_url equivalent

Agree with drew, this is not a solution.

View Article

Comment by Karthik T on In ansible what is the best way to manage Global and...

Looks very promising, I can use "all" as a default value i guess, but I was wondering if there was a more "Ansible" way in defining variables.

View Article


Comment by Karthik T on ERROR: While executing gem ... (TypeError)...

This helped, I had gemcutter.org setup, removing which my problem went away

View Article

Comment by Karthik T on Could not find iPhone 6 simulator after upgrade to...

This was my issue as well

View Article

Comment by Karthik T on How to specify test directory for mocha?

At the risk of getting banned from stack overflow.. WHAT THE F*#K... I suddenly have 60 failures :D

View Article


Comment by Karthik T on Postman - How can I pass array as variable

I had a slightly related issue, of trying to pass a array from a pre request script via pm.variables.set. I solved it by doing JSON.stringify on the array, seems to work!

View Article


Comment by Karthik T on What's the best way to get device locale in react...

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 Article

Comment by Karthik T on What's the best way to get device locale in react...

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 Article

Comment by Karthik T on How to group by count in array without using loop

Cleaner and easier to understand than the accepted answer.

View Article

Answer by Karthik T for Combining C++ standard algorithms by looping only once

After better understanding your question, I have got an idea that might work, but requires Boost.You could use a transform_iterator which calls toupper on all characters and use that as the...

View Article


Overriding a hash and making [] operators private - cant use ||= anymore

Test code:class PrivHash < Hash def set(key, val) self[key] = val end def set_maybe(key, val) self[key] ||= val end private def []= key, value end def [] key super endendWith this code, I expect...

View Article

Validates presense vs null false in Rails models/tables

I was playing around with Rails admin and I noticed something. Attributes which are defined as below in model, counted as "Required" in Rails admin validates :user, presence: trueHowever, attributes...

View Article


Answer by Karthik T for Ruby beginner needs a hand

The method add_two_numbers is not defined on the class Calc, however you are using it as if it is. This is the problem.I would presume you got a NoMethodError.Update: As pointed out in the comments, in...

View Article

Google tag manager and Google Enhanced Ecomerce tracking

This is mostly just a philosophical question.I am looking at integrating GTM and implementing Enhanced ecommerce tracking with it, and the more I look at it, the more I feel like these two are fighting...

View Article


Answer by Karthik T for SSH config file setup with wildcards and DRY

On top of figuring out why the config was "breaking", I discovered a new directive Match. This lets me do what I intendHost shortname1? Hostname %h.prod.xyz.comHost test-myname Hostname...

View Article

SSH config file setup with wildcards and DRY

My requirements are as followsAll of our cloud machines need the same config (User, Port, IdentityFile)I need these settings to be applied to them based on domain (*.xyz.com)I also need these settings...

View Article

When should variables be quoted in GTM custom html tag?

I am trying to implement facebook pixel via GTM, and I am hitting a few oddities. I am implementing via custom html tag, and If i dont quote the variables, the gtm debugger shows them as...

View Article

Answer by Karthik T for Why would I pass function parameters by value in C?

Please refer to Passing by reference in C. Pass by reference is a misnomer in C. It refers to passing the address of a variable instead of the variable, but you are passing a pointer to the variable by...

View Article


Answer by Karthik T for Why doesn't const A & bind to A() in template arguments?

Possible duplicate of Non-type template parametersThese are the rules of template non type parametersA non-type template-parameter shall have one of the following (optionally cv-qualified)...

View Article


Answer by Karthik T for How to check if a string is numeric?

Many options explored at http://www.coderanch.com/t/405258/java/java/String-IsNumericOne more is public boolean isNumeric(String s) { return s != null && s.matches("[-+]?\\d*\\.?\\d+"); } Might...

View Article

Answer by Karthik T for Lambda vs Proc in terms of memory and efficiency

The differences between Proc and lambda are mostly behavior related, and are answered better by Abraham and is also found hereThe old answer talked about how Block is faster than lambda as explained...

View Article

In ansible what is the best way to manage Global and groupwise vars [closed]

Currently my playbook to create user accounts and - name: Create the necessary users hosts: all become: yes vars: users: - name: user1 ssh_keys: - XXXXX - name: user2 ssh_keys: - YYYYY users_to_remove:...

View Article


Answer by Karthik T for Check if string is a punctuation character

Do you want to check more punctuations other than just .?If so you can do this.String punctuations = ".,:;";//add all the punctuation marks you want....if(punctuations.contains(letter[a]))

View Article

Answer by Karthik T for Function arguments like printf in C

You need to define a function with variable arguments, and use vsprintf to build the string.

View Article

Answer 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

Answer 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 Article



Answer 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 Article

Bounded 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article


Answer 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 Article

Returning 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 Article

Answer 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 Article
Browsing latest articles
Browse All 40 View Live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>