How to concatenate a std::string and an int

In alphabetical order: std::string name = “John”; int age = 21; std::string result; // 1. with Boost result = name + boost::lexical_cast<std::string>(age); // 2. with C++11 result = name + std::to_string(age); // 3. with FastFormat.Format fastformat::fmt(result, “{0}{1}”, name, age); // 4. with FastFormat.Write fastformat::write(result, name, age); // 5. with the {fmt} library result = fmt::format(“{}{}”, … Read more

Pandas Merging 101

This post aims to give readers a primer on SQL-flavored merging with Pandas, how to use it, and when not to use it. In particular, here’s what this post will go through: The basics – types of joins (LEFT, RIGHT, OUTER, INNER) merging with different column names merging with multiple columns avoiding duplicate merge key … Read more

StringBuilder vs String concatenation in toString() in Java

Version 1 is preferable because it is shorter and the compiler will in fact turn it into version 2 – no performance difference whatsoever. More importantly given we have only 3 properties it might not make a difference, but at what point do you switch from concat to builder? At the point where you’re concatenating … Read more

How to extend an existing JavaScript array with another array, without creating a new array

The .push method can take multiple arguments. You can use the spread operator to pass all the elements of the second array as arguments to .push: >>> a.push(…b) If your browser does not support ECMAScript 6, you can use .apply instead: >>> a.push.apply(a, b) Or perhaps, if you think it’s clearer: >>> Array.prototype.push.apply(a,b) Please note … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)