Skip to content

Instantly share code, notes, and snippets.

View jakkaj's full-sized avatar

Jordan Knight jakkaj

View GitHub Profile
@jakkaj
jakkaj / WorkflowTrackingExample
Created January 27, 2015 00:56
Example of how to track in progress workflows for updates in to the app UI
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using ModernHttpClient;
using UIKit;
using ProjectTripod.Portable.Model.Messages;
using ProjectTripod.Portable.Model.Workflow;
@jakkaj
jakkaj / TokenValidationParamsSettings.cs
Created August 3, 2016 20:42
JWT Validation using ASP.NET Core build in stuff
//From <https://stormpath.com/blog/token-authentication-asp-net-core>
var tokenValidationParameters = new TokenValidationParameters
{
// The signing key must match!
ValidateIssuerSigningKey = true,
IssuerSigningKey = signingKey,
// Validate the JWT Issuer (iss) claim
ValidateIssuer = true,
@jakkaj
jakkaj / webjob-publish-settings.json
Created January 25, 2017 08:56
Create a WebJob publish settings schedule
{
"$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
"webJobName": "SyncJob",
"startTime": "2015-12-16T00:00:00+10:00",
"endTime": "2020-12-16T00:00:00+10:00",
"jobRecurrenceFrequency": "Hour",
"interval": 6,
"runMode": "Scheduled"
}
@jakkaj
jakkaj / ParallelTaskHelper.cs
Created February 6, 2017 12:36
Simple Parallel Task Runner from Queues
/*Usage
public async Task TestParallelThings()
{
var tasks = new Queue<Func<Task>>();
for (var i = 0; i < 200; i++)
{
int c = i;
@jakkaj
jakkaj / run.csx
Created February 26, 2017 01:08
FFMPEG inside an Azure function.
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
using System.Diagnostics;
using System.IO;
public static async Task Run(Stream myBlob, string name, Binder binder, TraceWriter log)
{
log.Info($"Jordan C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
@jakkaj
jakkaj / demo.bat
Created February 27, 2017 09:40
FFMPEG commands to make nice screen capture demo GIFS of code and things
ffmpeg -y -i "dotnetrun ks.mp4" -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png
ffmpeg -i "dotnetrun ks.mp4" -i palette.png -filter_complex "fps=10,scale=1024:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
@jakkaj
jakkaj / webvttpocoparser.cs
Last active March 14, 2017 12:02
Parse WebVTT to POCO ready for indexing using Azure Search.
static List<IndexText> Parse(string vtt, string videoId){
string[] lines = vtt.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
var tcStart = default(TimeSpan);
var tcEnd = default(TimeSpan);
var indexList = new List<IndexText>();
foreach (var l in lines)
{
@jakkaj
jakkaj / Largersamplepost.json
Last active April 2, 2017 10:30
Function to render Graphviz graphs from dot files that are posted in
//thanks http://brandewinder.com/2017/04/01/azure-function-app-diagram/
{
"dot": "digraph app {\r\nnode [shape=doublecircle,style=filled,color=orange]\r\n \"check-mentions\"\r\n \"follow-users\"\r\n \"process-mention\"\r\n \"send-tweet\"\r\nnode [shape=box,style=filled,color=yellow]\r\n \"Timer\"\r\n \"Blob incontainer\/lastid\"\r\n \"Queue mentions\"\r\n \"Queue friends\"\r\n \"Queue tweets\"\r\nnode [shape=box,style=filled,color=lightblue]\r\n \"linqtotwitter (4.1.0)\"\r\n \"Newtonsoft.Json (9.0.1)\"\r\n \"FSharp.Compiler.Service (9.0.1)\" \r\nedge [ style=bold ]\r\n \"Timer\" -> \"check-mentions\" [ label = \"timer\" ]\r\n \"Queue friends\" -> \"follow-users\" [ label = \"userName\" ]\r\n \"Queue mentions\" -> \"process-mention\" [ label = \"input\" ]\r\n \"Queue tweets\" -> \"send-tweet\" [ label = \"input\" ]\r\nedge [ style=solid ]\r\n \"Blob incontainer\/lastid\" -> \"check-mentions\" [ label = \"previousID\" ]\r\nedge [ style=solid ]\r\n \"c
@jakkaj
jakkaj / SearchSession.cs
Created April 8, 2017 22:50
Azure Search Bot Session Entity
using Arlo.SDK.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Arlo.SDK.Entities.Product;
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using System.ComponentModel.DataAnnotations;
@jakkaj
jakkaj / QueryMaker.cs
Created April 9, 2017 23:44
QnA Query maker example
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Net;
using System.Threading.Tasks;
using Autofac;
using EventBot.SupportLibrary.Contract;
using EventBot.SupportLibrary.Entity;
using Newtonsoft.Json;
using Xamling.Azure.Portable.Contract;