How to pause / sleep thread or process in Android?

One solution to this problem is to use the Handler.postDelayed() method. Some Google training materials suggest the same solution. @Override public void onClick(View v) { my_button.setBackgroundResource(R.drawable.icon); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { my_button.setBackgroundResource(R.drawable.defaultcard); } }, 2000); } However, some have pointed out that the solution above causes a … Read more

127 Return code from $?

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn’t understand your command, because it doesn’t know where to find the binary you’re trying to call.

How to start a background process in Python?

While jkp’s solution works, the newer way of doing things (and the way the documentation recommends) is to use the subprocess module. For simple commands its equivalent, but it offers more options if you want to do something complicated. Example for your case: import subprocess subprocess.Popen([“rm”,”-r”,”some.file”]) This will run rm -r some.file in the background. … Read more

Visual Studio “Could not copy” …. during build

I have encountered similar error messages in Visual Studio 2013. Mostly, I have found that this situation has occurred when a debug process was halted because of an exception. When clean+build has not resolved this problem for me, I have had success by doing the following: Closing Visual Studio Deleting the bin and obj folders, … Read more

How do I execute a command and get the output of the command within C++ using POSIX?

#include <cstdio> #include <iostream> #include <memory> #include <stdexcept> #include <string> #include <array> std::string exec(const char* cmd) { std::array<char, 128> buffer; std::string result; std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, “r”), pclose); if (!pipe) { throw std::runtime_error(“popen() failed!”); } while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { result += buffer.data(); } return result; } Pre-C++11 version: #include <iostream> #include <stdexcept> #include … Read more

How do I run a node.js app as a background service?

Copying my own answer from How do I run a Node.js application as its own process? 2015 answer: nearly every Linux distro comes with systemd, which means forever, monit, PM2, etc are no longer necessary – your OS already handles these tasks. Make a myapp.service file (replacing ‘myapp’ with your app’s name, obviously): [Unit] Description=My … Read more

How to wait in bash for several subprocesses to finish, and return exit code !=0 when any subprocess ends with code !=0?

[*] wait also (optionally) takes the PID of the process to wait for, and with $! you get the PID of the last command launched in the background. Modify the loop to store the PID of each spawned sub-process into an array, and then loop again waiting on each PID. # run processes and store … Read more

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