Is it possible to insert into two tables at the same time?
In one statement: No. In one transaction: Yes BEGIN TRANSACTION DECLARE @DataID int; INSERT INTO DataTable (Column1 …) VALUES (….); SELECT @DataID = scope_identity(); INSERT INTO LinkTable VALUES (@ObjectID, @DataID); COMMIT The good news is that the above code is also guaranteed to be atomic, and can be sent to the server from a client … Read more
PRE-2016 Valgrind: Still Reachable Leak detected by Valgrind
There is more than one way to define “memory leak”. In particular, there are two primary definitions of “memory leak” that are in common usage among programmers. The first commonly used definition of “memory leak” is, “Memory was allocated and was not subsequently freed before the program terminated.” However, many programmers (rightly) argue that certain … Read more
How to check if a Docker image with a specific tag exists locally?
I usually test the result of docker images -q (as in this script): if [ -z “$(docker images -q myimage:mytag 2> /dev/null)” ]; then # do something fi On Powershell (comment from Garret Wilson): if (!(docker images -q myimage:mytag 2> $null)) { # do something } But since docker images only takes REPOSITORY as parameter, … Read more
C++11 std::thread vs Posix threads
If you want to run code on many platforms, go for Posix Threads. They are available almost everywhere and are quite mature. On the other hand if you only use Linux/gcc std::thread is perfectly fine – it has a higher abstraction level, a really good interface and plays nicely with other C++11 classes. The C++11 … Read more
Replace carets with HTML superscript markup using Java
str.replaceAll(“\\^([0-9]+)”, “<sup>$1</sup>”);
How to remove leading and trailing rendered as white spaces from a given HTML string? [closed]
See the String method trim() – https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim var myString = ‘ bunch of <br> string data with<p>trailing</p> and leading space ‘; myString = myString.trim(); // or myString = String.trim(myString); Edit As noted in other comments, it is possible to use the regex approach. The trim method is effectively just an alias for a regex: if(!String.prototype.trim) … Read more
Delete all documents from index without deleting index
I believe if you combine the delete by query with a match all it should do what you are looking for, something like this (using your example): curl -XDELETE ‘http://localhost:9200/twitter/tweet/_query’ -d ‘{ “query” : { “match_all” : {} } }’ Or you could just delete the type: curl -XDELETE http://localhost:9200/twitter/tweet Note: XDELETE is deprecated for … Read more