Skip to content

Instantly share code, notes, and snippets.

View atimin's full-sized avatar
🎯
Focusing

Alexey Timin atimin

🎯
Focusing
View GitHub Profile
const {Client} = require('reduct-js');
const client = new Client('http://localhost:8383');
client.getBucket('mqtt').then(async (bucket) => {
let data = await bucket.read('mqtt_data');
console.log('Last record: %s', data);
// Get data for the last hour
const stopTime = BigInt(Date.now() * 1000);
@atimin
atimin / docker-compose.yml
Created April 18, 2022 21:16
docker-compose-reduct-mqtt
version: "3"
services:
reduct-storage:
image: ghcr.io/reduct-storage/reduct-storage:latest
volumes:
- ./data:/data
ports:
- "8383:8383"
mqtt-broker:
@atimin
atimin / mqtt-reduct-writter.js
Created April 18, 2022 21:00
mqtt-reduct-writter
const MQTT = require('async-mqtt');
const {Client} = require('reduct-js');
MQTT.connectAsync('tcp://localhost:1883').then(async (mqttClient) => {
await mqttClient.subscribe('mqtt_data');
const reductClient = new Client('http://localhost:8383');
const bucket = await reductClient.getOrCreateBucket('mqtt');
mqttClient.on('message', async (topic, msg) => {
class HttpClient {
public:
HttpClient() { /* init only fields or allocate memory, threads etc */ }
[[ nodiscard ]] ErrorCode Connect() {
// Connect to server
}
}
class ISmartObject {
 public:
  virtual int Foo() const = 0;
}
class RealObject : public ISmartObject {
 public:
  RealObject() { /* allocate resource and throw exception */ }
  int Foo() const override { /* do real work */ }
}
class A {
 public:
  A() { is_valid_ = Init(); };
  void Foo() {
  if (!is_valid_) {
  is_valid_ = Init()
  }
  // do work 
 }
 
@atimin
atimin / PowerFlexLogicData.cpp
Last active February 7, 2020 01:42
Read Logic Status and write Logic Command for PowerFlex 525
//
// Created by Aleksey Timin on 11/16/19.
//
#include <cstdlib>
#include <sstream>
#include <cip/connectionManager/NetworkConnectionParams.h>
#include "SessionInfo.h"
#include "MessageRouter.h"
#include "ConnectionManager.h"
@atimin
atimin / makeDPIFaultRequest.cpp
Last active December 12, 2019 17:04
Make DPI Fault Request
#include "vendor/ra/powerFlex525/DPIFaultManager.h"
using namespace eipScanner;
using namespace eipScanner::vendor::ra::powerFlex525;
struct DPIFaultManagerResponse {
bool isTripped;
bool isErrored; // flag to say that we failed to make the request
std::vector<DPIFaultObject> faultObjects;
};
@atimin
atimin / work_arounds.patch
Created October 26, 2018 10:41
My workarounds for OpcUa Stack
diff --git a/src/OpcUaStackServer/ServiceSet/Session.cpp b/src/OpcUaStackServer/ServiceSet/Session.cpp
index e6ec6a85..54ba71e4 100644
--- a/src/OpcUaStackServer/ServiceSet/Session.cpp
+++ b/src/OpcUaStackServer/ServiceSet/Session.cpp
@@ -255,10 +255,10 @@ namespace OpcUaStackServer
Log(Debug, "user name invalid");
return BadIdentityTokenInvalid;
}
- if (token->passwordLen() == 0) {
- Log(Debug, "password name invalid");
@atimin
atimin / gist:3069186
Created July 8, 2012 03:38
Slice N-dimension matrix
#!/usr/bin/env ruby
require 'pp'
require 'test/unit/assertions.rb'
class NMatrix
attr_reader :shape, :elements, :count, :strides
def initialize(shape, elements = nil)
@shape = shape