Skip to content

Instantly share code, notes, and snippets.

View jasonswearingen's full-sized avatar

JasonS jasonswearingen

  • Woodinville WA, USA
  • 00:29 (UTC -07:00)
View GitHub Profile
@jasonswearingen
jasonswearingen / Event.cs
Created January 26, 2023 16:27
C# Event abstraction
/// <summary>
/// thread safe event registration and invoking.
/// subscriptions are stored as weakRefs so they can be garbage collected.
/// </summary>
/// <typeparam name="TEventArgs"></typeparam>
public class Event<TEventArgs> where TEventArgs : EventArgs
{
private List<WeakReference<EventHandler<TEventArgs>>> _storage = new();
/// <summary>
@jasonswearingen
jasonswearingen / proxy.ts
Created January 31, 2019 19:47
toy proxy for NodeJs (http+https support)
//from: https://stackoverflow.com/a/49864522/1115220 re question: https://stackoverflow.com/questions/8165570/https-proxy-server-in-node-js
import http = require( 'http' )
const port: number = Number.parseInt( process.env.PORT ) || 9191;
import net = require( 'net' )
import url = require( 'url' )
import xlib = require( "xlib" );
@jasonswearingen
jasonswearingen / gcloud.d.ts
Last active September 29, 2022 08:28
typescript definitions for gcloud datastore, v0.27.0 complete, but not yet tested/verified.
export interface IModuleImport {
(authOptions?: IAuthOptions): IGCloud;
}
export interface IAuthOptions {
projectId?: string;
keyFilename?: string;
}
@jasonswearingen
jasonswearingen / redux-simple-router-example.tsx
Last active October 31, 2017 19:37
A simplified example of redux + redux-simple-router using Typescript
/**
WHAT: A very simple example of redux + redux-simple-router using Typescript.
WHY: The official example found here: https://github.com/rackt/redux-simple-router/tree/1.0.2/examples/basic has problems:
1) it is spread over many files making it very hard to "skim"
2) it is organized by function, not by feature. (Example: learning "how to manipulate redux state" is spread over 5 files in 4 folders)
3) there are no comments explaining what's going on/why.
WHO: by JasonS@Novaleaf.com