Skip to content

Instantly share code, notes, and snippets.

using MediatR;
using TypeConst.Cli.Interfaces;
namespace TypeConst.Cli.Models;
public class Entity1 : IName, IRequest
{
public string Name { get; set; } = default!;
}
@n-j-m
n-j-m / docker-compose.yaml
Created February 11, 2021 08:10
Docker PostgreSQL server and PGAdmin4
version: '3.7'
services:
db:
image: postgres:latest
restart: always
environment:
POSTGRES_DB: postgres
POSTGRES_USER: someuser
POSTGRES_PASSWORD: somepassword
@n-j-m
n-j-m / GenericRequestPostProcessor.cs
Last active July 4, 2018 06:36
Implementation of an IRequestPostProcessor that takes a "long time" to execute.
using System;
using System.IO;
using System.Threading.Tasks;
using MediatR.Pipeline;
namespace MediatR.Examples
{
public class GenericRequestPostProcessor<TRequest, TResponse> : IRequestPostProcessor<TRequest, TResponse>
{
private readonly TextWriter _writer;
@n-j-m
n-j-m / better-fill.js
Last active February 25, 2018 20:29
Illustrates how to use generator functions to initialize and manipulate arrays.
/*
Copyright 2018 Nick Moore
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH
(function (root) {
const arrayMethods = ['push', 'pop', 'splice', 'shift', 'unshift', 'sort', 'reverse']
function cloneArray (arr) {
return Array.prototype.slice.call(arr, 0)
}
function augmentArray (arr, consumer, context) {
arrayMethods.forEach(method => {
const app_settings = require('json!./app_settings.json')
let clientsLoaded = 0
let auth2Loaded = false
let signin2Loaded = false
let auth2
const apiLoader = {
client() {
return new Promise(resolve => {
@n-j-m
n-j-m / es5.js
Last active August 29, 2015 14:26
Readable Observable
var Observable = Rx.Observable;
function buildQueue(abTestInfo, getJSON) {
return function(config) {
if (config.showInstantQueue) {
return getJSON("http://example.com/" + abTestInfo.urlPrefix + "/queue")
.map(function(queueMessage) { return queueMessage.list; });
}
else {
return Observable.returnValue(undefined);
@n-j-m
n-j-m / using-rxjs-instead-of-flux-with-react.md
Last active August 29, 2015 14:25 — forked from justinwoo/using-rxjs-instead-of-flux-with-react.md
Using RxJS instead of Flux with React to organize data flow

Reposted from Qiita

For almost a year now, I've been using this "flux" architecture to organize my React applications and to work on other people's projects, and its popularity has grown quite a lot, to the point where it shows up on job listings for React and a lot of people get confused about what it is.

Why I'm tired of using and teaching flux

There are a billion explainations on the internet, so I'll skip explaining the parts. Instead, let's cut to the chase -- the main parts I hate about flux are the Dispatcher and the Store's own updating mechanism.

If you use a setup similar to the examples in facebook/flux, and you use flux.Dispatcher, you probably have this kind of flow: