git pull remote branch cannot find remote ref

Be careful – you have case mixing between local and remote branch! Suppose you are in local branch downloadmanager now (git checkout downloadmanager) You have next options: Specify remote branch in pull/push commands every time (case sensitive):git pull origin DownloadManagerorgit pull origin downloadmanager:DownloadManager Specify tracking branch on next push:git push -u origin DownloadManager(-u is a short form of –set-upstream)this will persist downloadmanager:DownloadManager link … Read more

write() to stdout and printf output not interleaved?

Printf is buffered. You can force printf to ‘flush’ its buffer using the fflush call: In general, printf() being buffered is a good thing. Unbuffered output, particularly to visible consoles that require screen updates and such, is slow. Slow enough that an application that is printf’ing a lot can be directly slowed down by it (especially on … Read more

compilation error: identifier expected

You have not defined a method around your code. In this case, I have assumed that you want your code to be executed in the main method of the class. It is, of course, possible that this code goes in any other method.

Javascript – Track mouse position

The mouse’s position is reported on the event object received by a handler for the mousemove event, which you can attach to the window (the event bubbles): (Note that the body of that if will only run on old IE.) Example of the above in action – it draws dots as you drag your mouse over the page. (Tested on IE8, IE11, … Read more

Unity – How to stop Play Mode in case of infinite loop?

I just got into this situation: accidental infinite loop, stuck in play mode on a scene with unsaved work, Unity unresponsive. But I was lucky enough to have Monodevelop open, even though I was mainly using Sublime for scripting. I pressed the button to start debugging near the top left of the Monodevelop window, then … Read more

How to pass a list by reference?

Lists are already passed by reference, in that all Python names are references, and list objects are mutable. Use slice assignment instead of normal assignment. However, this isn’t a good way to write a function. You should simply return the combined list.

Displaying contents of a vector container in C++

There is an idiomatic way for printing a vector out. This way is safe and doesn’t require you to keep track of the vectors size or anything like that. It is also easily recognisable to other C++ developers. This method works on other container types too that do not allow random access. This works both … Read more