Skip to content

Instantly share code, notes, and snippets.

View makomweb's full-sized avatar
🌀

Martin Komischke makomweb

🌀
View GitHub Profile
@makomweb
makomweb / learnings-oauth2-oidc.md
Created January 3, 2020 13:55
My learnings about OAuth2.0 and Open ID Connect

OAuth 2.0

Endpoints

Endpoint Example Purpose
Authorization https://<auth-server>/oauth/authorize used by the client application to obtain authorization grant from the resource owner via user-agent redirection
Token https://<auth-server>/oauth/token used by the client application to exchange an authorization grant for an access token, typically with client authentication
Redirection https://<client>/callback used by the authorization server to return responses containing authorization grants to the client via the resource owner user-agent
@makomweb
makomweb / ViewModelBase.cs
Last active March 28, 2020 22:22
This is a view model base implementation which can be used in well known MVVM scenarios. It stores all the values in a backing dictionary and accesses it through the property name specified by the lambda expression.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;
namespace Playground {
// Notice the 3 occurrencies of the Title identifier and the abscence of additional backing fields!
public class ExampleViewModel : ViewModelBase {
public string Title {
@makomweb
makomweb / hello-rx.js
Created August 20, 2019 14:28
simple script to run node js app with reactive extensions
const Rx = require('rx');
const sequence = Rx.Observable.create(function(src) {
src.onNext(1);
src.onNext(2);
src.onNext(3);
src.onNext(4);
src.onError(new Error("booom!!!"));
src.onNext(5);
src.onCompleted();
@makomweb
makomweb / events_in_cpp.cpp
Last active August 2, 2017 08:03
Playing around with C++ events. Very similar to Qt's signal/slot mechanism.
#include <iostream>
#include <stdio.h>
using namespace std;
[event_source(native)]
class Sender
{
public:
__event void SendEvent(int value);
@makomweb
makomweb / awaiting_null_should_throw.cs
Created July 14, 2017 08:31
When awaiting null it should throw
[Fact]
public async Task When_awaiting_null_it_should_throw()
{
try
{
Task t1 = Task.Run(() => { /* do nothing */ });
Task t2 = null;
await Task.WhenAll(t1, t2);
Assert.True(false, "Should have thrown before!");
}
@makomweb
makomweb / observable_null_vs_empty.cs
Created April 8, 2016 17:00
Observable null vs. empty
public class MyTests
{
public class Package { }
public class Service
{
public IObservable<Package> DeliverRegular()
{
return DeliverRegularAsync().ToObservable();
}
public class LoginExplorations
{
public async Task<DataContracts.List[]> FetchListsAsync(string accessToken, string deviceId)
{
var info = new TestSystemInfo(
userAgent: "Wunderlist.Sdk/" + new AssemblyInfoHelper(typeof (RestClient)).AssemblyVersion,
clientId: "01d4f9dcdafd531da497",
clientProductGitHash: new AssemblyInfoHelper(typeof (RestClient)).InformationalVersion,
clientDeviceId: deviceId,
clientSystem: "Windows RT device",
@makomweb
makomweb / create_changelog.js
Last active December 31, 2015 15:09
Write all the GIT commit messages since the last tag (on the current branch) into a changelog file.
var usage_description = "Usage: node create_changelog.js MyChangelog.txt \"Changelog for nightly build version 0.9.0.1\"";
var args = ParseArguments();
var spawn = require('child_process').spawn;
var fs = require('fs');
var prc = spawn('git', ['describe', '--tags', '--abbrev=0']);
prc.stdout.setEncoding('utf8');
prc.stdout.on('data', function (data) {
var str = data.toString();
var lines = str.split(/(\r?\n)/g);
@makomweb
makomweb / datadriven_test_with_xUnit.net.cs
Last active December 31, 2015 03:29
Testing different serializers with xUnit.net.
public class SerializerTests
{
public static IEnumerable<object[]> Serializers
{
get
{
yield return new object[] { new NewtonsoftJson() };
yield return new object[] { new ServiceStackJson() };
}
}
@makomweb
makomweb / send_message_to_ws_server_and_receive_reply.cs
Last active December 30, 2015 05:59
Send a message to the WS server and receive a reply.
[Fact]
public async Task Getting_an_event_when_connecting_should_succeed()
{
using (var ws = new ReactiveWebSocket("ws://127.0.0.1:8080", true))
{
var man = new WebSocketManager(ws);
man.Send(new Message { Id = Guid.NewGuid().ToString() });