Skip to content

Instantly share code, notes, and snippets.

View ry8806's full-sized avatar

Ryan Southgate ry8806

View GitHub Profile
@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>
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
uploaderApp.service('S3UploadService', ['$q', function ($q) {
// Us standard region
AWS.config.region = 'us-east-1';
AWS.config.update({ accessKeyId: '**myAccessKeyId**', secretAccessKey: '**mySecretAccessKey**' });
var bucket = new AWS.S3({ params: { Bucket: 'myTempBucket', maxRetries: 10 }, httpOptions: { timeout: 360000 } });
this.Progress = 0;
this.Upload = function (file) {
var deferred = $q.defer();
@ry8806
ry8806 / uploader-controller.js
Last active November 13, 2019 04:37
Amazon S3 Upload to Bucket angularJS app and controller
// JavaScript source code
var uploaderApp = angular.module('uploaderApp', ['ngFileUpload']);
uploaderApp.run();
uploaderApp.controller('UploadController', ['$scope', 'Upload', 'S3UploadService', function ($scope, Upload, S3UploadService) {
$scope.uploadFiles = function (files) {
$scope.Files = files;
if (files && files.length > 0) {
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 / jplayer-directive.js
Last active May 20, 2016 14:44
AngularJS and jPlayer directive
myApp.directive("jplayer", ['$window', 'PlayerService', function ($window, PlayerService) {
return {
restrict: "E",
// Have our own scope - we only want to watch the service and not conflict with other scopes
scope: {},
// Serve up some html with our player
templateUrl: "/jplayer-template.html",
link: function (scope, element, attrs) {
// An element on the page to attach the jPlayer to. Could also use "element" from linkFN ^
var jPlayer = angular.element("#jquery_jplayer_1").jPlayer();
@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)