Skip to content

Instantly share code, notes, and snippets.

@thedillonb
thedillonb / work-queue.ts
Created August 18, 2020 03:01
RXJS Work Queue
import * as rx from 'rxjs';
import { concatMap, onErrorResumeNext, tap } from 'rxjs/operators';
export class WorkQueue<T = unknown> {
private queue = new rx.Subject<[rx.Observable<T>, rx.Subscriber<T>]>();
constructor() {
this.queue.pipe(concatMap(this.doWork)).subscribe();
}
@thedillonb
thedillonb / gist:79f3d8a538f4a56d4e42b8078e061659
Created June 4, 2018 19:02
Server Sent Events TypeScript Definition
declare module 'server-sent-events' {
import express = require('express');
interface Middleware extends express.RequestHandler {}
function MiddlewareFn(): Middleware;
export = MiddlewareFn;
}
declare namespace Express {
export interface ISSEResponse {
sse(value: string): void;
@thedillonb
thedillonb / Food
Created July 2, 2017 01:37
Creat!!
Goes in my tummy
@thedillonb
thedillonb / query.gql
Created February 19, 2017 14:52
GraphQL Introspection Query
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
using System.Collections.Generic;
using System.Linq;
using System;
using System.Text;
public static class ArrayExtensions
{
public static Diff<T> Diff<T>(IEnumerable<T> @this, IEnumerable<T> other)
where T : IEquatable<T>
@thedillonb
thedillonb / stamp.cs
Created April 1, 2016 01:01
Stamp iOS With Date
public static class UIApplicationDelegateExtensions
{
/// <summary>
/// Record the date this application was installed (or the date that we started recording installation date).
/// </summary>
public static DateTime StampInstallDate(this UIApplicationDelegate @this, string name)
{
try
{
var query = new SecRecord(SecKind.GenericPassword) { Service = name, Account = "account" };
@thedillonb
thedillonb / index.js
Last active April 23, 2017 00:59
NodeJS Graceful shutdown of a HTTP server
'use strict';
const http = require('http');
function addGracefulShutdown(server) {
const oldClose = server.close;
const connections = {};
let shouldDestroy = false;
let connectionId = 0;
function destroy(socket) {
@thedillonb
thedillonb / Moocow
Created August 30, 2015 21:27
Awesome!
Hello
@thedillonb
thedillonb / permute-characters.js
Last active August 30, 2015 02:57 — forked from h2non/permute-characters.js
Recursive implementation of string characters permutation covering all possible cases without duplication
/**
* Recursive implementation of string characters permutation
* covering all possible cases without duplication
*/
function permute(str) {
var stack = []
if (str.length === 1) {
return [ str ]
}
@thedillonb
thedillonb / program.fs
Created July 26, 2015 01:12
A very simple F# example using OWIN
open System
open Owin
open Microsoft.Owin
let doStuff (x:IOwinContext) =
x.Response.StatusCode <- 200
x.Response.WriteAsync "Hello!"
[<EntryPoint>]
let main argv =