Skip to content

Instantly share code, notes, and snippets.

View gaevoy's full-sized avatar

Volodymyr Gaevoy gaevoy

View GitHub Profile

Keybase proof

I hereby claim:

  • I am gaevoy on github.
  • I am gaevoy (https://keybase.io/gaevoy) on keybase.
  • I have a public key ASCgFi5Ys_1RS8WtBn4oakM5Z4btKWZ3oPhHx0LrCs9u1go

To claim this, I am signing this object:

@gaevoy
gaevoy / WebhookSignature.cs
Last active April 26, 2018 10:18
How to verify webhook's signature
using System;
using System.IO;
using System.Text;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
public static class WebhookSignature
{
public static bool Verify(string publicKey, string payload, string signature)
@gaevoy
gaevoy / StateMachineExample.cs
Last active April 5, 2018 07:59
StateMachineExample is simplistic example on how to implement state machine pattern without any framework
using System;
class StateOwner // This class must be persisted in database by ORM
{
private State _state;
public string StateType { get; set; }
public State State
{
get { return _state ?? (_state = State.Create(StateType, this)); }
set { _state = value; }
using System;
using Castle.MicroKernel.Lifestyle;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using NUnit.Framework;
namespace Tests
{
[TestFixture(true)]
[TestFixture(false)]
[TestFixture]
public class MongoDriverAsyncSyncTests
{
private readonly IMongoCollection<SimpleDto> _collection;
private readonly SimpleDto[] _dtosToInsert;
public MongoDriverAsyncSyncTests()
{
string connectionString = "mongodb://localhost/MongoDriverAsyncSyncTests";
string databaseName = new MongoUrl(connectionString).DatabaseName;
[TestFixture]
public class WatcherTests
{
[Test]
public async Task ItShouldCollectWatcher()
{
var _ = new Watcher();
GC.Collect();
GC.Collect();
await Task.Delay(5000);
@gaevoy
gaevoy / CqrsProblemSolutionUpdates.txt
Last active August 29, 2015 14:13
Discussion Meetup: CQRS Problem/Solution updates
Chat: https://gitter.im/gaevoy/cqrs-dnepr
Tips: https://docs.google.com/document/d/1gXWWjY60TGnwTppidRwhUIGPnklnW5q0wAqJkIqc_1Y
Любые предложения по CQRS пишите в чат или сюда коментами.
@gaevoy
gaevoy / ko.getUnusedFields.js
Last active August 29, 2015 14:02
ko.getUnusedFields(el)
ko.getUnusedFields = function (el) {
function isElement(obj) {
try {
//Using W3 DOM2 (works for FF, Opera and Chrom)
return obj instanceof HTMLElement;
}
catch (e) {
//Browsers not supporting W3 DOM2 don't have HTMLElement and
//an exception is thrown and we end up here. Testing some
//properties that all elements have. (works on IE7)