Skip to content

Instantly share code, notes, and snippets.

View ry8806's full-sized avatar

Ryan Southgate ry8806

View GitHub Profile
public class HomeController : Controller
{
private readonly BufferBlock<CompetitionEntry> _bufferBlock;
private readonly ILogger<HomeController> _logger;
public HomeController(BufferBlock<CompetitionEntry> bufferBlock, ILogger<HomeController> logger)
{
_bufferBlock = bufferBlock;
_logger = logger;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
// Setup the DataFlow
// CSV File Setup (do/check this one time at application start)
if (!File.Exists("entries.csv"))
{
// If it doesn't exist, write the header line
@ry8806
ry8806 / form.html
Last active May 8, 2021 09:26
Elastic Email + JavaScript
<form id="subscribeForm">
<input id="email-input" type="text" />
<button type="submit">Submit</button>
</form>
function isDefinedAndNotNull(property) {
return property !== undefined && property !== null;
};
angApp.directive("radioTrackBy", [function () {
return {
restrict: "A",
scope: {
ngModel: "=",
ngValue: "=",
@ry8806
ry8806 / gulpfile.js
Last active October 19, 2016 12:59
Search Box Component for ASP.NET Core (MVC) and Angular2
/// <binding BeforeBuild='beforeBuild' />
/*
This file in the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
*/
var gulp = require('gulp');
var webRoot = "./wwwroot/";
app.filter('textfilter', [function() {
return function (input) {
if (arguments.length > 1) {
// If we have more than one argument (insertion values have been given)
var str = input;
// Loop through the values we have been given to insert
for (var i = 1; i < arguments.length; i++) {
// Compile a new Regular expression looking for {0}, {1} etc in the input string
var reg = new RegExp("\\{" + (i-1) + "\\}");
// Perform the replace with the compiled RegEx and the value
@ry8806
ry8806 / AutofacActivator.cs
Last active May 10, 2016 09:17
WebJobs and DI
using Autofac;
using Microsoft.Azure.WebJobs.Host;
namespace WebJob1
{
public class AutofacActivator : IJobActivator
{
private readonly IContainer _container;
public AutofacActivator(IContainer container)
using System.IO;
using Microsoft.Azure.WebJobs;
namespace WebJob1
{
public class Functions
{
// This function will get triggered/executed when a new message is written
// on an Azure Queue called queue.
public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
var promise1 = getFirstValue().then(function (value) {
return value;
});
// DON'T DO THIS
var p2 = $q.defer();
p2.resolve("A value that is instant but we're faffing around with it");
var promise2 = p2.deferred;
var promise3 = getThirdValue().then(function (value) {
var promise1 = getFirstValue().then(function (value) {
return value;
});
// We can just return a value without creating a promise if we don't need.
var promise2 = "A value that is instant";
var promise3 = getThirdValue().then(function (value) {
return value;
});