Skip to content

Instantly share code, notes, and snippets.

View QiMata's full-sized avatar

Jared Rhodes QiMata

View GitHub Profile
@QiMata
QiMata / CompositeFilterMapper.cs
Created August 19, 2018 23:40
The ElasticSearch query mapper
class CompositeFilterMapper<T>
{
private readonly CompositeFilterDescriptor _compositeFilterDescriptor;=
public CompositeFilterMapper(CompositeFilterDescriptor compositeFilterDescriptor)
{
_compositeFilterDescriptor = compositeFilterDescriptor;
}
public QueryContainer GetQueryContainer(QueryContainerDescriptor<ElasticDataUpload<T>> query)
@QiMata
QiMata / GridController.cs
Last active August 19, 2018 22:47
The Controller Endpoint for using a Kendo Grid against ElasticSearch
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Nest;
@QiMata
QiMata / app.component.ts
Last active August 19, 2018 14:21
Component for angular 5 grid
import { Component } from '@angular/core';
import { process, State } from '@progress/kendo-data-query';
import { sampleProducts } from './products';
import {
GridComponent,
GridDataResult,
DataStateChangeEvent
} from '@progress/kendo-angular-grid';
@QiMata
QiMata / CompositeFilterDescriptor.cs
Last active August 19, 2018 14:28
A serializable object for the Kendo Grid Filter
public class CompositeFilterDescriptor
{
[JsonProperty("logic")]
public string Logic { get; set; }
[JsonProperty("filters")]
public ICollection<CompositeFilterDescriptor> Filters { get; set; }
[JsonProperty("field")]
public string Field { get; set; }
@QiMata
QiMata / main.cpp
Created July 9, 2018 17:55
Main file for open cv write up
#include <opencv2/opencv.hpp>
int main( int argc, char** argv )
{
VideoCapture cap;
if(!cap.open(0))
return 0;
Mat frame;
cap >> frame;
@QiMata
QiMata / web.config
Created July 4, 2018 22:00
Web.config for all your Azure app services redirect needs.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<action type="Redirect" url="http://<<appdomain>>/{R:0}" redirectType="Permanent" />
</rule>
</rules>
@QiMata
QiMata / TensorflowImageSample.py
Created April 30, 2018 03:23
Image detection Neural Network Definition
with tf.name_scope("ImageInputLayer"):
image_input = tf.placeholder(tf.float32, shape=[None, 307, 441, 3])
x_image = tf.summary.image('input_cards', image_input, 5)
y_ = tf.placeholder(tf.int32, [None, len(features.InternalId)])
with tf.device(get_available_gpus()[0]):
with tf.name_scope("ConvolutionLayer1"):
with tf.name_scope("Weights"):
W_conv1 = weight_variable([5, 5, 3, 32])
variable_summaries(W_conv1)
[FunctionName("StreamOutputToElastic")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
{
var node = new Uri("http://{username}:{password}@{ipaddress}:9200");
var settings = new ConnectionSettings(node);
settings.DefaultIndex("my-index");
var elasticClient = new ElasticClient(settings);
var records = await req.Content.ReadAsAsync<T>();
await elasticClient.IndexManyAsync(timeStampedEvents, "my-index-name");
@QiMata
QiMata / Program.cs
Created January 7, 2018 14:26
Function for receiving cloud to device messages
private static async void ReceiveC2dAsync()
{
Console.WriteLine("\nReceiving cloud to device messages from service");
while (true)
{
Message receivedMessage = await deviceClient.ReceiveAsync();
if (receivedMessage == null) continue;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Received message: {0}", Encoding.ASCII.GetString(receivedMessage.GetBytes()));
@QiMata
QiMata / Program.cs
Last active November 11, 2017 16:01
function.json for Function that reacts to azure
public static void Run(Stream myBlob, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}