Skip to content

Instantly share code, notes, and snippets.

Owen Allen owenallenaz

Block or report user

Report or block owenallenaz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@owenallenaz
owenallenaz / test.md
Last active Apr 26, 2019
Advanced Filtering
View test.md

Currently our graphql filters only support exact matches { acct_id : "5" }, or { name : "x" }.

I'm adding the feature to expose mongodb advanced filtering mechanics $exists, $gt, $lt, $regex etc. What should the syntax be for adding advanced filters in a way that we can add them to all of our find() endpoints.

standard filtering in graphql and prefix

{
  auth {
    products(filter: { url : "http://url.is/exactly/this" })
  }
@owenallenaz
owenallenaz / server.js
Last active Mar 19, 2019
Using Apollo schema stitching with context and error handling
View server.js
const { HttpLink } = require("apollo-link-http");
const { ApolloLink } = require("apollo-link");
const { setContext } = require("apollo-link-context");
const { onError } = require("apollo-link-error");
const fetch = require("node-fetch");
const express = require("express");
const { introspectSchema, makeRemoteExecutableSchema, ApolloServer, gql, mergeSchemas } = require("apollo-server-express");
const { TypeInfo, GraphQLSchema } = require("graphql");
const assert = require("assert");
const lodash = require("lodash");
View gist:48278400e3ac3e5e6e0a5cbf522bd078

Right now most queries are

table(filter: {}, paging : { limit : x, skip : x })

Do we rename paging to options, and put sort inside?

users(filter: {}, options: { limit : x, skip : x, sort : x })
@owenallenaz
owenallenaz / test.js
Last active Aug 22, 2018
Difference in error handling for async/await and callbacks
View test.js
const request = require("request");
const express = require("express");
const util = require("util");
const app = express();
const requestPromise = util.promisify(request);
const timeoutPromise = util.promisify(setTimeout);
const getImgUrl = function(hostname, comicId, cb) {
request(`https://${hostname}/${comicId}/info.0.json`, function(err, resp, body) {
@owenallenaz
owenallenaz / Node 7.10.0 results
Created Jul 21, 2017
RSS expansion due to WeakMap() usage
View Node 7.10.0 results
process { http_parser: '2.7.0',
node: '7.10.0',
v8: '5.5.372.43',
uv: '1.11.0',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '51',
openssl: '1.0.2k',
icu: '58.2',
unicode: '9.0',
@owenallenaz
owenallenaz / index.html
Created Mar 31, 2017
Race condition using require and loader plugins
View index.html
<!doctype html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script>
<script>
require.config({
paths : {
"slow" : "/slow",
},
waitSeconds : 60
View gist:1b2e341fa560102de94355fbba1097aa
// in api
var buildUrl = miscLib.memoizeSync(function(args) {
return crmLib.buildMultipleDetailUrl({
title : args.title,
recid : args.recid,
defaultPath : plugin._def.settings.detail.path,
detailPath : miscLib.varLookup(plugin._detailTypeIndexBySite, [args.detail_type, args.site]),
sitePath : miscLib.varLookup(site, ["siteConfigs", args.site, "urlNoSlash"]),
absolute : args.absolute
});
@owenallenaz
owenallenaz / dnsCaller.js
Created Jan 13, 2017
Showing stalled file reads because of `dns.lookup`
View dnsCaller.js
var dns = require("dns");
var http = require("http");
var fs = require("fs");
var net = require("net");
dns.setServers(["127.0.0.1"]);
var makeCallLookup = function(cb) {
dns.lookup("testSlow.com", cb);
}
@owenallenaz
owenallenaz / loadModule.js
Last active Jun 29, 2017
Fast module hacking
View loadModule.js
// var fs = require("fs");
// var Module = require("module");
// var pathCache = JSON.parse(fs.readFileSync("/sv/test/pathCache.json").toString());
// Object.keys(pathCache).forEach(function(val, i) {
// Module._pathCache[val] = pathCache[val];
// });
// console.time("load");
// // var mongolayer = require("/sv/node_modules/npm/mongolayer/1/node_modules/mongolayer/");
@owenallenaz
owenallenaz / README.md
Created Dec 20, 2016
Faking a slow DNS server to show setTimeout not affected by dns resolution timing
View README.md

node dnsLagDnsServer.js

node dnsLagServer.js

node dnsLag.js

--- dnsLag.js should timeout if the timeout was affected

You can’t perform that action at this time.