What is the difference between lock, mutex and semaphore?
A lock allows only one thread to enter the part that’s locked and the lock is not shared with any other processes. A mutex is the same as a lock but it can be system wide (shared by multiple processes). A semaphore does the same as a mutex but allows x number of threads to enter, this … Read more
Undo a Git merge that hasn’t been pushed yet
With git reflog check which commit is one prior the merge (git reflog will be a better option than git log). Then you can reset it using: There’s also another way: It will get you back 1 commit. Be aware that any modified and uncommitted/unstashed files will be reset to their unmodified state. To keep them either stash changes … Read more
TypeError: ‘list’ object is not callable while trying to access a list
For accessing the elements of a list you need to use the square brackets ([]) and not the parenthesis (()). Instead of: you need to use: And instead of: you need to use:
Why in C++ do we use DWORD rather than unsigned int? [duplicate]
DWORD is not a C++ type, it’s defined in <windows.h>. The reason is that DWORD has a specific range and format Windows functions rely on, so if you require that specific range use that type. (Or as they say “When in Rome, do as the Romans do.”) For you, that happens to correspond to unsigned int, but that might not … Read more
List of All Locales and Their Short Codes?
The importance of locales is that your environment/os can provide formatting functionality for all installed locales even if you don’t know about them when you write your application. My Windows 7 system has 211 locales installed (listed below), so you wouldn’t likely write any custom code or translation specific to this many locales. Edit: The … Read more
How do I pause my shell script for a second before continuing?
Use the sleep command. Example: One can also employ decimals when specifying a time unit; e.g. sleep 1.5s
Why has the int32 type a maximum value of 2³¹ − 1? [duplicate]
Possible Duplicate:What is “2’s Complement”? I know int32 has a length of 32 bits (4 bytes). I assume it has 2³² values but as half of them must be under zero, I guess it has something to do with this. I would like to know why exactly int32 has max. positive number 2³¹ − 1.
What throws an IOException in Java?
Assume you were: Reading a network file and got disconnected. Reading a local file that was no longer available. Using some stream to read data and some other process closed the stream. Trying to read/write a file, but don’t have permission. Trying to write to a file, but disk space was no longer available. There … Read more
Arduino Sketch upload issue – avrdude: stk500_recv(): programmer is not responding
I had this problem with a Crowduino, running the Arduino IDE on OS X. The solution for me was to switch on verbose output during upload (in the Arduino IDE preferences pane). Then, when uploading, you can see AVRDUDE sending three packets avrdude: Send: 0 [30] [20] (with corresponding RX flashes on the board) right before the avrdude: ser_recv(): programmer is … Read more