Skip to content

Instantly share code, notes, and snippets.

View lirbank's full-sized avatar
🚴‍♂️
Riding me' bike

Mikael Lirbank lirbank

🚴‍♂️
Riding me' bike
View GitHub Profile
@adamkl
adamkl / regen-domain-types.js
Last active September 28, 2022 15:04
Generating typescript definitions from .graphql files using apollo-codegen and graphql-code-generator
const { introspectSchema } = require("apollo-codegen");
const { executeWithOptions } = require("graphql-code-generator/dist/cli");
const fs = require("fs");
const path = require("path");
const graphqlPath = "./src/graphql/";
const schemaInput = "./src/graphql/temp.graphql";
const jsonOutput = "./src/graphql/temp.json";
const dtsOutput = "./src/graphql/domain.d.ts";
@chrisckchang
chrisckchang / dupe-finder.js
Last active February 16, 2017 15:11
Aggregation query to find duplicate key values
// Desired unique index:
// db.collection.ensureIndex({ firstField: 1, secondField: 1 }, { unique: true})
db.collection.aggregate([
{ $group: {
_id: { firstField: "$firstField", secondField: "$secondField" },
uniqueIds: { $addToSet: "$_id" },
count: { $sum: 1 }
}},
{ $match: {
@ritikm
ritikm / 1_settings.js
Created October 15, 2013 22:57
Pure-JS method of importing settings into Meteor.js. This file is put in server/lib.
environment = process.env.NODE_ENV || "development";
var settings = {
development: {
public: {},
private: {}
},
staging: {
public: {},
private: {}
@joscha
joscha / meteor-async.md
Last active August 29, 2017 06:51 — forked from possibilities/meteor-async.md
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished.