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
//----------------------------------------------------------------------------- | |
// Format current time (calculated as an offset in current day) in this form: | |
// | |
// "hh:mm:ss.SSS" (where "SSS" are milliseconds) | |
//----------------------------------------------------------------------------- | |
std::string now_str() | |
{ | |
// Get current time from the clock, using microseconds resolution | |
const boost::posix_time::ptime now = | |
boost::posix_time::microsec_clock::local_time(); |
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
#!/usr/bin/python3 | |
# encoding: utf-8 | |
import platform | |
import asyncio | |
@asyncio.coroutine | |
def _read_stream(stream, cb): | |
while True: | |
line = yield from stream.readline() |
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
// http://reedbeta.com/blog/python-like-enumerate-in-cpp17/?fbclid=IwAR3b_OJ61ol7pU525NxcIzureSBU1emoSQtvVG3L_q_pCvBcO4yKyyHU6OA | |
#include <iostream> | |
#include <tuple> | |
#include <vector> | |
template <typename T, | |
typename TIter = decltype(std::begin(std::declval<T>())), | |
typename = decltype(std::end(std::declval<T>()))> |
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
#ifndef __cplusplus | |
#define UNUSED(x) ((void)(x)) | |
#else | |
template <typename... Ts> | |
inline constexpr void ignore_unused(Ts const& ...){} | |
template <typename... Ts> | |
inline constexpr void ignore_unused(){} | |
#define UNUSED(x) ignore_unused(x) |
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 <memory> | |
int main() | |
{ | |
std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(name.c_str(), "r"), &std::fclose); | |
return 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 <memory> | |
int main() | |
{ | |
auto Data = | |
std::unique_ptr<double, decltype(free)*>{ | |
reinterpret_cast<double*>(malloc(sizeof(double)*50)), | |
free }; | |
return 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
template <uint32_t N, typename... Args> | |
void _snprintf(char (&buf)[N], const char* format, Args&&... args) | |
{ | |
snprintf(buf, N, format, args...); | |
buf[N-1] = '\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
#ifndef SSVU_FASTFUNC | |
#define SSVU_FASTFUNC | |
#include <cstring> | |
#include <type_traits> | |
#include <cassert> | |
#include <cstddef> | |
#include <memory> | |
#include <new> | |
#include <utility> |