Skip to content

Instantly share code, notes, and snippets.

View jsrubin's full-sized avatar

Justin Rubin jsrubin

  • ServiceNow
  • San Diego, CA
View GitHub Profile
@jsrubin
jsrubin / recursive-problem.js
Last active February 20, 2022 19:22
Recursive code challenge problem
const flatData = [
{
"id":0,
"order":1,
"name":"trigger",
"children":[
1,
11
]
},
@jsrubin
jsrubin / chainedClassJS.js
Created May 23, 2019 19:47
ES6 Chained Class Object
/*
ES6 Chained Class Object
*/
class User {
let _name;
constructor(name) {
_name = name || "";
}
@jsrubin
jsrubin / schemaStitcher.js
Created March 8, 2019 22:14
GraphQL schema stitcher class
const path = require("path");
const { map, merge } = require("lodash");
const { makeExecutableSchema } = require("graphql-tools");
module.exports = class GraphQLStitch {
constructor(dir) {
this.schemaDir = __dirname + "/" + dir;
this.schemaFiles = this.readSchemaFiles();
return makeExecutableSchema({
@jsrubin
jsrubin / graphqlSchemaPastry.js
Created March 6, 2019 16:20
Graphql schema for pastry endpoint
module.exports.typeDefs = `
extend type Query {
getPastry(id: Int!, name: String): Pastry
getPastries(temp: Temperature, type: Category): [Pastry]
}
extend type Mutation {
addPastry(name: String!, type: Category!): Success
}
type Pastry {
@jsrubin
jsrubin / graphqlSchemaStitch.js
Last active February 19, 2019 17:06
Graphql schema stitching
require("graphql-tools").makeExecutableSchema({
typeDefs: [ common.typeDefs, drink.typeDefs, food.typeDefs ],
resolvers: merge([ common.resolvers, drink.resolvers ])
});
@jsrubin
jsrubin / graphqlSchemaCommon.js
Last active February 19, 2019 16:37
GraphQL Schema Common
module.exports.typeDefs = `
type Query {
ping: Boolean!
}
type Mutation {
ping: Boolean!
}
type Success {
status: Boolean!
@jsrubin
jsrubin / graphqlSchemaDrinks.js
Last active March 6, 2019 16:15
GraphQL Schema Coffee
module.exports.typeDefs = `
extend type Query {
getDrink(id: Int!, name: String): Drink
getDrinks(temp: Temperature, type: Category): [Drink]
}
extend type Mutation {
addDrink(name: String!, temp: Temperature!, type: Category!): Success
}
@jsrubin
jsrubin / tvView.js
Last active July 23, 2018 23:55
UI hard coded metric for Browse view
define(function () {
'use strict';
return {
tvViewRateBeta: {
name: 'TV View Rate (Visits)',
resources: [
'tvViews',
'visits'
@jsrubin
jsrubin / actionsEnum.java
Last active July 23, 2018 23:56
Enum of beacon Actions
enum ActionType {
HOMEPAGE_VIEW(true), // context aware
..., // lots more actions here
TV_VIEW(true);
private boolean contextAware = false;
private ActionType(boolean contextAware) {
this.contextAware = contextAware;
}
@jsrubin
jsrubin / metricDef.json
Last active July 23, 2018 23:56
example metric definition
"tvViewsCount": {
"metric": {
"identifier": "tvViewsCount",
"name": "TV Views (Visits)",
"resources": [
"tvViewsCount"
],
"options": {
"isPercent": false
},