Skip to content

Instantly share code, notes, and snippets.

// there are many json-schema validators available, I prefer ajv
let Ajv = require('ajv')
let ajv = Ajv({ allErrors:true })
let swagger = require('./docs/my-swagger-definition')
// validation middleware
let validateSchema = (parameters) => {
return (req, res, next) => {
let errors = []
parameters.map(param => {
@CacheControl
CacheControl / gist:9cbe66dc251ef45a351abf44dc584c9c
Last active May 18, 2022 22:27
snowflake-labelsnow-sql-compilation-error

SQL compilation error when running

labelsnow.put_tables_into_snowflake(ctx, labelbox_payload)

Cause: Missing permissions to create table. Ensure write access to database, schema, warehouse.

@CacheControl
CacheControl / apollo-rover-could-not-parse-partial-schema.md
Created June 15, 2021 20:16
Apollo rover "Could not parse partial schema as AST."

"Could not parse partial schema as AST."

Ran into this when using rover to parse a graphql schema that had a syntax error. The issue was caused by double quotes in a graphql comment, something allowed by the framework I was using to render the schema (DGS).

"""Placing quotes around "strings" in graphql comments causes this error""""  # INVALID

The fix is to remove or replace the double quotes, e.g.

@CacheControl
CacheControl / Dockerfile
Created October 9, 2020 20:26
dockerfile for bundling graphicsmagick within a lambda
FROM amazonlinux
# epel-release required for graphicsmagick
RUN amazon-linux-extras install epel
RUN yum -y --nogpgcheck install gcc-c++ make GraphicsMagick yum-utils rpmdevtools
# node.js 12 (also adds npm)
RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash -
RUN yum -y --nogpgcheck install nodejs
@CacheControl
CacheControl / partition_function.sql
Last active May 20, 2019 22:54
Postgresql Table Partitioning Function
CREATE OR REPLACE FUNCTION
public.insert_comment()
RETURNS TRIGGER AS
$BODY$
DECLARE
_start_dt text;
_end_dt text;
_table_name text;
BEGIN
IF NEW.id IS NULL THEN
@CacheControl
CacheControl / http-request-promise.js
Created March 22, 2019 15:25
node.js http request to promise
const http = require('http');
return new Promise((resolve, reject) => {
http.get(url, (res) => {
if (res.statusCode >= 400) {
const err = new Error(`${res.statusCode} - ${res.statusMessage}`);
err.statusCode = res.statusCode;
return reject(err);
}
return resolve(res);
@CacheControl
CacheControl / Movie View
Created November 12, 2012 05:50
Backbone view
var MovieView = Backbone.View.extend({
listTemplate: _.template($("#movieTemplate").html()),
editTemplate: _.template($("#movieEditTemplate").html()),
initialize: function() {
this.model.on('change', this.render, this);
this.model.on('destroy', this.remove, this);
this.model.on('error', this.invalid, this);
},
render: function() {
this.$el.html(this.listTemplate(this.model.toJSON()));