Skip to content

Instantly share code, notes, and snippets.

View tejacques's full-sized avatar

Tom Jacques tejacques

  • Tinder
  • San Francisco Bay Area
View GitHub Profile
; (function (global, define) { define('module-name', function (require, exports, module) {
// CommonJS style code here
/*!
* UMD/AMD/Global context Module Loader wrapper
* based off https://gist.github.com/tejacques/202a8f2d198ddd54a409
*
* This wrapper will try to use a module loader with the
* following priority:
*

Geo sharding

Shard Space

Like redis cluster, we'll use a shard space of 2^14 = 16384. Essentially what this means is that we'll take our entire geo area, and split it into 16384 segments of approximately equal entries.

Each instance will be responsible for any number of segments, typically a cluster of segments that are geographically close.

Searches

@tejacques
tejacques / HOCBaseRender.tsx
Last active May 2, 2022 13:05
React Higher Order Components in TypeScript
import * as React from 'react';
import { Component } from 'react';
export default function HOCBaseRender<Props, State, ComponentState>(
Comp: new() => Component<Props & State, ComponentState>) {
return class HOCBase extends Component<Props, State> {
render() {
return <Comp {...this.props} {...this.state}/>;
}
}
/**
* I'd like to have a router with semantics that work like this
* Pros:
* - Named routes
* - Type Safe routing (with TypeScript)
* - Links are not strings so refactoring/changing them is trivial
* - Relative links are possible
*
* Cons:
* - Verbose links
@tejacques
tejacques / RPCDemo.cs
Last active October 26, 2020 23:06
C# Async Mini RPC Demo
using ServiceStack.Text;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
@tejacques
tejacques / asynceval.js
Last active October 24, 2020 07:17
Async Polyfill for javascript using eval and async function transform
/* Idea for allowing async-style functions in vanilla JS
* This transforms a function which uses await into a function
* which returns an ES6-style promise
*
* eval has the property of running the string of javascript
* with the same closure scope chain as the method it is called
* from, which is why it is necessary to call eval on the output
* of the async function, which returns a string representing
* the transformed function.
*/
function identity(x) {
return x;
}
function fp<T1, T2> (
transform: (x: T1) => T2
): (x: T1) => T2;
function fp<T1, T2, T3> (
transform1: (x: T1) => T2,
let wrappable = {
'object': true,
'function': true
};
let autowrapSymbol = '@@autowrap';
function wrap(fn) {
console.log('wrapping function call');
let wrapped = function() {

IDL:

  • Creates an Avro-like Schema
  • Desn't require labeling field location as in Thrift / Protocol Buffers
  • Compiler to generate output boilerplate code in multiple languages
  • Runtime library for supported languages which boilerplate code will use (targeting C++, Java, Python, JavaScript, TypeScript, C#, Kotlin, Scala)
  • Supports storing data in Array of Struct (Row) or Struct of Array format (Column) per record type
  • Allows Specifying RPC calls
  • Annotations for optional implementation details
  • Inheritance
@tejacques
tejacques / keybase.md
Last active September 21, 2016 19:04

Keybase proof

I hereby claim:

  • I am tejacques on github.
  • I am tejacques (https://keybase.io/tejacques) on keybase.
  • I have a public key whose fingerprint is 8D52 2AF4 F797 A946 BD36 FA92 5498 9516 13E3 FAC8

To claim this, I am signing this object: