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
## http://qiita.com/Chironian/items/8770c8ab833086fb51a9 | |
############################################################ | |
# base | |
############################################################ | |
cmake_minimum_required(VERSION 2.8.8) | |
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE) | |
set(CMAKE_SUPPRESS_REGENERATION TRUE) |
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
void WebCrawlerSample::MainPage::button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) | |
{ | |
HttpClient^ client = ref new HttpClient(); | |
Uri^ addr = ref new Uri("https://heejune.me"); | |
auto asyncOp = client->GetAsync(addr); | |
// create and set Progress handler | |
asyncOp->Progress = ref new AsyncOperationProgressHandler<HttpResponseMessage^, HttpProgress>( | |
[=](IAsyncOperationWithProgress<HttpResponseMessage^, HttpProgress>^ pretask, HttpProgress progressInfo) { |
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 <future> | |
std::future<int> compute_value() | |
{ | |
int result = co_await std::async([] | |
{ | |
return 30; | |
}); | |
co_return result; |
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
// TODO: reference additional headers your program requires here | |
#include <windows.h> | |
#include <future> | |
#include <iostream> | |
#ifdef _RESUMABLE_FUNCTIONS_SUPPORTED | |
#include <experimental/resumable> | |
#endif |
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
template<class _Ty> | |
bool await_ready(future<_Ty>& _Fut) | |
{ | |
return (_Fut._Is_ready()); | |
} | |
template<class _Ty> | |
void await_suspend(future<_Ty>& _Fut, | |
experimental::coroutine_handle<> _ResumeCb) | |
{ // change to .then when future gets .then |
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
// resumable-idea.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
using namespace std; | |
struct resumable_thing | |
{ | |
void resume() {} |
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
// resumable-idea.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
using namespace std; | |
using namespace std::experimental; | |
struct resumable_thing | |
{ |
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
winrt::Windows::Foundation::IAsyncOperation<int> GetAsyncOp() | |
{ | |
using namespace winrt; | |
using namespace Windows::Foundation; | |
for (int i = 0; i != 5; ++i) | |
{ | |
co_await 5000ms; | |
} |
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
from slackclient import SlackClient | |
class SlackBot(object): | |
''' | |
SlackBot: | |
''' | |
def __init__(self, logger, slackclient): | |
self.logger = logger or logging.getLogger(__name__) | |
self.slack_client = slackclient or SlackClient(os.environ.get('SLACK_BOT_TOKEN')) |
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
bool isPrime(unsigned long num) | |
{ | |
if (num == 2) | |
return true; | |
if (num <= 1 || num % 2 == 0) // 0, 1, and all even numbers | |
return false; | |
for (unsigned long x = 3; x*x <= num; x += 2) { | |
if (num % x == 0) |