Skip to content

Instantly share code, notes, and snippets.

View tejacques's full-sized avatar

Tom Jacques tejacques

  • Tinder
  • Los Angeles
View GitHub Profile
#include <type_traits>
template <typename...TArgs>
struct TypeList {};
// Assume TElement is not in the list unless proven otherwise
template < typename TElement, typename TList >
struct ContainsType {
static constexpr bool value = false;
};
@tejacques
tejacques / TypedBuilder.cpp
Last active August 10, 2016 01:27
TypeSafe object loader
#include <stdio.h>
#include <vector>
using std::vector;
enum UserFlags {
BASICS = 0x1,
LOCATION = 0x2
};

Properties:

  • Highly efficient schema-driven RPC calls
  • Session-Aware Metrics
  • Standard reporting for services about their interfaces
  • Registration with membership/load balancing servers which spread requests and merge responses
    • One such load balancer is the router service, which registers a regular-like expression (trie routing)
    • Another such load balancer is data/query routing service -- think top level of a GraphQL API. It needs to communicate with other services to generate the data.
    • Should work isomorphically, client-side bundled multiple routes, server forwards routes
  • Should support in-process communication as well, which also live/hot updates (at least in supported languages). This can be accomplished by not saving stateful objects, but instead communicating to services over interfaces.
@tejacques
tejacques / TestRuntimes.cs
Last active December 19, 2015 10:29
Test the execution time of task wrapping / waiting vs. AsyncBrdige.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using AsyncBridge;
using System.Diagnostics;
namespace AsyncTests
@tejacques
tejacques / .bashrc
Last active December 16, 2015 00:29
.bashrc file with prompt coloring, check / x mark for success / failure, number of jobs running, and directory, and writing the current running application to the screen window name using escape characters.
# .bashrc
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
var testFn = function() {};
testFn.prototype.test1 = function() {
console.log('test1');
};
testFn.prototype.test2 = function() {
console.log('test2');
};
@tejacques
tejacques / ExceptLastLinq.cs
Created March 10, 2014 03:55
IEnumerable extension for all but the last n elements of a sequence.
namespace System.Linq
{
public static class ExceptLastLinq
{
public static IEnumerable<T> ExceptLast<T>(
this IEnumerable<T> source)
{
if (source == null)
throw new ArgumentNullException("source");
public static class Extensions
{
public static async Task ForEachAsync<T, U>(this IEnumerable<T> collection, Func<T, Task<U>> body, IObserver<U> observer = null)
{
foreach (var item in collection)
{
var res = await body(item);
if (null != observer)
{
observer.OnNext(res);