Skip to content

Instantly share code, notes, and snippets.

View hayes's full-sized avatar

Michael Hayes hayes

View GitHub Profile
@hayes
hayes / schema-first.md
Created April 6, 2022 05:07
Pothos schema first concept

Simple SDL

type Query {
  posts(page: Int): [Post!]!
}

type Post {
  author: User
  title: String
@hayes
hayes / errors.md
Created May 30, 2021 21:05
error plugin idea
class Error1() extends Error {
  error1Prop = 'error 1'
}

class Error2() extends Error {
  error2Prop = 'error 2'
}

builder.queryField('example', (t) => t.int({
@hayes
hayes / scope-auth.md
Last active February 4, 2021 00:22
scope auth plugin api proposal for giraphql

Scope Auth

State of proposal

This is a rough overview of a new API for the auth plugin. This will be a breaking change, which will likely coincide with a 2.0 release (possibly for both the plugin and core).

Method and property names, and associated terminology is all placeholder, this version is mostly to cover use cases, and integration points.

Keybase proof

I hereby claim:

  • I am hayes on github.
  • I am hayes (https://keybase.io/hayes) on keybase.
  • I have a public key whose fingerprint is B25D 216F 1F76 4EDB E42A 8852 E7F0 12B4 D53D 1962

To claim this, I am signing this object:

@hayes
hayes / shim.js
Last active August 29, 2015 14:17
var scoped = require('scoped')
var falafel = require('falafel')
function shim(code, done) {
falafel(code, scoped(wrap))
function wrap(scope) {
var vars = scope.vars
var out = 'var global = module.exports;\n(function(' + vars.join(', ') + ') {\n'
out += code + ';\n'
www(null, '', 'nrnpm')
unpm.middleware.push(docs)
unpm.server.listen(instance.port)
function docs(respond, matched, unpm, next) {
var headers = respond.req.headers
var route
var acceptable = headers.accept && headers.accept.match(/image|(text\/(?:html|css))/)
var tarball = respond.req.url.match(/\.tgz$/i)
var run = require('jsdom-eval')
function(js, html, stdout, stderr) {
run(js, html, function(data) {
(data.method === 'error' ? stderr : stdout).write(data.message)
})
}
var document = require('dom-lite').document
var specificity = require('specificity')
var cssauron = require('cssauron')
var css = require('cssauron')({
tag: 'tagName',
contents: 'innerText',
id: 'id',
class: 'className',
parent: 'parentNode',
@hayes
hayes / how-to-log.js
Last active August 29, 2015 14:09
Most loggers write to streams in a risky way, here is a simple demonstration, and way to avoid the issue.
var fs = require('fs')
var http = require('http')
var count = 0
// using fs.createWriteStream directly will cause massive memory and cpu ussage
// var log = fs.createWriteStream('test.log')
// if you want to make your computer feel bad, replace this with the line above
var log = new Logger('test.log')
var fs = require('fs')
var stream = fs.createWriteStream('test_log.log', {flags: 'w+'})
var buf = new Buffer('im just a little string, log me out and watch mem grow\n', 'utf8')
var start = Date.now()
function log() {
for(var i = 0; i < 1000; i++) {
stream.write(buf)
}
console.log(process.memoryUsage())