Skip to content

Instantly share code, notes, and snippets.

⚗️
Experimenting

Martin Komischke makomweb

⚗️
Experimenting
Block or report user

Report or block makomweb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@makomweb
makomweb / hello-rx.js
Created Aug 20, 2019
simple script to run node js app with reactive extensions
View hello-rx.js
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 / batch_resize.py
Created Sep 19, 2018
Python script for batch resizing images and keeping the aspect ratio
View batch_resize.py
from PIL import Image
import os, sys
path = "c:\\Workspace\Images"
dirs = os.listdir( path )
mywidth = 640
def resize_keep_aspect_ration():
for item in dirs:
img_path = path + "\\" + item
@makomweb
makomweb / awaiting_null_should_throw.cs
Created Jul 14, 2017
When awaiting null it should throw
View awaiting_null_should_throw.cs
[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!");
}
View observable_null_vs_empty.cs
public class MyTests
{
public class Package { }
public class Service
{
public IObservable<Package> DeliverRegular()
{
return DeliverRegularAsync().ToObservable();
}
View login_explorations.cs
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 / ViewModelBase.cs
Created Nov 23, 2015
Updated ViewModelBase
View ViewModelBase.cs
namespace Sandbox
{
public class ExampleViewModel : ViewModelBase
{
public string Title
{
get { return GetValue(() => Title); }
set { SetValue(() => Title, value); }
}
}
View type_switch_playground.cs
namespace VisitorTests
{
public interface INt
{
}
public interface INtel
{
}
@makomweb
makomweb / ViewModelBase.cs
Last active Aug 29, 2015
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.
View ViewModelBase.cs
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 / reissue.cs
Created Oct 9, 2014
Issue, cancel and reissue async operation
View reissue.cs
public class WorkerCancellationTests
{
[Test]
public async Task When_running_async_then_result_should_be_true()
{
var worker = new Worker();
var result = await worker.DoAsync(100.Milliseconds());
result.Should().BeTrue();
}
@makomweb
makomweb / rx_cancel.cs
Last active Aug 29, 2015
Rx operator which evaluates cancellation
View rx_cancel.cs
public class RxPlayground
{
public static class MyReactiveExtensions
{
public static IObservable<T> ToCancellable<T>(this IObservable<T> source, CancellationToken cancellationToken)
{
var obj = new ThrowWhenCancelled<T>(source);
cancellationToken.Register(obj.Cancel);
return obj.ToObservable();
}
You can’t perform that action at this time.