Skip to content

Instantly share code, notes, and snippets.

View thomasheyenbrock's full-sized avatar

Thomas Heyenbrock thomasheyenbrock

View GitHub Profile
@thomasheyenbrock
thomasheyenbrock / typesafe-graphql-queries.ts
Last active April 19, 2022 08:30
Building type-safe queries with variables- and result-types in GraphQL
/* eslint-disable */
/**
* What do we want to achieve here? 👀
*
* 1. Write type-safe GraphQL queries with autocomplete and all the cool stuff
* 2. For the query we just wrote, we want to have...
* a. ...types for the resulting data
* b. ...types for the used variables
*
@thomasheyenbrock
thomasheyenbrock / README.md
Last active February 6, 2019 09:15
create combinations for items with multiple unique identifiers

How to combine some stuff

Scenario

Imagine that you want to buy DVDs for all the Star Wars movies of the original trilogy. (For all the prequel and sequel lovers, this scenario works as well with more movies.) You search Ebay and end up with a list of auctions, each with a different price and each containing a certain subset of the three movies.

const auctions = [
  { id: 1, price: 11,  movies: ["NEW_HOPE"] },
 { id: 2, price: 13, movies: ["EMPIRE_STRIKES_BACK"] },
@thomasheyenbrock
thomasheyenbrock / snippet.js
Created July 4, 2018 15:01
What the google analytics tracking snippet really does...
// create a ga function in the window object (if not exists)
// which queues all function calls as long as the real script
// is not loaded yet
window.GoogleAnalyticsObject = 'ga';
window.ga = window.ga || function () {
(window.ga.q = window.ga.q || []).push(arguments)
};
window.ga.l = 1 * new Date();
// create new script tag to load the "real" ga function