Shell
#!/usr/bin/env sh
Python
This file contains 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 <iostream> | |
#include <chrono> | |
// for sleep | |
#include <thread> | |
void sleep(unsigned long sleep_time) | |
{ | |
std::chrono::milliseconds duration(sleep_time); | |
std::this_thread::sleep_for(duration); |
This file contains 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 <iostream> | |
#include <memory> | |
struct Item { | |
public: | |
Item() { | |
std::cout << "Item::Constructor" << std::endl; | |
} | |
~Item() { | |
std::cout << "Item::Destructor" << std::endl; |
This file contains 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 <iostream> | |
#include <random> | |
#include <limits> | |
/** | |
* @brief ランダムな整数を生成する関数を作成します。 | |
* @tparam T 実数型(short, int, long...)。省略時は unsigned int. | |
* @param min 乱数最小値。省略時は0が指定される。 | |
* @param max 乱数最大値。省略時はT型の最大値が指定される。 | |
* @return 整数乱数生成関数 |
This file contains 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
/**************************************************************************//** | |
* @brief Example of merge std::vector And sort with erase duplicates. | |
* @par Bibliography | |
* http://stackoverflow.com/questions/1041620/most-efficient-way-to-erase-duplicates-and-sort-a-c-vector | |
* | |
* @author Mitsu | |
* @date 2014-07-07. 七夕! | |
******************************************************************************/ | |
#include <chrono> | |
#include <iostream> |
This file contains 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
//------------------------------ Common Template ------------------------------// | |
//////////////////////////////////////////////////////////////////////////////// | |
// | |
//////////////////////////////////////////////////////////////////////////////// | |
/****************************************************************************** | |
* | |
******************************************************************************/ |
This file contains 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 <iostream> | |
/** | |
* @brief Return the number of occurrences of substring 'sub in string 'src'. | |
* @param src search target. | |
* @param sub substring. | |
* @return the number of occurrences of substring. | |
*/ | |
int countSubStr(std::string &src, std::string &sub) | |
{ |
This file contains 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 <iostream> | |
#include <cstdint> | |
/* | |
1. Assigns 1 to 16bit variable. | |
int16_t x16 = 1; | |
BE : 00000000 00000001 | |
LE : 00000001 00000000 | |
2. Cast it to 8bit variable, then get upper 8bits. |
This file contains 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 <iostream> | |
#include <memory> | |
#include <vector> | |
struct Test { | |
Test(int data = 0) : data(data) { | |
std::cout << "Test::Constructor: " << this->data << std::endl; | |
} | |
~Test() { | |
std::cout << "Test::Destructor: " << this->data << std::endl; |
This file contains 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 <iostream> | |
#include <ctime> | |
#include <thread> | |
#include <iomanip> | |
void sleep(unsigned long sleep_time) | |
{ | |
std::chrono::milliseconds duration(sleep_time); | |
std::this_thread::sleep_for(duration); | |
} |
OlderNewer