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.

module.exports = Batch
function Batch(sync) {
if(!(this instanceof Batch)) {
return new Batch(sync)
}
this.jobs = []
this.sync = sync
this.frame = null
@hayes
hayes / altr.patch
Created January 27, 2014 17:56
altr diff
diff --git a/lib/filters/add.js b/lib/filters/add.js
index 44d3f99..2c22e8a 100644
--- a/lib/filters/add.js
+++ b/lib/filters/add.js
@@ -1,12 +1,21 @@
var through = require('through')
-module.exports = function(num) {
- console.log(num)
- num = +num
@hayes
hayes / commit-msg
Last active December 25, 2015 15:39
add branch name to commit if not on master
#!/bin/sh
#
# Simply prepends the branch name to every commit message
branch=$(git rev-parse --abbrev-ref HEAD)
if [ $branch != 'master' ] && [ $branch != 'HEAD' ]; then
echo "[$branch] `cat $1`" > $1
fi
@hayes
hayes / request.js
Last active December 25, 2015 15:29
simple request function
function request(method, path, body, headers, ready) {
var xhr = new XMLHttpRequest
, zone
if(typeof headers === 'function') {
ready = headers
headers = {}
} else if(typeof body === 'function') {
ready = body
body = null
@hayes
hayes / to_byte.js
Last active December 19, 2015 21:49
convert a string to a byte array
function to_bytes(str) {
var arr = []
, byte_count
, padding
, binary
, prefix
, bytes
, code
for(var i = 0, len = str.length; i < len; ++i) {
@hayes
hayes / gist:5724622
Last active December 18, 2015 04:19
lat+lon to image with marker
<html>
<head>
</head>
<body>
lat:<input type="text" name="lat" value="45.52578"><br>
lon:<input type="text" name="lon" value="-122.683672"><br>
<img src="">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
var Application = require('./application')
, User = compound.models.User;
var UserController = module.exports = function UserController(init) {
Application.call(this, init);
init.before(loadUser, {
only: ['show', 'edit', 'update', 'destroy']
});
};