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
return { | |
default_server_start = { | |
port = 8412 | |
}, | |
server = { | |
server_name = "Algomieszkanko", | |
allow_nat_traversal = false | |
}, | |
http_client = { | |
update_on_launch = false |
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
import paho.mqtt.client as mqtt | |
import threading | |
ADDR="192.168.2.128" | |
TOPIC_NAME="BMS/P11" | |
def on_connect(client, userdata, flags, rc): | |
print("Connected with result code "+str(rc)) | |
print(client.subscribe(TOPIC_NAME)) |
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
import paho.mqtt.client as mqtt | |
import threading | |
ADDR="test.mosquitto.org" | |
TOPIC_NAME="flow_temp_pres" | |
def on_connect(client, userdata, flags, rc): | |
print("Connected with result code "+str(rc)) | |
print(client.subscribe(TOPIC_NAME)) |
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
To pokazuje jak se można odstrzelić całą nogę w tym języku. | |
Miałem takiego buga, że jak do jednego pliku, | |
nazwijmy go crash.cpp - nie wrzuciłem jednego includa - to miałem crasha w serializacja.cpp. | |
Co ciekawe, funkcje z crash.cpp w ogóle nie były wykorzystywane podczas testowania. | |
Więc mam se w kodzie takie generalne templatki do serializacji, write_bytes oraz read_bytes, | |
które z dowolnego obiektu robią ci wektor bajtów i vice versa, | |
ale możesz dla swojego złożonego typu zdefiniować w global scopie własne funkcje | |
zwane write_object_bytes/read_object_bytes. |
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
mkdir .deps ; cd .deps | |
cmake -DCMAKE_BUILD_TYPE=Release ../third-party -G Ninja | |
ninja | |
export CFLAGS='-O3 -flto -fuse-ld=lld' | |
export CXXFLAGS='-O3 -flto -fwhole-program-vtables -fuse-ld=lld' | |
export LDFLAGS='-flto -fwhole-program-vtables -fuse-ld=lld' | |
../ | |
mkdir build ; cd build | |
cmake -DCMAKE_BUILD_TYPE=Release .. -G Ninja | |
ninja |
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 <type_traits> | |
#include <iostream> | |
template <class A, class = void> | |
struct has_member : std::false_type {}; | |
template <class A> | |
struct has_member<A, decltype(A::member, void())> : std::true_type {}; | |
struct AA { static constexpr bool member = 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
#pragma once | |
#include <future> | |
#include <optional> | |
template <class T> | |
bool is_ready(const std::future<T>& f) { | |
return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready; | |
} | |
template <class 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
struct A { int v; }; | |
struct B { int v; }; | |
struct C { int v; }; | |
struct Ar { int& v; }; | |
struct Br { int& v; }; | |
struct Cr { int& v; }; | |
void add_ref(A& a, B& b, C& c) { | |
a.v += c.v; | |
b.v += c.v; |
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 <type_traits> | |
#include <iostream> | |
using namespace std; | |
template <bool> | |
struct constexpr_if; | |
template <> | |
struct constexpr_if<true> { | |
struct elser { |
NewerOlder