Skip to content

Instantly share code, notes, and snippets.

View owenallenaz's full-sized avatar

Owen Allen owenallenaz

View GitHub Profile
@owenallenaz
owenallenaz / Dockerfile
Created September 20, 2021 22:26
res.on("finish") not called on client-side timeout
FROM node:14.16.0
WORKDIR /app
COPY . /app
@owenallenaz
owenallenaz / test.cfm
Last active February 18, 2020 23:23
Cleaning email arrays in CF
<cffunction name="cleanEmails">
<cfargument name="toStr">
<cfset local.tempArr = ListToArray(arguments.toStr)>
<cfset local.newArr = []>
<cfloop array="#local.tempArr#" index="local.email">
<cfset ArrayAppend(local.newArr, trim(lcase(local.email)))>
</cfloop>
const mongolayer = require("mongolayer");
async function findDraft(civid) {
}
async function findNav(civid) {
const contentResult = await findContent(civid);
const result = await site.plugins.nav.apis.navItemVersions.promises.aggregate([
{
@owenallenaz
owenallenaz / test.md
Last active April 26, 2019 16:25
Advanced Filtering

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 March 19, 2019 16:52
Using Apollo schema stitching with context and error handling
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");

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 August 22, 2018 20:39
Difference in error handling for async/await and callbacks
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 July 21, 2017 23:15
RSS expansion due to WeakMap() usage
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 March 31, 2017 01:08
Race condition using require and loader plugins
<!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
@owenallenaz
owenallenaz / gist:1b2e341fa560102de94355fbba1097aa
Created January 25, 2017 00:25
unifying url generation systems
// 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
});