This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ex: ruby ./costsort.rb /path/to/query.txt | |
# look for biggest change furthest in middle of tree | |
path = ARGV[0] | |
line_number = 0 | |
results = [] | |
File.open(path, 'r').each_line do |line| | |
if line.include?("cost=") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const path = require("path"); | |
/** | |
for each package | |
Convert src/* kebab-case to ClassCase | |
Look inside, remove any customElements.define usage | |
for each camelCase name not containing style or .d.ts or Index.js - | |
write a kebab-cased export that defines custom element | |
for each camelCase name not containing Index.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Following along withhttps://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/ | |
// Basic Mixin Implementation | |
const MyMixin = (superclass: any) => | |
class extends superclass { | |
foo() { | |
console.log("foo from MyMixin"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage: | |
// type Query { | |
// organizations( | |
// where: OrganizationWhereInput | |
// first: Int | |
// skip: Int | |
// orderBy: OrganizationOrderByInput | |
// ): [Organization]! @hasPermission(requires: [OEM_ADMIN, ORG_ADMIN]) | |
// organization(id: ID!): Organization | |
// associatedOrganization: Organization @isAuthenticated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SchemaDirectiveVisitor } from "apollo-server-koa"; | |
import { GraphQLField, defaultFieldResolver } from "graphql"; | |
class IsAuthenticatedDirective extends SchemaDirectiveVisitor { | |
visitFieldDefinition(field: GraphQLField<any, any>) { | |
const { resolve = defaultFieldResolver } = field; | |
field.resolve = async function(...args) { | |
const ctx = args[2]; | |
if (!ctx.state.user.id) { | |
throw new Error("You must be signed in to do this."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const programsQuery = ctx => { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve({ | |
program: { | |
id: ctx.params.id, | |
name: 'hey', | |
}, | |
}); | |
}, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buildTask = (taskName, resolver) => { | |
return { | |
[taskName]: { | |
initial: "resolving", | |
states: { | |
resolving: { | |
invoke: { | |
id: taskName, | |
src: ctx => resolver(ctx), | |
onError: "errored", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const machine = Machine( | |
{ | |
id: 'multiply', | |
initial: 'addThenMultiply', | |
states: { | |
addThenMultiply: { | |
on: { | |
TOGGLE: 'multiplyThenAdd', | |
INCREMENT: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wordMachine = Machine({ | |
id: 'word', | |
type: 'parallel', | |
states: { | |
bold: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_BOLD: 'off' } | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lightMachine = Machine({ | |
id: 'light', | |
initial: 'green', | |
type: 'compound', | |
states: { | |
green: { | |
on: { | |
TIMER: 'yellow' | |
} | |
}, |
NewerOlder