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
#!/bin/bash | |
# create directories | |
rm -rf /tmp/ghost-backup | |
rm /tmp/ghost-backup*.tar.gz | |
mkdir -p /tmp/ghost-backup/ | |
mkdir -p /tmp/ghost-backup/etc/ | |
mkdir -p /tmp/ghost-backup/etc/nginx/ | |
mkdir -p /tmp/ghost-backup/usr/local/etc/ | |
mkdir -p /tmp/ghost-backup/var/www/ghost/content/ |
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
/* | |
* checksum.c | |
*/ | |
#include "checksum.h" | |
unsigned char do_checksum(const unsigned char *buf, size_t count) | |
{ | |
unsigned char checksum = 0; | |
size_t i; |
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
// Open image | |
CString FilePathName; | |
CFileDialog dlg(TRUE);///TRUE为OPEN对话框,FALSE为SAVE AS对话框 | |
if (dlg.DoModal() == IDOK) { | |
FilePathName = dlg.GetPathName(); | |
GetDlgItem(IMAGE_FILENAME)->SetWindowText(FilePathName); | |
CT2CA pszConvertedAnsiString(FilePathName); | |
cv::Mat img = cv::imread(std::string(pszConvertedAnsiString), | |
CV_LOAD_IMAGE_UNCHANGED); |
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
// this is slow | |
boost::asio::ip::tcp::resolver resolver1(io_); | |
auto endpoint_iterator1 = resolver1.resolve({ "8.8.8.8", "53" }); | |
boost::asio::connect(socket_, endpoint_iterator1); | |
// this is faster | |
boost::asio::ip::tcp::resolver::query q(boost::asio::ip::tcp::v4(), | |
"8.8.8.8", | |
"53"); | |
auto endpoint_iterator2 = resolver2.resolve(q); |
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
sudo gdisk /dev/sdc | |
x | |
e | |
w |
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
sum += data[c] * 100000; |
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
for (unsigned i = 0; i < 100000; ++i) | |
{ | |
sum += data[c]; | |
} |
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
Sorted: | |
0.3 | |
sum = 314931600000 | |
Unsorted: | |
0.31 | |
sum = 314635000000 | |
Sorted swapped: | |
0.3 | |
sum = 314226200000 | |
Unsorted swapped: |
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
Sorted: | |
2.43 | |
sum = 314931600000 | |
Unsorted: | |
14.39 | |
sum = 314635000000 | |
Sorted swapped: | |
0 | |
sum = 314226200000 | |
Unsorted swapped: |
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 <stdio.h> | |
#include <stdlib.h> | |
/** | |
* @brief Find largest rectangle for a new window in a canvas with some existing windows. | |
* @param width Canvas width in pixel | |
* @param height Canvas height in pixel | |
* @param objects Existing objects, in the form {{x_topleft,y_topleft,x_bottomright_y_bottomright},...} | |
* @param num_objects Number of objects in previous parameter | |
* @param output Array to store result as {x_topleft,y_topleft,x_bottomright_y_bottomright} |