This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stackoverflow.com/questions/692000/how-do-i-write-stderr-to-a-file-while-using-tee-with-a-pipe | |
command_to_execute 2>&1 | tee -a log | |
# in bash 4 | |
command_to_execute |& tee -a log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DisplayError(LPTSTR lpszFunction) | |
// Routine Description: | |
// Retrieve and output the system error message for the last-error code | |
{ | |
LPVOID lpMsgBuf; | |
LPVOID lpDisplayBuf; | |
DWORD dw = GetLastError(); | |
FormatMessage( | |
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Timing.h" | |
double Timing::getEllipsedMilliseconds() | |
{ | |
if (m_running) | |
{ | |
setToCurrentTime(m_endTime); | |
} | |
return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(m_endTime - m_startTime).count()) / 1000000.0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iomanip> | |
#include <ctime> | |
void PrintLocalTime() | |
{ | |
std::tm tmNow; | |
std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); | |
time_t t = std::chrono::system_clock::to_time_t(now); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://qt.gitorious.org/qt-creator/qt-creator/source/1a37da73abb60ad06b7e33983ca51b266be5910e:src/app/main.cpp#L13-189 | |
// taken from utils/fileutils.cpp. We can not use utils here since that depends app_version.h. | |
static bool copyRecursively(const QString &srcFilePath, | |
const QString &tgtFilePath) | |
{ | |
QFileInfo srcFileInfo(srcFilePath); | |
if (srcFileInfo.isDir()) { | |
QDir targetDir(tgtFilePath); | |
targetDir.cdUp(); | |
if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xset dpms force off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chardet | |
chardet.detect('something中文Chinese') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## from http://askubuntu.com/questions/9135/best-way-to-backup-all-settings-list-of-installed-packages-tweaks-etc | |
dpkg --get-selections > ~/Package.list | |
sudo cp /etc/apt/sources.list ~/sources.list | |
sudo apt-key exportall > ~/Repo.keys | |
rsync --progress /home/`whoami` /path/to/user/profile/backup/here | |
## Reinstall now | |
rsync --progress /path/to/user/profile/backup/here /home/`whoami` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtGui/QApplication> | |
#include <QtGui/QPushButton> | |
#include <QtGui/QWidget> | |
#include <QtGui/QSpinBox> | |
#include <QtGui/QSlider> | |
#include <QtGui/QHBoxLayout> | |
int main(int argc, char *argv[]) | |
{ | |
QApplication a(argc, argv); |