Skip to content

Instantly share code, notes, and snippets.

View QiMata's full-sized avatar

Jared Rhodes QiMata

View GitHub Profile
@QiMata
QiMata / PythonModule.cpp
Created May 20, 2019 20:20
The python portion of the shared memory provider
BOOST_PYTHON_MODULE(ScryUnlimitedCommunicator)
{
Py_Initialize();
class_<SeralizedPythonSharedMemoryConsumer, boost::noncopyable>("SeralizedSharedMemoryConsumer",init<std::string>())
.def("set_callable", &SeralizedPythonSharedMemoryConsumer::set_callable)
.def("start",&SeralizedPythonSharedMemoryConsumer::start)
.def("wait",&SeralizedPythonSharedMemoryConsumer::wait);
class_<ImagePythonSharedMemoryConsumer, boost::noncopyable>("ImageSharedMemoryConsumer",init<std::string>())
.def("set_callable", &ImagePythonSharedMemoryConsumer::set_callable)
@QiMata
QiMata / SharedMemoryConsumer.hpp
Created May 20, 2019 19:27
This gist is to showcase boost interprocess. Creating a set of classes to create an interface for me to create a shared memory layer for high level languages
template<size_t BufferSize>
class SharedMemoryConsumer
{
public:
explicit SharedMemoryConsumer(const std::string& memory_name)
: name_length_(memory_name.size()),
shm_(boost::interprocess::open_or_create,memory_name.c_str(),boost::interprocess::read_write)
{
shm_.truncate(sizeof(TraceQueue<BufferSize>));
@QiMata
QiMata / routes.json
Created April 22, 2019 15:47
The routes for the dog image storage
"routes": {
"cameraToObjectDetection": "FROM /messages/modules/camera/outputs/imageOutput INTO BrokeredEndpoint(\"/modules/objectDetection/inputs/incomingImages\")",
"cameraToImageStorage": "FROM /messages/modules/camera/outputs/imageOutput INTO BrokeredEndpoint(\"/modules/imageStorage/inputs/incomingImages\")",
"objectDetectionToMotionDetection": "FROM /messages/modules/objectDetection/outputs/objectDetectionOutput INTO BrokeredEndpoint(\"/modules/motionDetection/inputs/incomingObjectDetection\")",
"motionDetectionToDeleteImage": "FROM /messages/modules/motionDetection/outputs/motionDetectionOutput INTO BrokeredEndpoint(\"/modules/imageStorage/inputs/deleteImages\")"
}
@QiMata
QiMata / Dockerfile.amd64.debug
Last active February 13, 2019 03:42
A docker file that allows for using VLC
FROM ubuntu:xenial AS base
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common gdb && \
add-apt-repository -y ppa:aziotsdklinux/ppa-azureiot && \
apt-get update && \
apt-get install -y azure-iot-sdk-c-dev && \
rm -rf /var/lib/apt/lists/*
FROM base AS build-env
RUN apt-get update && \
@QiMata
QiMata / main.c
Last active January 16, 2019 11:41
Downloading an image from an Izon camera and sending to the EdgeHub for comsumption
struct MemoryStruct {
char *memory;
size_t size;
};
static size_t
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
@QiMata
QiMata / main.c
Last active January 1, 2019 16:54
An example of updating a list of IP addresses with Azure IoT Edge Module Twin
#include <stdio.h>
#include <stdlib.h>
#include "iothub_module_client_ll.h"
#include "iothub_client_options.h"
#include "iothub_message.h"
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/platform.h"
#include "azure_c_shared_utility/shared_util_options.h"
@QiMata
QiMata / Dockerfile.amd64.debug
Created December 29, 2018 04:12
Changing the dockerfile to add LibCurl so that the module can download from the Izon Camera
FROM ubuntu:xenial AS base
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common gdb && \
add-apt-repository -y ppa:aziotsdklinux/ppa-azureiot && \
apt-get update && \
apt-get install -y azure-iot-sdk-c-dev && \
rm -rf /var/lib/apt/lists/*
FROM base AS build-env
RUN apt-get update && \
@QiMata
QiMata / LeadTools.cmake
Created October 3, 2018 17:25
A CMake rewrite of the make file for Lead tools OCR example
if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(lib_arch x64)
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x64")
set(lib_arch x64)
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86")
set(lib_arch x86)
else()
message(FATAL_ERROR "System architecture is not supported")
endif()
@QiMata
QiMata / ChildViewModel.cs
Created August 27, 2018 12:52
Code Snippet for Team
class ChildViewModel
{
//some properties
}
@QiMata
QiMata / CMakeLists.txt
Created August 24, 2018 01:31
A CMake snippet for auto generating protobuf c++ files during make file generation
file(GLOB PROTOBUF_DEFINITION_FILES "*.proto")
set(PROTOBUF_INPUT_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(PROTOBUF_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/Models/Proto/")
foreach(file ${PROTOBUF_DEFINITION_FILES})
set(PROTOBUF_ARGUMENTS "protoc --proto_path=\"${PROTOBUF_INPUT_DIRECTORY}\" --cpp_out=\"${PROTOBUF_OUTPUT_DIRECTORY}\" \"${file}\"")
execute_process(COMMAND ${PROTOBUF_OUTPUT_DIRECTORY}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE PROTOBUF_RESULT
OUTPUT_VARIABLE PROTOBUF_OUTPUT_VARIABLE)
endforeach()