Query comparing dates in SQL

Instead of ‘2013-04-12’ whose meaning depends on the local culture, use ‘20130412’ which is recognized as the culture invariant format. If you want to compare with December 4th, you should write ‘20131204’. If you want to compare with April 12th, you should write ‘20130412’. The article Write International Transact-SQL Statements from SQL Server’s documentation explains how to … Read more

Check if a string contains another string

Use the Instr function will return 15 in pos If not found it will return 0 If you need to find the comma with an excel formula you can use the =FIND(“,”;A1) function. Notice that if you want to use Instr to find the position of a string case-insensitive use the third parameter of Instr and give it the const vbTextCompare (or just … Read more

Pull request vs Merge request

 Answer recommended by GitLab GitLab’s “merge request” feature is equivalent to GitHub’s “pull request” feature. Both are means of pulling changes from another branch or fork into your branch and merging the changes with your existing code. They are useful tools for code review and change management. An article from GitLab discusses the differences in naming the feature: Merge or pull requests … Read more

What does the “as” keyword do?

That is not vanilla JavaScript, it is TypeScript. As any means consider the typed object as a plain untyped JavaScrpt object. The as keyword is a Type Assertion in TypeScript which tells the compiler to consider the object as another type than the type the compiler infers the object to be.

A warning – comparison between signed and unsigned integer expressions

It is usually a good idea to declare variables as unsigned or size_t if they will be compared to sizes, to avoid this issue. Whenever possible, use the exact type you will be comparing against (for example, use std::string::size_type when comparing with a std::string‘s length). Compilers give warnings about comparing signed and unsigned types because the ranges of signed and unsigned ints … Read more

Angular-ui-router: ui-sref-active and nested states

Instead of this- You can do this- Currently it doesn’t work. There is a discussion going on here (https://github.com/angular-ui/ui-router/pull/927) And, it will be added soon. UPDATE: For this to work, $state should be available in view. More Info UPDATE [2]: As of version 0.2.11, it works out of the box. Please check the related issue: https://github.com/angular-ui/ui-router/issues/818

Python reshape list to ndim array

You can think of reshaping that the new shape is filled row by row (last dimension varies fastest) from the flattened original list/array. An easy solution is to shape the list into a (100, 28) array and then transpose it: Update regarding the updated example:

gpg: no valid OpenPGP data found

This problem might occur if you are behind corporate proxy and corporation uses its own certificate. Just add “–no-check-certificate” in the command. e.g. wget –no-check-certificate -qO – http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add – It works. If you want to see what is going on, you can use verbose command instead of quiet before adding “–no-check-certificate” option. … Read more

How to overcome “datetime.datetime not JSON serializable”?

Updated for 2018 The original answer accommodated the way MongoDB “date” fields were represented as: {“$date”: 1506816000000} If you want a generic Python solution for serializing datetime to json, check out @jjmontes’ answer for a quick solution which requires no dependencies. As you are using mongoengine (per comments) and pymongo is a dependency, pymongo has built-in utilities to help … Read more