Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
namespace MemTestPlain
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@migajek
migajek / x.cs
Created October 8, 2019 10:11
Hangfire Console ASP.NET Core logging integration
public class HangfireConsoleLogger: ILogger
{
private class AsyncLocalScope : IDisposable
{
public AsyncLocalScope(PerformContext context) => PerformContext.Value = context;
public void Dispose() => PerformContext.Value = null;
}
private static readonly AsyncLocal<PerformContext> PerformContext = new AsyncLocal<PerformContext>();
@migajek
migajek / gist:dede8e9184a087e19bd9
Last active June 1, 2016 12:22
Angular + ServiceStack's SSE
factory('sse', ['$rootScope', '$http', function($rootScope, $http) {
// https://gist.github.com/migajek
var splitOnFirst = function (s, c) { if (!s) return [s]; var pos = s.indexOf(c); return pos >= 0 ? [s.substring(0, pos), s.substring(pos + 1)] : [s]; };
return {
start: function(handlers) {
var opt = {};
var sse = new EventSource('/event-stream');
sse.addEventListener('message', function(e) {
var parts = splitOnFirst(e.data, ' ');
var selector = parts[0];
@migajek
migajek / gist:40f9d3e7fbd39787edb3
Last active August 29, 2015 14:04
Sublime Text 3 plugin for quick modification of dependencies
import sublime, sublime_plugin
import re
class AngularPromptDepsCommand(sublime_plugin.WindowCommand):
def run(self):
defstr = ""
if self.window.active_view():
cmd = AngularInjectGetDepsCommand(view = self.window.active_view())
result = cmd.run(None)
if result: