Skip to content

Instantly share code, notes, and snippets.

View romipetrelis's full-sized avatar

Romi Petrelis romipetrelis

  • Velcraft Software Inc
  • United States
View GitHub Profile
@romipetrelis
romipetrelis / descriptions.txt
Created May 8, 2019 17:12
descriptions vtt
WEBVTT
00:01.000 --> 00:04.000
Description of why drinking liquid nitrogen is bad.
00:05.000 --> 00:09.000
- It will perforate your stomach.
- You could die.
@romipetrelis
romipetrelis / captions.txt
Last active May 8, 2019 17:11
captions vtt
WEBVTT
00:01.000 --> 00:04.000
Never drink liquid nitrogen.
00:05.000 --> 00:09.000
- It will perforate your stomach.
- You could die.
public interface IEventBroker
{
Task Publish(object e);
}
internal class EventBroker : IEventBroker
{
private readonly IList<DomainEventHandler> _handlers;
public EventBroker(IList<DomainEventHandler> subscribers)
{
@romipetrelis
romipetrelis / daemon.cs
Created November 7, 2017 15:00
console app with cancel-able infinite loop
// credit: https://stackoverflow.com/questions/35714547/c-sharp-console-application-run-for-loop-while-not-disturbing-rest-of-exec
class Program {
static void Main(string[] args){
var tokenSource = new CancellationTokenSource();
var cancellationToken = tokenSource.Token;
var backgroundTask = Task.Run(() =>
{
Console.WriteLine("Background task started");
long count = 0;
using System;
using System.Collections.Generic;
namespace Fluent
{
public class OrderBuilder
{
private readonly Order _order;
private OrderLine _currentLine;
private int _currentLineNumber;
@romipetrelis
romipetrelis / mvc-packages.config
Created February 27, 2017 21:59
Packages for an ASP.NET MVC project
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="4.2.1" targetFramework="net46" />
<package id="Autofac.Mvc5" version="4.0.1" targetFramework="net46" />
<package id="Autofac.Mvc5.Owin" version="4.0.1" targetFramework="net46" />
<package id="Autofac.Owin" version="4.0.0" targetFramework="net46" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net46" />
private static void ConfigureSwagger(HttpConfiguration config)
{
config.EnableSwagger(
c => {
c.SingleApiVersion("all", "Some API");
c.IncludeXmlComments(string.Format(@"{0}\bin\Your.Assembly.XmlComments.xml",
AppDomain.CurrentDomain.BaseDirectory));
c.RootUrl(req =>
req.RequestUri.GetLeftPart(UriPartial.Authority) +
req.GetRequestContext().VirtualPathRoot.TrimEnd('/'));
@romipetrelis
romipetrelis / TransformConfig.msbuild
Created January 27, 2017 20:26
Transform configs (conditionally) after build
<Target Name="AfterBuild">
<CallTarget Condition="$(IsAgentBuild)=='true'" Targets="TransformConfig" />
<CallTarget Condition="!($(IsAgentBuild)=='true')" Targets="PreviewTransformedConfig" />
</Target>
<Target Name="TransformConfig">
<ItemGroup>
<DeleteAfterBuild Include="$(WebProjectOutputDir)\web.*.config"/>
</ItemGroup>
<TransformXml Source="web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\web.config" />
@romipetrelis
romipetrelis / Restore-Nuget.ps1
Last active January 27, 2017 20:22
Restore nuget packages during build (for old versions of TFS)
param(
$nugetPath, # Specified in your build definition. Ex: \\someunc\somewhere\nuget.exe
$slnPath # Specified in your build definition. Ex: $(TF_BUILD_SOURCESDIRECTORY)\MySolutionName.sln
)
$exp = $nugetPath + " restore " + $slnPath
Invoke-Expression $exp
@romipetrelis
romipetrelis / Replace-Tokens.ps1
Created January 27, 2017 20:18
Replace tokens in config file with values from environment
param(
$SourceFile,
$TokenStart = '__',
$TokenEnd = '__'
)
function Get-EnvironmentVariables
{
$env = @{}