Skip to content

Instantly share code, notes, and snippets.

private static IWebHost CreateWebHost()
{
var scheme = Environment.GetEnvironmentVariable("SCHEME");
if (string.IsNullOrWhiteSpace(scheme))
{
scheme = "http";
}
var port = Environment.GetEnvironmentVariable("PORT");
if (string.IsNullOrWhiteSpace(port))
FROM microsoft/dotnet:1.1.1-runtime
RUN mkdir /opt/app-release
WORKDIR /opt/app-release
COPY out .
ENTRYPOINT ["dotnet", "My.Dotnet.Application.dll"]
version: '3'
services:
web:
image: microsoft/dotnet:1.1.1-sdk
ports:
- "5000:5000"
env_file: .env
depends_on:
- db
volumes:
@luuhq
luuhq / HmacDataProtector.cs
Created April 6, 2017 03:15
HmacDataProtector
using System;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNetCore.DataProtection;
namespace Home.Web
{
internal sealed class HmacDataProtector : IDataProtector
{
private const int HmacSize = 32; // for SHA256
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
!-::
{
SendInput —
}
return
private static Message CreateReplyMessage(Message message, string text)
{
var reply = message.CreateReplyMessage(text);
reply.BotUserData = message.BotUserData;
return reply;
}
private Message HandleAddCommand(Command command, Message message)
{
public Message Post([FromBody]Message message)
{
const string NotSupportMessage = "Sorry, I could not understand that.";
if (message.Type == "Message")
{
Command command = null;
if (Command.TryParse(message.Text, out command) == false)
{
return message.CreateReplyMessage(NotSupportMessage);
public class Command
{
public string Action { get; set; }
public string Parameters { get; set; }
public static bool TryParse(string text, out Command command)
{
command = null;
public Message Post([FromBody]Message message)
{
if (message.Type == "Message")
{
// calculate something for us to return
int length = (message.Text ?? string.Empty).Length;
// return our reply to the user
return message.CreateReplyMessage($"Hello from TallyBot! You sent {length} characters");
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Child1: {0}", new Child1().Caller);
Console.WriteLine("Child2: {0}", new Child2().Caller);
Console.WriteLine("Child3: {0}", new Child3().Caller);
}
public abstract class Parent