Skip to content

Instantly share code, notes, and snippets.

Matthew Podwysocki mattpodwysocki

Block or report user

Report or block mattpodwysocki

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
View orderby.ts
// New Way
export function orderBy<TSource>(
key: keyof TSource
): UnaryFunction<AsyncIterable<TSource>, OrderedAsyncIterableX<TKey, TSource>> {
return function orderByOperatorFunction(source: AsyncIterable<TSource>) {
return new OrderedAsyncIterableX<TSource>(source, key, false);
};
}
// Old way
View groupby-new.ts
export interface GroupByOptions<TSource, TKey, TValue = TSource> {
keySelector: (value: TSource) => TKey | Promise<TKey>;
elementSelector?: (value: TSource) => TValue | Promise<TValue>;
signal?: AbortSignal;
}
export interface GroupByOptionsWithSelector<TSource, TKey, TValue, TResult> {
keySelector: (value: TSource) => TKey | Promise<TKey>;
elementSelector?: (value: TSource) => TValue | Promise<TValue>;
resultSelector?: (
View delay.ts
import { AbortError } from "../util/aborterror";
export function delay(action: () => void, dueTime: number, signal?: AbortSignal) {
return new Promise((resolve, reject) => {
if (signal?.aborted) {
throw new AbortError();
}
const id = setTimeout(() => {
if (signal?.aborted) {
@mattpodwysocki
mattpodwysocki / concatcall.ts
Last active Feb 3, 2020
Adding basic cancellation to IxJS AsyncIterable
View concatcall.ts
import { AsyncIterableX } from '../asynciterablex';
import { OperatorAsyncFunction } from '../../interfaces';
import { wrapWithAbort } from './withabort';
export class ConcatAllAsyncIterable<TSource> extends AsyncIterableX<TSource> {
private _source: AsyncIterable<AsyncIterable<TSource>>;
private _signal?: AbortSignal;
constructor(source: AsyncIterable<AsyncIterable<TSource>>, signal?: AbortSignal) {
super();
View Stamp.ps1
function Get-Files($path = $pwd) {
foreach ($item in Get-ChildItem $path) {
if (Test-Path $item.FullName -PathType Container) {
Get-Files $item.FullName
} else {
$item
}
}
}
View mousedrag.js
const move$ = fromEvent(document, 'mousemove')
const down$ = fromEvent(document, 'mousedown')
const up$ = fromEvent(document, 'mouseup')
const mergeFn = downs => { // In case you want the first position
// If you want to deltas between start and end, you might want a map that captures downs versus moves
return move$.pipe(takeUntil($ups));
};
const paints$ = move$.pipe(
View unitofwork.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
View Repository.cs
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using SQLite;
namespace MobCat.Data.Repositories
{
View Repository.cs
public interface IDataRepository<TEntity> : IDisposable where TEntity : class
{
ICollection<TEntity> Find(
Expression<Func<TEntity, bool>> criteria,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = "");
Task<ICollection<TEntity>> FindAsync(
Expression<Func<TEntity, bool>> criteria,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
string includeProperties = "");
View flatmap.ts
import { AsyncObserver, AsyncObserverX } from './asyncobserver';
import { AsyncObservable, AsyncObservableX } from './asyncobservable';
import { AsyncSubscription } from './asyncsubscription';
import { AsyncSubscriptionX } from './subscriptions/asyncsubscriptionx';
import { CompositeAsyncSubscription } from './subscriptions/compositeasyncsubscription';
import { BinarySubscription } from './subscriptions/stablecompositeasyncsubscription';
import { SingleAssignmentAsyncSubscription } from './subscriptions/singleassignmentasyncsubscription';
import { bindCallback } from '../internal/bindcallback';
class InnerObserver<T, R> extends AsyncObserverX<R> {
You can’t perform that action at this time.