Skip to content

Instantly share code, notes, and snippets.

View Laro88's full-sized avatar

Jes Ramsing Laro88

  • Denmark
View GitHub Profile
#include <iostream>
#include <string>
#include <pqxx/pqxx>
std::basic_string<std::byte> randomizer(int size)
{
std::basic_string<std::byte> n;
for(int j = 0; j < size; ++j)
{
std::byte b;
@Laro88
Laro88 / streamtest.cpp
Last active September 2, 2020 11:15
libpqxx stream_to binarystring tester (normal prepared vs stream_to)
#include <iostream>
#include <string>
#include <ctime>
#include "pqxx/pqxx" //wherever you have the local pqxx superheader - remember to fix your linker as well
int lengthByteArray = 10000;
int vectorsize = 10000; //10K 10K gives a couple of seconds
char* GetRandomByteArrayContent() { //generate the fake data - should include random 0 values (end of char strings)
@Laro88
Laro88 / README.md
Created September 27, 2016 08:37
function to format data for chart to plot series of timestamp,value

The topic of interest in the "function slice and aggregate...." It solves the problem of plotting {timestamp, value} points, not just adding a new value.

It originates from polling a public api that exposes recorded IoT data. The data received contains the latest value for the inquired sensors, however since the data is timestamped, these should be respected in the plotting.

Notice: The context stores the obtained dataset and adds points if the timestamp is not previously seen. Some memory is wasted maintaining a lookup array that is not used for anything.