Skip to content

Instantly share code, notes, and snippets.

View QiMata's full-sized avatar

Jared Rhodes QiMata

View GitHub Profile
@QiMata
QiMata / Channel.cs
Created June 26, 2020 12:25
Creating a new guid using the channel info
enum Channel : byte
{
UnknownChannel = 0,
Email = 1,
CallCenter = 2,
BrokerHelpDesk = 3,
BrokerPortal = 4
}
@QiMata
QiMata / create_trigger.sql
Created June 18, 2020 18:46
A function for creating the trigger
CREATE TRIGGER address_versioning_trigger
BEFORE UPDATE OR DELETE ON location.address
FOR EACH ROW EXECUTE PROCEDURE address_trigger_function();
@QiMata
QiMata / address_trigger_function.sql
Created June 18, 2020 18:39
Trigger for insert into logging table
create function address_trigger_function()
returns trigger as $$
BEGIN
insert into logging_address_address (address_id, type, street1, street2, street3, street4, city, po_box_code, phone_number, date_created, operation)
values (old.address_id, old.type, old.street1,old.street2,old.street3,old.street4,old.city,old.po_box_code,old.phone_number, old.date_created,TG_OP);
RETURN NEW;
end;
$$ LANGUAGE plpgsql;
@QiMata
QiMata / logging_address.sql
Created June 18, 2020 16:37
Logging table for table to be logged
create table logging_address
(
like address EXCLUDING CONSTRAINTS,
operation char(10) not null,
date_operated timestamp with time zone not null default current_timestamp
);
@QiMata
QiMata / address_table.sql
Created June 18, 2020 16:34
Table to be logged
create table address
(
address_id integer not null,
type varchar(100),
street1 varchar(120) not null,
street2 varchar(120),
street3 varchar(120),
street4 varchar(120),
city varchar(80),
po_box_code varchar(20) not null,
@QiMata
QiMata / ClassGenerator.cs
Created November 12, 2019 13:05
Showcasing how to generate proto files dynamically using protobuf-net
public class ClassGenerator
{
private readonly ModuleBuilder _moduleBuilder;
public ClassGenerator()
{
var an = new AssemblyName("DynamicProtoAssembly");
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(an,AssemblyBuilderAccess.Run);
_moduleBuilder = assemblyBuilder.DefineDynamicModule("DynamicProtoModule");
@QiMata
QiMata / CustomVisionImageProcessor.py
Created June 20, 2019 02:29
Image processor for creating images that can be classified by a custom vision model
from PIL import Image
import numpy as np
import cv2
def convert_to_opencv(image):
# RGB -> BGR conversion is performed as well.
image = image.convert('RGB')
r,g,b = np.array(image).T
opencv_image = np.array([b,g,r]).transpose()
return opencv_image
@QiMata
QiMata / CustomVisionCategorizer.py
Created June 20, 2019 02:15
A python script that loads a tensorflow model into memory without holding the global tensor flow graph hostage
import tensorflow as tf
import numpy as np
# The category name and probability percentage
class CategoryScore:
def __init__(self, category, probability: float):
self.category = category
self.probability = probability
@QiMata
QiMata / ISharedMemoryConsumer.cs
Created June 10, 2019 15:26
The C# portions of the shared memory provider
using System;
public delegate void HandleMessage(byte[] message);
internal delegate void InternalHandleMessage(IntPtr array, int length);
public interface ISharedMemoryConsumer
{
long Size();
void SetCallback(HandleMessage handler);
@QiMata
QiMata / NetCoreModule.cpp
Created May 20, 2019 20:34
The .NET portion of the shared memory provider
extern "C" ImageNetCoreSharedMemoryConsumer* GetImageConsumer(char * name)
{
return new ImageNetCoreSharedMemoryConsumer(std::string(name));
}
extern "C" void DeleteImageNetCoreSharedMemoryConsumer(ImageNetCoreSharedMemoryConsumer* consumer)
{
delete consumer;
}