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 <Windows.h> | |
#include <iostream> | |
namespace std | |
{ | |
struct _pos | |
{ | |
_pos(short x, short y) : _x(x), _y(y) | |
{} | |
template<typename Elem, typename Traits> |
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
#define CALL_LOOP(TIME, FUNC) {static unsigned long cnt_##FUNC_##TIME_counter;\ | |
if (millis() - cnt_##FUNC_##TIME_counter > (TIME)) {\ | |
cnt_##FUNC_##TIME_counter = millis();\ | |
FUNC();}\ | |
} | |
void TestFunc() | |
{ | |
} |
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 <typename RET, typename... ARGS> | |
using FunctionPtr = RET(*)(ARGS...); | |
std::string func1(int a, int b) | |
{ | |
} | |
int main() | |
{ | |
FunctionPtr<std::string, int, int> fPtr = func1; |
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 magAck; | |
MyMessage msgBtn(PIN_BUTTON_1, V_TRIPPED); | |
void loop() | |
{ | |
int8_t btn = sleep(0, CHANGE, 1, CHANGE, 3600000); | |
if (btn >= 0) | |
{ | |
delay(20); | |
msgBtn.sensor = PIN_BUTTON_1 + btn; |
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
// How to convert lvalue to rvalue, because the compiler treats a named rvalue reference as an lvalue | |
// and an unnamed rvalue reference as an rvalue | |
// https://docs.microsoft.com/en-us/cpp/cpp/rvalue-reference-declarator-amp-amp?view=vs-2017#additional-properties-of-rvalue-references | |
std::vector<std::thread> thread_list; | |
for (int i = 0; i < 5; i++) | |
{ | |
std::thread t(thread_proc, dist(engine)); | |
// convert to rvalue explicitly | |
thread_list.push_back(static_cast<std::thread&&>(t)); |
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
#pragma once | |
#include <memory> | |
#include <iostream> | |
#include <string> | |
#include <cstdio> | |
template<typename ... Args> | |
std::wstring string_format(const std::wstring& format, Args ... args) | |
{ | |
size_t size = std::swprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0' |
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
## Restart ICS when specified MAC address not present in ARP cache (DHCP not working) | |
# | |
# Schedule on system startup: | |
# schtasks /create /SC ONSTART /DELAY 0005:00 /TN RB\TerminalICS /RU SYSTEM /RL HIGHEST /TR "powershell -file c:\temp\Enable-ICS.ps1 >> c:\temp\enable-ics.log" | |
function global:Enable-ICS | |
{ | |
Param ( | |
[String] | |
[ValidateSet('status','enable','disable')] |
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
// Client side (requesting node). | |
#define SERVER_NODE 99 | |
void setup() | |
{ | |
// Request for value from other node, response will be precessed by receive() | |
requests(CHILD_ID_LIGHT, V_PERCENTAGE, SERVER_NODE); | |
} | |
void receive(const MyMessage &message) | |
{ |